Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added blockhash argument to getrawtransaction api #39

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions src/cryptoadvance/spectrum/spectrum.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ def testmempoolaccept(self, rawtxs, maxfeerate=0.1):
return [{"allowed": True} for tx in rawtxs]

@rpc
def getrawtransaction(self, txid, verbose=False):
def getrawtransaction(self, txid, verbose=False, blockhash=None):
"""
Get raw transaction data for a given transaction id.
For more information on the Bitcoin RPC call see: https://developer.bitcoin.org/reference/rpc/getrawtransaction.html
Expand All @@ -593,10 +593,16 @@ def getrawtransaction(self, txid, verbose=False):
- This method is using the ElectrumX API call `blockchain.transaction.get` which is documented here:
https://electrumx.readthedocs.io/en/latest/protocol-methods.html#blockchain-transaction-get
"""
if verbose:
return self.sock.call("blockchain.transaction.get", [txid, True])
if blockhash:
if verbose:
return self.sock.call("blockchain.transaction.get", [txid, True, blockhash])
else:
return self.sock.call("blockchain.transaction.get", [txid, False, blockhash])
else:
return self.sock.call("blockchain.transaction.get", [txid, False])
if verbose:
return self.sock.call("blockchain.transaction.get", [txid, True])
else:
return self.sock.call("blockchain.transaction.get", [txid, False])
Comment on lines -596 to +605
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be simplified a lot. If you're unsure how to do that, please ask chatGPT to do it.


@rpc
def sendrawtransaction(self, hexstring, maxfeerate=0.1):
Expand Down