HomePhabricator

[chronik] add electrum method blockchain.transaction.get

Description

[chronik] add electrum method blockchain.transaction.get

Summary:
Return a raw tx (hex string) for a txid, or a tx object (similar to the one returned by the node's gettransaction RPC in verbose mode)

Depends on D17314
Ref T3598

Test Plan:

./src/bitcoind -regtest -chronik -chronikelectrumbind="[::1]:50001" -chronikelectrumbind="127.0.0.1:50001"

In a different terminal, query the regtest genesis coinbase transaction:

$ echo '{"jsonrpc": "2.0", "method": "blockchain.transaction.get", "params": ["4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"], "id": "test"}' | nc 127.0.0.1 50001
$ echo '{"jsonrpc": "2.0", "method": "blockchain.transaction.get", "params": ["4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b", false], "id": "test"}' | nc 127.0.0.1 50001
$ echo '{"jsonrpc": "2.0", "method": "blockchain.transaction.get", "params": {"txid": "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"}, "id": "test"}' | nc 127.0.0.1 50001
$ echo '{"jsonrpc": "2.0", "method": "blockchain.transaction.get", "params": {"txid": "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b", "verbose": false}, "id": "test"}' | nc 127.0.0.1 50001

{"id":"test","jsonrpc":"2.0","result":"01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff4d04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73ffffffff0100f2052a01000000434104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac00000000"}

$ echo '{"jsonrpc": "2.0", "method": "blockchain.transaction.get", "params": ["4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b", true], "id": "test"}' | nc 127.0.0.1 50001
$ echo '{"jsonrpc": "2.0", "method": "blockchain.transaction.get", "params": {"txid": "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b", "verbose": true}, "id": "test"}' | nc 127.0.0.1 50001
{"id":"test","jsonrpc":"2.0","result":{"blockhash":"06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f","blocktime":1296688602,"confirmations":2,"hash":"4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b","hex":"01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff4d04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73ffffffff0100f2052a01000000434104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac00000000","time":0}}

ninja all check-all

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Subscribers: Fabien

Maniphest Tasks: T3598

Differential Revision: https://reviews.bitcoinabc.org/D17323

Details

Provenance
PiRKAuthored on Mon, Dec 9, 15:14
PiRKPushed on Mon, Dec 16, 15:32
Reviewer
Restricted Project
Differential Revision
D17323: [chronik] add electrum method blockchain.transaction.get
Parents
rABCcedd98bd44e8: [chronik] add a test for the new JSON RPC interface
Branches
Unknown
Tags
Unknown
Tasks
Restricted Maniphest Task