handshake-org / handshake-org/hsd
Coinbase TX JSON should include fees for airdrops, name claims
- Dominant language
- JavaScript
- Stars
- 2.1k
- Forks
- 306
- PR merge metrics
- No merged PRs in 30d
Description
When requesting a TX form the api like `hsd-cli tx 61a61452ca79a030ade7738cbb67c045ed572dc978195aa4d455050c55d75d84` the miner fee is included, but for coinbase transactions it is always `0`:
```
"hash": "61a61452ca79a030ade7738cbb67c045ed572dc978195aa4d455050c55d75d84",
"witnessHash": "3f703780be82ed8ab8107f76c63e70c630da494ee85648d35663272d44a9df62",
"fee": 0,
"rate": 0,
"mtime": 1614091146,
"height": 56188,
"block": "00000000000000014e5165676dd8e36d61b154e925d3965e0bf4ed524c11f1dd",
"time": 1614067124,
"index": 0,
"version": 0,
```
This makes sense because there are no inputs in this transactions coin view:
https://github.com/handshake-org/hsd/blob/master/lib/primitives/tx.js#L852-L862
However, it COULD include the fees paid by whatever airdrops or name claims are merged into the coinbase transaction.
This might also be just more confusing (so it's open for discussion) because the fee as far as `inputValue - outputValue` would be a different number altogether, given that the output would actually include all the TX fees from the entire block.
In JSON terms though my idea does make sense, for example using `jq` we can get all the TX's fees from a block, and add them up:
```
--> hsd-cli block 75939 | jq .txs[].fee
0
71800
29100
22016
22016
22116
22116
22116
90965
22516
22316
22316
22616
21915
21815
21915
21915
21815
21915
21915
21915
21915
21915
21915
21915
21915
100000
100000
7000
100000
100000
--> hsd-cli block 75939 | jq '[.txs[].fee] | add'
1083704
```
However - NOTICE that this value (1.083704) is incorrect!
https://hnsnetwork.com/blocks/75939
https://blockexplorer.com/blocks/75939
The coinbase transaction paid the miner 2001.183704 HNS meaning the miner collected total fees worth 1.183704.
The missing 0.1 HNS was paid by the airdrop merged into the coinbase TX. Just to be totally sure, I decoded the proof from the witness:
```
{
index: 161489,
proof: [
'0834c6914eb67874a220aa2d1698062e1cd0653f94b529256648e7d0ff868387',
'2b40a0e3e5205dd2a76ed522ea12084389896db624f7dcacf6983a89886413a3',
'255a0fd8d33ec9cc0cadb979709a86f97ba25ed55262106e1aacb8a84d526ca2',
'6227cd56b03b4541e4165634db5b6062fa5bb953fc9c8e6fee6f5d101dbdbd2c',
'1468ab18ddc799454f626fa0960c4ed0c764921e7b3df7f21d51961a7803f9cd',
'22d2a1eaaf154ebd1a023badc1937849e031d0347581ac2820f5eb844c4aacd4',
'06fcbef14ec8d6475f067851adf9d45137b2c5b1876308d74fa4f4dd5e30c3b1',
'91bc31d46404b6d43ef32d3a58ab0a73cf6dc4da36bb7bbefd07a10512690c07',
'a9d3df4a10b61ee7dbaa6e47d23811602ef9b2edf1a79cbaab4d9bdfe511e338',
'bb14868d7bf5ffbc6f8048661c05ae6647ff232983bfed79dd8ea4cb325ab8e2',
'4652a97b541ccdfcc6f853c7138b5564fbae554a7bc248a2ef82b60344c4f910',
'3eb788cd2dcd461c1ec3b0dbeba4f963368501a07a29e7e7c53c83e140438133',
'e3e902355904ec9eceddb2b77f37a973876b5d9ad093a607cd406c8c73d11c2f',
'c46d24bc3a8725b6df1ea737aea9a8fdd82720db784515c0a3e8fa39f4458422',
'4bcb24d3de5b07a52e4baee86d9d4379ccf833f17756acf79e22d5f35772c299',
'ab52c38933a44afd538504e4315c1c43b67fac114a8b13a9cf4e0d1243d89153',
'9acc76c864d4f19f711b029b5383114025bfc0222db2243a00d0faaba7086bfc',
'0b6baa2d712c32986f30c2f4cdf7cc35afcebbd6e369f1bab718a1988b51bb81'
],
subindex: 6,
subproof: [
'6552df8dbd4b49b9861c7660cccc59123180db5028d40220cc69652b5a5282f7',
'c2a0c617964bc01f919e9b41073bde97ca4f2575db51e0e3ce9d2bf9df5cd754',
'68c1c9828d2f9767955901b88e81634d5611c8f369106782ea5b49213ce965b0'
],
key: {
type: 'RSA',
n: 'cb790fc492329e61250a2b74503adaf1ec889ec08289befc974a1a23c185f614a594ddd2641ccdb4a85b48bf5b0cc7f28e3c0089fb0ca7c09d498f363503b6650df280e6e4457cfaaf8775244a1bb60bd7aaf4b00ccc3e49fa162ff5bb18f85d204ae48966fdce69a594a2b8306d66fc99e0ecbf7073cab122aef578be4888cdc6a98ebf18155f6a01559af984541bd336d4c0a3af277771fcb411f051b4a22baff9dd658013816e491a8062bab64a76cb6b754abd91ef209d615ad12c13116d25b840670ecd4609f2c9368959ef45a96f3c66bc66f4976d8caa19cf13817af4a571240b3813c6c1d67a3cb917c976c447a1efa0065f5adc4e65d44d88271a29',
e: '010001',
C1: undefined,
point: undefined,
version: undefined,
address: undefined,
value: undefined,
sponsor: undefined,
nonce: '0b79f8d84ea9918138b12bc942561ba51c52e0b44069354c22c8825f84ebec70'
},
version: 0,
address: 'bb38e69c35e31e67882c4d061c5a3339b60e59f3',
fee: 100000,
signature: '95fec86d2bf0a711fc16d3c1b8c0ac030edb84fbf5ec80aa2194d55feb119d941fdbfbe0b64a2ff758dd1fffce93511ed690bb03fdb229afcf0d055d6b8d8fd1d45e8efbd13a427084ab2ff301acb33d35f98cfebc0b4bbf4bebc3cb3b6b760c7a8fb46d5ccd198e589cd38ae87080da294ac93f31076a3f3274050cacd99128a83af20c72eb705367a0b534dab2c6c47deed4be326675547d2e933eccfe389e96bbf57ca485ec68e4ac9cef1b113fb65d14f23cdbf6a25043a61ac6635aeb37a37a34ecd03cc7d32f2925d21ae215126694ad42af2e0f32570b59bacaf1d386a49f7ff3eb79990e6184d9461dce9de29639d43436072e9ee8f67ae04de4b6ba'
}
```
Contributor guide
Assessment
This issue has not been assessed yet.