2

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 1

2

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.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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