bitcoin/bitcoin — pull request #3671 by gavinandresen (2014-02-14 01:29:31+00:00)
Title: Txn conflicts

This builds on #3656 and #3669.

It adds a "walletconflicts" array to wallet transaction JSON output, identifying transactions that share the same normalized transaction ID (that have exactly the same inputs and outputs).

I need to sleep on the last commit, I'm afraid it might open up services to a double-spend attack if a blockchain re-org is done.

Example output from the txnmall.sh regression test, spending 1 BTC from account "foo", then spending 2 BTC of the change from that transaction and spending it from account "bar". After a mutant of the "foo" transaction is then mined listtransactions reports:

```
{
"account" : "foo",
"address" : "mzkQgu25PwDiizVe386isePJtcvcuUfe92",
"category" : "conflicted",
"amount" : -1.00000000,
"fee" : 0.00000000,
"confirmations" : -1,
"txid" : "37ae388f1d2a4df39a1eae251bf8ee43000691284d6a28077154b9648ec66318",
"normtxid" : "fe7355741ed22c056469e22797f15cc31916e0026828c6daf3110ff76bb81d1e",
"walletconflicts" : [
"9c5f1b72f18c28b7e0e501c7125329333d0baeb4def08c565a1957031b9d3bbb"
],
"time" : 1392336916,
"timereceived" : 1392336916
},
{
"account" : "foo",
"address" : "mzkQgu25PwDiizVe386isePJtcvcuUfe92",
"category" : "send",
"amount" : -1.00000000,
"fee" : 0.00000000,
"confirmations" : 1,
"blockhash" : "0000b1e01161164fe2622491b5748ecfcd69a4305842815f17d0f1c4888d6dc6",
"blockindex" : 1,
"blocktime" : 1392336917,
"txid" : "9c5f1b72f18c28b7e0e501c7125329333d0baeb4def08c565a1957031b9d3bbb",
"normtxid" : "fe7355741ed22c056469e22797f15cc31916e0026828c6daf3110ff76bb81d1e",
"walletconflicts" : [
"37ae388f1d2a4df39a1eae251bf8ee43000691284d6a28077154b9648ec66318"
],
"time" : 1392336916,
"timereceived" : 1392336917
},
{
"account" : "bar",
"address" : "mzkQgu25PwDiizVe386isePJtcvcuUfe92",
"category" : "conflicted",
"amount" : -2.00000000,
"fee" : 0.00000000,
"confirmations" : -1,
"txid" : "a41295cf488bb3baa654522658e6847cfd385737f82a3447dc1cddb77d7dfd7c",
"normtxid" : "bfcb414d3a3372fb22008e56a530585f4d50644de5c6fc0c6ad2c0382f9c945b",
"walletconflicts" : [
],
"time" : 1392336917,
"timereceived" : 1392336917
}
```