As per my understanding, an SPV client only keeps a track of the block headers in its own database. So when a user tries to send bitcoins using that particular SPV client, how is the transaction constructed?
A user using that client will probably enter the amount he wants to send and the destination address. And he probably will be signed in using his private key.
So using these 3 data i.e. amount, destination and privateKey how will the SPV construct the whole transaction object.
Because I know that if I have to manually write a transaction by hand, I need:
- Previous Transaction Hash (Funding Transaction).
- Sequence Number of the UTXO I am trying to spend.
- ScriptSig or the unlocking key, which is constructed using the privateKey and the hash of the entire transaction body.
- Output Value.
- ScriptPubKey which is constructed using the destination address.
- SigHash Code.
So I am just supplying amount, destination and private key. How will the SPV client get the remaining values such as Prevout hash, sequence Number, how many UTXOs to be unlocked and how many new UTXOs should be formed?
It will be very helpful, if someone mentions a codebase where the implementation is given.