From 42dc54325211e39afdc464833fe03cd6ee0481a7 Mon Sep 17 00:00:00 2001 From: JamieMcNaught Date: Tue, 7 Aug 2018 13:50:57 +0000 Subject: [PATCH 1/3] Add the parameter includewatchonly to gettransaction for the additional parameter added in Bitcoin Core 0.10.0 --- bitcoin/rpc.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bitcoin/rpc.py b/bitcoin/rpc.py index f2c5d4a5..92c3dcfd 100644 --- a/bitcoin/rpc.py +++ b/bitcoin/rpc.py @@ -562,7 +562,7 @@ def getreceivedbyaddress(self, addr, minconf=1): r = self._call('getreceivedbyaddress', str(addr), minconf) return int(r * COIN) - def gettransaction(self, txid): + def gettransaction(self, txid, includewatchonly=False): """Get detailed information about in-wallet transaction txid Raises IndexError if transaction not found in the wallet. @@ -570,7 +570,7 @@ def gettransaction(self, txid): FIXME: Returned data types are not yet converted. """ try: - r = self._call('gettransaction', b2lx(txid)) + r = self._call('gettransaction', b2lx(txid), includewatchonly) except InvalidAddressOrKeyError as ex: raise IndexError('%s.getrawtransaction(): %s (%d)' % (self.__class__.__name__, ex.error['message'], ex.error['code'])) From 873bdae58d7266555922ffd5aaab66e47ca9af46 Mon Sep 17 00:00:00 2001 From: Jamie McNaught Date: Fri, 12 Oct 2018 15:26:18 +0000 Subject: [PATCH 2/3] Add very basic support for getblockchaininfo. --- bitcoin/rpc.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bitcoin/rpc.py b/bitcoin/rpc.py index 92c3dcfd..0a5f83d9 100644 --- a/bitcoin/rpc.py +++ b/bitcoin/rpc.py @@ -562,6 +562,9 @@ def getreceivedbyaddress(self, addr, minconf=1): r = self._call('getreceivedbyaddress', str(addr), minconf) return int(r * COIN) + def getblockchaininfo(self): + return self._call('getblockchaininfo') + def gettransaction(self, txid, includewatchonly=False): """Get detailed information about in-wallet transaction txid From 6f7cf44b6c386a6c846bfa7b4d565f5b7aa631d4 Mon Sep 17 00:00:00 2001 From: Dan Bolser Date: Tue, 11 Dec 2018 14:19:53 +0000 Subject: [PATCH 3/3] making compatible with DASH TODO: this can be improved along the lines described here: https://github.com/petertodd/python-bitcoinlib/pull/196 --- bitcoin/__init__.py | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/bitcoin/__init__.py b/bitcoin/__init__.py index d52d9145..1c0d6ee3 100644 --- a/bitcoin/__init__.py +++ b/bitcoin/__init__.py @@ -53,6 +53,16 @@ class RegTestParams(bitcoin.core.CoreRegTestParams): 'SCRIPT_ADDR':196, 'SECRET_KEY' :239} +## Crudely making this multi-coin aware! +class RegTestDashParams(bitcoin.core.CoreRegTestParams): + #MESSAGE_START = b'\xfa\xbf\xb5\xda' + #DEFAULT_PORT = 18444 + RPC_PORT = 19998 + #DNS_SEEDS = () + BASE58_PREFIXES = {'PUBKEY_ADDR':140, + 'SCRIPT_ADDR':19, + 'SECRET_KEY' :239} + """Master global setting for what chain params we're using. However, don't set this directly, use SelectParams() instead so as to set the @@ -64,17 +74,27 @@ class RegTestParams(bitcoin.core.CoreRegTestParams): def SelectParams(name): """Select the chain parameters to use - name is one of 'mainnet', 'testnet', or 'regtest' + name is one of 'mainnet', 'testnet', 'regtest' or 'regtest-DASH' Default chain is 'mainnet' """ global params - bitcoin.core._SelectCoreParams(name) + + + ## We are abusing 'name' to mean both network+COIN. There is + ## probably a much better way to do this! + core_name = name + if name == 'regtest-DASH': + core_name = 'regtest' + + bitcoin.core._SelectCoreParams(core_name) if name == 'mainnet': params = bitcoin.core.coreparams = MainParams() elif name == 'testnet': params = bitcoin.core.coreparams = TestNetParams() elif name == 'regtest': params = bitcoin.core.coreparams = RegTestParams() + elif name == 'regtest-DASH': + params = bitcoin.core.coreparams = RegTestDashParams() else: raise ValueError('Unknown chain %r' % name)