3

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?

3

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.