client – Send or receive bitcoins with bitcoin-cli without downloading full blockchain

1 Mins read

I think you could do what you are asking with an explorer API and rawtransactions, however you need to be careful when using rawtransactions as you could lose a lot of coins if you dont know what you are doing (see my note at the end).

Transactions are made of inputs and outputs. Lets say you have 10 coins on address A, you could have two unspent transaction outputs (the 2 outputs from when you deposited the 10 coins), maybe one unspent output has 7 coins, and the other 3 coins (totaling 10).

If you want to send your friend 1 coin, you may take the available unspent transaction of 3 coins, send 1 coin to your friend, and 1.9999 coins (after fees of 0.0001) will be returned to you as “change”. Here is an example transaction You can see 1 previous output, becoming the input, and the two resulting outputs.

Your bitcoin-cli wallet needs the full blockchain, because the list of your unspent transactions is constructed from all the inputs and outputs. However notice that the explorer I linked to also has an API and (if you request and are granted an API key) the following query will result in giving you all the inputs for that specific address;

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

Refer to the Wiki for usage and other useful CLI commands around this topic.

WARNING: Note when using createrawtransaction you MUST MANUALLY CALCULATE TRANSACTION FEES AND CHANGE, if you fail to do this correctly change will be consumed as fees!!!

So now you can see how its possible (although extremely awkward!) to make and send transactions without a local copy of the blockchain. In terms of how a Ledger works, I suspect they do steps 1/ createrawtransaction and 3/ sendrawtransaction in an un-secure environment, they just use the Ledger itself to do step 2/ signrawtransaction, as this is the only point at which private keys are needed.

Source link

Related posts

Singaporean crypto exchange enters India amid regulatory uncertainty

1 Mins read
Despite India’s unpredictive stance towards crypto regulations, Singaporean crypto exchange Coinstore has allocated a $20 million fund to set up three new…

The Price of the SNAKE (SNK) Game Token Is Growing as We Approach November 30. Wait for a Dump or Buy Now?

2 Mins read
Less than two weeks are left before the start of one of the most anticipated blockchain games of 2021 — Cryptosnake. Now…

Java: bitcoinj; how to download a full block?

1 Mins read
I would like to download a full block using Java and bitcoinj and then parse it to an array to be able…

Leave a Reply

Your email address will not be published. Required fields are marked *