Saturday, October 5, 2024

consumer – Ship or obtain bitcoins with bitcoin-cli with out downloading full blockchain

I believe you could possibly do what you might be asking with an explorer API and rawtransactions, nevertheless you have to watch out when utilizing rawtransactions as you could possibly lose numerous cash if you happen to dont know what you might be doing (see my observe on the finish).

Transactions are made from inputs and outputs. Let’s imagine you’ve gotten 10 cash on deal with A, you could possibly have two unspent transaction outputs (the two outputs from once you deposited the ten cash), perhaps one unspent output has 7 cash, and the opposite 3 cash (totaling 10).

If you wish to ship your pal 1 coin, you could take the obtainable unspent transaction of three cash, ship 1 coin to your pal, and 1.9999 cash (after charges of 0.0001) will probably be returned to you as “change”. Right here is an instance transaction https://chainz.cryptoid.information/btc/tx.dws?499936575.htm You possibly can see 1 earlier output, changing into the enter, and the 2 ensuing outputs.

Your bitcoin-cli pockets wants the total blockchain, as a result of the record of your unspent transactions is constructed from all of the inputs and outputs. Nonetheless discover that the explorer I linked to additionally has an API and (if you happen to request and are granted an API key) the next question will lead to supplying you with all of the inputs for that particular deal with;

https://chainz.cryptoid.information/BTC/api.dws?q=unspent&key=(YOUR_API_KEY)&lively=18mcGpg2e3Fj6djLxiCbdjgh3cD46VayLC

You then would use the RPC console to:
1/ createrawtransaction
2/ signrawtransaction
3/ sendrawtransaction

Check with the https://en.bitcoin.it/wiki/Raw_Transactions Wiki for utilization and different helpful CLI instructions round this subject.

WARNING: Be aware when utilizing createrawtransaction you MUST MANUALLY CALCULATE TRANSACTION FEES AND CHANGE, if you happen to fail to do that accurately change will probably be consumed as charges!!!

So now you’ll be able to see how its doable (though extraordinarily awkward!) to make and ship transactions and not using a native copy of the blockchain. When it comes to how a Ledger works, I believe they do steps 1/ createrawtransaction and three/ sendrawtransaction in an un-secure setting, they simply use the Ledger itself to do step 2/ signrawtransaction, as that is the one level at which personal keys are wanted.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles