Created
April 8, 2020 21:45
-
-
Save justinmoon/1c50eb24c5ef5874adab6fc38244409b to your computer and use it in GitHub Desktop.
Bitcoin Core RPC Transactions (from slack discussion)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Remember how we've seen some weirdness in the output of listtransactions ? | |
| If you make one transactions there will be multiple entries in our transaction list? | |
| That's because each separate input / output gets a different entry in listtransactions | |
| This is one transaction: | |
| { | |
| "involvesWatchonly": true, | |
| "address": "bcrt1qg9xjv8raj57pynq39hmgswruectr6qzdmeppvtgnnrwjvs4z9hws42jalj", | |
| "category": "receive", | |
| "amount": 0.89996360, | |
| "label": "", | |
| "vout": 0, | |
| "confirmations": 20, | |
| "blockhash": "3d309db62d1904b137d9f78bbf8726e48d06a919971d12628dd0cc7cb3fb85c9", | |
| "blockindex": 2, | |
| "blocktime": 1584066822, | |
| "txid": "2bb9cbc2fdbe6c0522944829d1356457de344c1e407f74c99b50dfc36cf708c0", | |
| "walletconflicts": [ | |
| ], | |
| "time": 1583994600, | |
| "timereceived": 1583994600, | |
| "bip125-replaceable": "no" | |
| }, | |
| { | |
| "involvesWatchonly": true, | |
| "address": "2Mzc1rETGQ4FA8BJ9SXfFcrkzoZwyxvCdeZ", | |
| "category": "send", | |
| "amount": -0.10000000, | |
| "vout": 1, | |
| "fee": -0.00003640, | |
| "confirmations": 20, | |
| "blockhash": "3d309db62d1904b137d9f78bbf8726e48d06a919971d12628dd0cc7cb3fb85c9", | |
| "blockindex": 2, | |
| "blocktime": 1584066822, | |
| "txid": "2bb9cbc2fdbe6c0522944829d1356457de344c1e407f74c99b50dfc36cf708c0", | |
| "walletconflicts": [ | |
| ], | |
| "time": 1583994600, | |
| "timereceived": 1583994600, | |
| "bip125-replaceable": "no", | |
| "abandoned": false | |
| }, | |
| { | |
| "involvesWatchonly": true, | |
| "address": "bcrt1qg9xjv8raj57pynq39hmgswruectr6qzdmeppvtgnnrwjvs4z9hws42jalj", | |
| "category": "send", | |
| "amount": -0.89996360, | |
| "label": "", | |
| "vout": 0, | |
| "fee": -0.00003640, | |
| "confirmations": 20, | |
| "blockhash": "3d309db62d1904b137d9f78bbf8726e48d06a919971d12628dd0cc7cb3fb85c9", | |
| "blockindex": 2, | |
| "blocktime": 1584066822, | |
| "txid": "2bb9cbc2fdbe6c0522944829d1356457de344c1e407f74c99b50dfc36cf708c0", | |
| "walletconflicts": [ | |
| ], | |
| "time": 1583994600, | |
| "timereceived": 1583994600, | |
| "bip125-replaceable": "no", | |
| "abandoned": false | |
| } | |
| See how txid is the same for each entry | |
| First entry is has category of receive, the second two are send (edited) | |
| - change output credit (positive amount) | |
| - output being sent debit (negative amount) | |
| - change output debit (negative amount, equal to first entry) | |
| (edited) | |
| This is what gettransaction returns: | |
| { | |
| "amount": -0.10000000, | |
| "fee": -0.00003640, | |
| "confirmations": 20, | |
| "blockhash": "3d309db62d1904b137d9f78bbf8726e48d06a919971d12628dd0cc7cb3fb85c9", | |
| "blockindex": 2, | |
| "blocktime": 1584066822, | |
| "txid": "2bb9cbc2fdbe6c0522944829d1356457de344c1e407f74c99b50dfc36cf708c0", | |
| "walletconflicts": [ | |
| ], | |
| "time": 1583994600, | |
| "timereceived": 1583994600, | |
| "bip125-replaceable": "no", | |
| "details": [ | |
| { | |
| "involvesWatchonly": true, | |
| "address": "bcrt1qg9xjv8raj57pynq39hmgswruectr6qzdmeppvtgnnrwjvs4z9hws42jalj", | |
| "category": "send", | |
| "amount": -0.89996360, | |
| "label": "", | |
| "vout": 0, | |
| "fee": -0.00003640, | |
| "abandoned": false | |
| }, | |
| { | |
| "involvesWatchonly": true, | |
| "address": "2Mzc1rETGQ4FA8BJ9SXfFcrkzoZwyxvCdeZ", | |
| "category": "send", | |
| "amount": -0.10000000, | |
| "vout": 1, | |
| "fee": -0.00003640, | |
| "abandoned": false | |
| }, | |
| { | |
| "involvesWatchonly": true, | |
| "address": "bcrt1qg9xjv8raj57pynq39hmgswruectr6qzdmeppvtgnnrwjvs4z9hws42jalj", | |
| "category": "receive", | |
| "amount": 0.89996360, | |
| "label": "", | |
| "vout": 0 | |
| } | |
| ], | |
| "hex": "020000000001010f0f35f262c63352721256a770dfb95f7b08f56efa5603d259a31e7f6001b9a00000000000feffffff02483c5d0500000000220020414d261c7d953c124c112df688387cce163d004dde42162d1398dd2642a22ddd809698000000000017a91450b77b930f4345f9fdaa41f19a65f52c673cb491870400483045022100a294205e0ddcd68a5a0d5bcbe179e0a5c2a1eb5f630ae30b748bc83fabdea51c02204f876ad1fe770802c53715d9635d4c7c2ca578bc88ae49ef67fb692b089dc6f00147304402203a458977140e2cc092d2258d6597b5d5ff5dd606f3ac3572cd34a33c11c3477d022070194fe7462440ec3e82d3793131c434e2311ad24c6475d0be4b9b333b069f6a014752210313d89943978d0887ad76bf589c9ea705ee44db04761ddaa5bc856313e586f6d9210324c84a776c4fb2483a9592685d160fb5b9be93559d4688ed2554f2170ca4302752ae00000000" | |
| } | |
| That's much more straightforward to deal with. Do you think we should just save this? | |
| One shitty thing is that there doesn't seem to be a good way to look up the amounts of the transaction inputs | |
| Remember -- transaction inputs in a bitcoin transaction don't include the amount information | |
| Only the outputs do | |
| Bitcoin Core has a gettxout command -- which would allow us to look up the amounts of the transaction inputs (they're just the amount of the UTXO they're spending). But the problem is that this only works for unspent outputs. So if a couple sequential transactions happen without junction noticing -- we would only be able to deduce the input amounts for the last one in the chain because `gettxout` doesn't work for spent transaction outputs. | |
| But it seems the Bitcoin Core doesn't throw away references to the ancestor transactions themselves. So we can use gettransaction to look up the hex of that previous transaction and find the amount ... | |
| But this would only allow us to infer input amounts of the transactions we send, not the transactions we receive | |
| It seems that the inability to infer the input amounts of the transactions we receive is a fundamental limitation of Bitcoin RPC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment