cculianu / Fulcrum

A fast & nimble SPV Server for BCH, BTC, and LTC
Other
331 stars 76 forks source link

Add the `query` subcommand to the `FulcrumAdmin` script. #166

Closed cculianu closed 1 year ago

cculianu commented 1 year ago

This closes #165. It allows the user to use a new query verb with FulcrumAdmin, similar to how it works on elextrumx_rpc.

Usage:

calin@Box ~/Fulcrum/ $ ./FulcrumAdmin query -h
usage: FulcrumAdmin query [-h] [-l [limit]] address [address ...]

positional arguments:
  address     Address or hex-encoded scriptPubKey to query

optional arguments:
  -h, --help  show this help message and exit
  -l [limit]  UTXO and history output limit

Example run with a mix of legacy, cashaddr, and scriptPubKey hex as input:

calin@Box ~/Fulcrum/ $ ./FulcrumAdmin -p 9000 query -l 5 mgSyDui1gE4f7NKs1CcrnhpYt4fuN6HSZU qr7k35kg0uxuz7v729jh6vh0hx4rvlgkrc8pq96ndx bchtest:qr4gww42l0wh5lr56ulwz96wgtmzpv9p3sz4wxrydq bchtest:qq3pfyjzgjhske7jlfpslypq8skys0d4zgc70ahmcq 76a9147dbdcf6c874cba69392bd319a285ac100e7fc15f88ac
Address: bchtest:qq9rw090p2eu9drv6ptztwx4ghpftwfa0gyqvlvx2q
History #0: height 30 tx_hash e69c9b4b32a4b0a95edbc3f5f907f143a74332772ed46915d6fd7760d26cf54a
History #1: height 31 tx_hash ccd41a9d358b224413c5a8d835a83e75e076d26ba0681b815ef0fd6a2d860c4e
History #2: height 32 tx_hash 8a43966006b97c6b2cbc914384f371e89c15d26031f0f36e883df62b7b4e0c28
History #3: height 33 tx_hash a781d7b3ff23e63dfbfff9997c3d6d0058777b6d8b798d05fa3d541235782a2b
History #4: height 34 tx_hash 9feb6f0d1213ecf360ed2b535e7e4d2e469a3e53e538e7032baf57ea69e228b5
UTXO #1: tx_hash 52e5cbcb7ff94f0832a7c731506b953eebcfc049e9680d563075acdcbcf386d2 tx_pos 0 height 55,885 value 5,000,000,000
UTXO #2: tx_hash 6eb228f0838d3d859e104a5051e6b7f38b1c2f028fd2d74e8b1e096e67ba424a tx_pos 0 height 55,886 value 5,000,000,000
UTXO #3: tx_hash b34d53e71cf1b42dbb8e5bb7496b481f540447a05c88b20f2406bfa2d03d65f3 tx_pos 0 height 55,887 value 5,000,000,000
UTXO #4: tx_hash 9897fcbaf542ee151f18348fc9c2a7602438dbb47646c0ff4944c5dc17dbfd23 tx_pos 0 height 55,888 value 5,000,000,000
UTXO #5: tx_hash 1fa7e514e8c0c52caffa8d955d936cadd5d5957c0c136d590e599b5512b539f7 tx_pos 0 height 55,889 value 5,000,000,000
Balance: 750.7671 tBCH
Address: bchtest:qr7k35kg0uxuz7v729jh6vh0hx4rvlgkrc8pq96ndx
History #0: height 108,234 tx_hash 9d4842ede0db89a36504fa8a100e6430362c36b84ce57a23f92e6299bb4cfc53
History #1: height 109,245 tx_hash 80101f17039368630cf7dc2d1cda1c5d52aac4fbe2dd37f0a776ef92c23e3993
History #2: height 140,065 tx_hash 1ca29a27d955666e3dc41fdf9f2fecb99630caeb2440001076cbd18577a43174
UTXO #1: tx_hash 1ca29a27d955666e3dc41fdf9f2fecb99630caeb2440001076cbd18577a43174 tx_pos 0 height 140,065 value 8,260,688,715,176
Balance: 82,606.88715176 tBCH
Address: bchtest:qr4gww42l0wh5lr56ulwz96wgtmzpv9p3sz4wxrydq
History #0: height 130,356 tx_hash 60a8885ad94471166b9333f36acdcb404babca883db439b34329b506c328f519
UTXO #1: tx_hash 60a8885ad94471166b9333f36acdcb404babca883db439b34329b506c328f519 tx_pos 1 height 130,356 value 4,899,999,500
Balance: 48.999995 tBCH
Address: bchtest:qq3pfyjzgjhske7jlfpslypq8skys0d4zgc70ahmcq
No history found
No UTXOs found
Balance: 0.0 tBCH
Script: 76a9147dbdcf6c874cba69392bd319a285ac100e7fc15f88ac
History #0: height 130,789 tx_hash dd533368cbf56582374b5b5e33b0160287df6a3c9e84e744a85ce9cb6624844f
History #1: height 142,537 tx_hash 66c6334805d1e1988ee7e43ab634bb6095169ead659645d4fccd851261c2faa9
UTXO #1: tx_hash 66c6334805d1e1988ee7e43ab634bb6095169ead659645d4fccd851261c2faa9 tx_pos 0 height 142,537 value 59,998,715
Balance: 0.59998715 tBCH