Search code examples
bitcoinbitcoind

bitcoin core, How label based wallet api works?


We can assign a label to an address either using getnewaddress or setlabel.

getnewaddress ( "label" "address_type" )
setlabel "address" "label"

For sending bitcoins we have two functions sendtoaddress and setndmany, both don't concern themselves with labels.

sendtoaddress "address" amount ( "comment" "comment_to" subtractfeefromamount replaceable conf_target "estimate_mode" )

sendmany "" {"address":amount} ( minconf "comment" ["address",...] replaceable conf_target "estimate_mode" )

and we have getreceivedbylabel and getreceivedbyaddress:

getreceivedbylabel "label" ( minconf )
getreceivedbyaddress "address" ( minconf )

My educated guess is that send* functions will debit the amount from any address in wallet they see fit, and credit the return back to any address they want.

Is that correct? and how does that impact getreceivedbylabel & getreceivedbyaddress?


Solution

  • With sendtoaddress and sendmay you can try sending bitcoin to provided address(es). But propagation of transaction may take some time based on exchange network and fee you suggest. So you need a mechanism for checking current state of your transaction and here is why you should use getreceivedbylabel or getreceivedbyaddress