Skip to content

Commit

Permalink
Drop support for pre-0.17 Bitcoin Core
Browse files Browse the repository at this point in the history
  • Loading branch information
kristapsk committed Dec 25, 2020
1 parent 17c93ee commit 81982c7
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 45 deletions.
4 changes: 3 additions & 1 deletion docs/INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,11 @@ Before starting, note you need either (a) Bitcoin Core installed on Windows or (
If (a), then note the following two points:
##### Installing Bitcoin Core
If you haven't done so yet, install Bitcoin Core as described [here](https://bitcoin.org/en/full-node#windows-10). After starting it for the first time, it will start the Initial Block Download. JoinMarket cannot be used until this is finished. More information on that can be found [here](https://bitcoin.org/en/full-node#initial-block-downloadibd).
If you haven't done so yet, install Bitcoin Core, version 0.18 or newer, as described [here](https://bitcoin.org/en/full-node#windows-10). After starting it for the first time, it will start the Initial Block Download. JoinMarket cannot be used until this is finished. More information on that can be found [here](https://bitcoin.org/en/full-node#initial-block-downloadibd).
##### Configuring Bitcoin Core
Bitcoin Core needs to be configured to allow JoinMarket to connect to it. From the `Settings` menu choose `Options` and click `Open Configuration File`. Add `server=1`, save and close the file. After that restart Bitcoin Core.
There are currently two choices for installing on Windows; one, directly installing on Windows, requiring the manual addition of a libsodium dependency, or, two, using Ubuntu via the WSL mechanism (which may require additional setup to make the Qt GUI work).
Expand Down
2 changes: 1 addition & 1 deletion docs/PAYJOIN.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ So just skip those sections if you already know it.

### Preparatory step: configuring for Bitcoin Core.

Joinmarket currently requires a Bitcoin Core full node, although it can be pruned.
Joinmarket currently requires a Bitcoin Core full node, version 0.18 or newer, although it can be pruned.

First thing to do: in `scripts/`, run:

Expand Down
2 changes: 1 addition & 1 deletion docs/TESTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
### Test instructions (for developers):

Work in your `jmvenv` virtualenv as for all Joinmarket work. Make sure to have [bitcoind](https://bitcoin.org/en/full-node) 0.17 or newer installed. Also need miniircd installed to the root (i.e. in your `joinmarket-clientserver` directory):
Work in your `jmvenv` virtualenv as for all Joinmarket work. Make sure to have [bitcoind](https://bitcoin.org/en/full-node) 0.18 or newer installed. Also need miniircd installed to the root (i.e. in your `joinmarket-clientserver` directory):

(jmvenv)$ cd /path/to/joinmarket-clientserver
(jmvenv)$ git clone https://github.com/Joinmarket-Org/miniircd
Expand Down
61 changes: 19 additions & 42 deletions jmclient/jmclient/blockchaininterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,7 @@ def __init__(self, jsonRpc, network):
raise Exception('wrong network configured')

def is_address_imported(self, addr):
try:
return self._rpc('getaccount', [addr]) != ''
except JsonRpcError:
return len(self._rpc('getaddressinfo', [addr])['labels']) > 0
return len(self._rpc('getaddressinfo', [addr])['labels']) > 0

def get_block(self, blockheight):
"""Returns full serialized block at a given height.
Expand Down Expand Up @@ -232,11 +229,7 @@ def _rpc(self, method, args):
return res

def is_address_labeled(self, utxo, walletname):
# Bitcoin Core before 0.17 used accounts, new versions has labels
return (
("label" in utxo and utxo["label"] == walletname) or
("account" in utxo and utxo["account"] == walletname)
)
return ("label" in utxo and utxo["label"] == walletname)

def import_addresses(self, addr_list, wallet_name, restart_cb=None):
"""Imports addresses in a batch during initial sync.
Expand Down Expand Up @@ -275,15 +268,11 @@ def import_addresses(self, addr_list, wallet_name, restart_cb=None):
sys.exit(EXIT_FAILURE)

def import_addresses_if_needed(self, addresses, wallet_name):
try:
imported_addresses = set(self._rpc('getaddressesbyaccount',
[wallet_name]))
except JsonRpcError:
if wallet_name in self._rpc('listlabels', []):
imported_addresses = set(self._rpc('getaddressesbylabel',
[wallet_name]).keys())
else:
imported_addresses = set()
if wallet_name in self._rpc('listlabels', []):
imported_addresses = set(self._rpc('getaddressesbylabel',
[wallet_name]).keys())
else:
imported_addresses = set()
import_needed = not addresses.issubset(imported_addresses)
if import_needed:
self.import_addresses(addresses - imported_addresses, wallet_name)
Expand Down Expand Up @@ -327,25 +316,21 @@ def get_transaction(self, txid):
watch-only wallets.
"""
htxid = bintohex(txid)
#changed syntax in 0.14.0; allow both syntaxes
try:
res = self._rpc("gettransaction", [htxid, True])
except JsonRpcError as e:
#This should never happen (gettransaction is a wallet rpc).
log.warn("Failed gettransaction call; JsonRpcError: " + repr(e))
return None
except Exception as e:
try:
res = self._rpc("gettransaction", [htxid, 1])
except JsonRpcError as e:
#This should never happen (gettransaction is a wallet rpc).
log.warn("Failed gettransaction call; JsonRpcError: " + repr(e))
return None
except Exception as e:
log.warn("Failed gettransaction call; unexpected error:")
log.warn(str(e))
return None
log.warn("Failed gettransaction call; unexpected error:")
log.warn(str(e))
return None
if res is None:
# happens in case of rpc connection failure:
return None
if "confirmations" not in res:
log.warning("Malformed gettx result: " + str(res))
log.warning("Malformed gettransaction result: " + str(res))
return None
return res

Expand Down Expand Up @@ -479,11 +464,7 @@ def get_best_block_median_time(self):
return self._rpc('getblockchaininfo', [])['mediantime']

def _get_block_header_data(self, blockhash, key):
try:
# works with pruning enabled, but only after v0.12
return self._rpc('getblockheader', [blockhash])[key]
except JsonRpcError:
return self._rpc('getblock', [blockhash])[key]
return self._rpc('getblockheader', [blockhash])[key]

def get_block_height(self, blockhash):
return self._get_block_header_data(blockhash, 'height')
Expand Down Expand Up @@ -594,13 +575,9 @@ def import_addresses_if_needed(self, addresses, wallet_name):
addr_list = ["addr(" + a + ")" for a in addresses]
log.debug("Starting scan of UTXO set")
st = time.time()
try:
self._rpc("scantxoutset", ["abort", []])
self.scan_result = self._rpc("scantxoutset", ["start",
addr_list])
except JsonRpcError as e:
raise RuntimeError("Bitcoin Core 0.17.0 or higher required "
+ "for no-history sync (" + repr(e) + ")")
self._rpc("scantxoutset", ["abort", []])
self.scan_result = self._rpc("scantxoutset", ["start",
addr_list])
et = time.time()
log.debug("UTXO set scan took " + str(et - st) + "sec")
elif self.import_addresses_call_count > 4:
Expand Down

0 comments on commit 81982c7

Please sign in to comment.