hsd icon indicating copy to clipboard operation
hsd copied to clipboard

node rpc: scantxoutset

Open tynes opened this issue 5 years ago • 3 comments

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:

  • wpk
  • wsh
  • addr
  • opreturn

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)'

tynes avatar Aug 12 '20 17:08 tynes

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 Coverage Status
Change from base Build 204174244: 0.009%
Covered Lines: 19339
Relevant Lines: 30485

💛 - Coveralls

coveralls avatar Aug 12 '20 17:08 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 Coverage Status
Change from base Build 204174244: 0.009%
Covered Lines: 19337
Relevant Lines: 30485

💛 - Coveralls

coveralls avatar Aug 12 '20 17:08 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.

tynes avatar Aug 12 '20 20:08 tynes