node rpc: scantxoutset
This is a simple implementation of scantxoutset. This RPC returns a list of the outputs that match the output descriptor.
It currently works with the output descriptor types:
wpkwshaddropreturn
Some descriptor types defined in https://github.com/bitcoin/bitcoin/blob/master/doc/descriptors.md do not make sense for Handshake. It should be possible to add multi and sortedmulti with the current implementation.
The Descriptor class should be reimplemented and more thoroughly tested before this should be considered ready for a merge. I think a regex based approach for parsing the descriptor would be more flexible. The xpub stuff would be a nice to have.
Example usage:
hsd-rpc --timeout 100000 scantxoutset 'addr(hs1qnryzj7n8awq7cd398q5t2cs6vqd6yv525y2c4l)'
Pull Request Test Coverage Report for Build 205920748
- 53 of 79 (67.09%) changed or added relevant lines in 4 files are covered.
- 1 unchanged line in 1 file lost coverage.
- Overall coverage increased (+0.009%) to 59.004%
| Changes Missing Coverage | Covered Lines | Changed/Added Lines | % |
|---|---|---|---|
| lib/blockchain/chain.js | 0 | 1 | 0.0% |
| lib/utils/descriptor.js | 51 | 55 | 92.73% |
| lib/blockchain/chaindb.js | 0 | 9 | 0.0% |
| lib/node/rpc.js | 2 | 14 | 14.29% |
| <!-- | Total: | 53 | 79 |
| Files with Coverage Reduction | New Missed Lines | % |
|---|---|---|
| lib/script/script.js | 1 | 63.07% |
| <!-- | Total: | 1 |
| Totals | |
|---|---|
| Change from base Build 204174244: | 0.009% |
| Covered Lines: | 19339 |
| Relevant Lines: | 30485 |
💛 - Coveralls
Pull Request Test Coverage Report for Build 205920748
- 53 of 79 (67.09%) changed or added relevant lines in 4 files are covered.
- 3 unchanged lines in 1 file lost coverage.
- Overall coverage increased (+0.009%) to 59.004%
| Changes Missing Coverage | Covered Lines | Changed/Added Lines | % |
|---|---|---|---|
| lib/blockchain/chain.js | 0 | 1 | 0.0% |
| lib/utils/descriptor.js | 51 | 55 | 92.73% |
| lib/blockchain/chaindb.js | 0 | 9 | 0.0% |
| lib/node/rpc.js | 2 | 14 | 14.29% |
| <!-- | Total: | 53 | 79 |
| Files with Coverage Reduction | New Missed Lines | % |
|---|---|---|
| lib/net/pool.js | 3 | 32.49% |
| <!-- | Total: | 3 |
| Totals | |
|---|---|
| Change from base Build 204174244: | 0.009% |
| Covered Lines: | 19337 |
| Relevant Lines: | 30485 |
💛 - Coveralls
@pinheadmz bought up a good point, we could rename opreturn to nulldata. I'm not super opinionated on this. opreturn is not part of the Bitcoin spec, you would have to use hex to get opreturn outputs on Bitcoin. I left out hex since there are no bare scripts, but now that I think about it, hex in the case of handshake could be version || data. Then you could use it to get opreturn outputs when the version is 31. The opreturn descriptor can accept ascii or hex, depending on if there is a 0x prefix.