I am playing around with the core code trying to implement my own wallet (out of curiosity and mainly to get better grips with internals).
So far this is what i have done
- Launched in regtest mode , generated 101 blocks with mining reward 50.0 BTC paid out.
- Got hold of the chainActive structure and basically trying to implement a version of ScanForWalletTransactions.
- Following the crumbs from the above function leads me to Solver (called via isMine)
bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, std::vector >& vSolutionsRet);
If I look at the representation of the pubKey script in the reward transaction it looks something like :
2103d7a738b1e5d4f66470d3439d970661c83e35054408eff625b441967be85caea7ac
Which is decoded to :
03d7a738b1e5d4f66470d3439d970661c83e35054408eff625b441967be85caea7 OP_CHECKSIG
Looking at the solver , this transactions will not be decoded to TX_PUBKEY as it expects the following in the template
CScript() << OP_PUBKEY << OP_CHECKSIG
But the getBalance RPC can correctly deduce the balance, so essentially it works.
For the love of god , i am unable to figure out how is the simple script signature of
OP_CHECKSIG is added to the wallet. Any tips will be appreciated.
Cheers!