Using bitcoins JSON RPC, how can I confirm a transaction I published?

8

2

I have created, signed and sent a raw transaction via bitcoind RPC. Now I want to wait for it to have n confirmations.

Considering transaction malleability, I can't just check the "confirmations" field returned by gettransaction, because the transaction with that particular txid may never be accepted, in case an equivalent transaction with some other txid was accepted instead.

So, what is the canonical way, using bitcoind JSON-RPC, to check if an equivalent transaction was accepted in place of mine? What calls are better suited for the task?

lvella

Posted 2015-02-16T19:14:11.880

Reputation: 246

Answers

1

You can use the listtransactions JSON-RPC call to get the complete list of transactions that have to do with your addresses. This includes both sends and receives. You can filter for the transaction you're looking for by the category (should be "send"), address, amount and time. The txid and confirmations in this RPC call should be what's actually included in the blockchain and can be relied upon.

For reference, here's what the RPC call looks like:

[
{   
    "account" : "",
    "address" : "1ENnzep2ivWYqXjAodTueiZscT6kunAyYs",
    "category" : "send",
    "amount" : -0.00040000,
    "fee" : -0.00010000,
    "confirmations" : 34055,
    "blockhash" : "000000000000000019313300fa20943b3974a97c1da2de6de13ea1281f77097f",
    "blockindex" : 414,
    "blocktime" : 1404861981,
    "txid" : "8a1f0f07fb397b2aa0e77995723f2dac9aee7df63a6f05a7db7d168d62a60f94",
    "walletconflicts" : [
    ],
    "time" : 1404861981,
    "timereceived" : 1412296394
}
]

Jimmy Song

Posted 2015-02-16T19:14:11.880

Reputation: 7 067

So it is organized by output addresses, but what this fee means? If my transaction has 2 output addresses, the entries returned by listtransactions for both will contain the same fee?lvella 2015-02-17T16:54:27.377

The fee will be the same, yes.Jimmy Song 2015-02-17T21:42:54.067

1I am somewhat unsatisfied with this answer, because the answer for listtransactions will become increasingly large with my wallet usage. That won't be practical, if checking outgoing transactions is a routine operation.lvella 2015-03-28T06:10:33.177

wouldn't an answer be that you get a negative confirmation amount if a malleability tx got confirmed instead?tobi 2017-04-03T09:35:27.400