I want to use sendfrom
bitcoind rpc method to transfer funds from my account to some address. Right after calling it, I want to get all the data about this transaction using gettransaction
or listsinceblock
. Does bitcoind's wallet system process a new transaction before or after responding with a "txid" to sendfrom
? Is it safe to call sendfrom
and gettransaction
right after that from my python code for example?
1 Answer
Yes. It's save.
The current transaction submitting logic (CommitTransaction
) do report the transaction ID after adding the tx to the local database and to the mempool.
On top, it holds the cs_main
and the cs_wallet
lock which makes sure not other thread can manipulate the relevant data-structured during the time of AddToWallet
and AcceptToMempool
.
https://github.com/bitcoin/bitcoin/blob/master/src/wallet/wallet.cpp#L2557
This means, when you call a send*
RPC command, you will get response (the txid) after the transaction was submitted to the mempool and added to your local wallet database.
Immediately calling gettransaction
is therefore save.