From f129b45e7270d2054d46cb3b5d71917ef7eb4c90 Mon Sep 17 00:00:00 2001 From: PaarthAgarwal Date: Wed, 25 Jan 2023 03:57:41 +0530 Subject: [PATCH 1/2] added blockhash argument to getrawtransaction api --- src/cryptoadvance/spectrum/spectrum.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cryptoadvance/spectrum/spectrum.py b/src/cryptoadvance/spectrum/spectrum.py index 999f94a..b7f9442 100644 --- a/src/cryptoadvance/spectrum/spectrum.py +++ b/src/cryptoadvance/spectrum/spectrum.py @@ -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, blockhash, txid, verbose=False): """ 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 From 5d37dfd1367a69ccc6e717117d7742804f2991c6 Mon Sep 17 00:00:00 2001 From: PaarthAgarwal Date: Tue, 31 Jan 2023 19:09:23 +0530 Subject: [PATCH 2/2] update --- src/cryptoadvance/spectrum/spectrum.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/cryptoadvance/spectrum/spectrum.py b/src/cryptoadvance/spectrum/spectrum.py index b7f9442..8311c17 100644 --- a/src/cryptoadvance/spectrum/spectrum.py +++ b/src/cryptoadvance/spectrum/spectrum.py @@ -577,7 +577,7 @@ def testmempoolaccept(self, rawtxs, maxfeerate=0.1): return [{"allowed": True} for tx in rawtxs] @rpc - def getrawtransaction(self, blockhash, 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 @@ -593,10 +593,16 @@ def getrawtransaction(self, blockhash, 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]) @rpc def sendrawtransaction(self, hexstring, maxfeerate=0.1):