Skip to content
This repository has been archived by the owner on May 13, 2022. It is now read-only.

Commit

Permalink
Merge pull request #367 from adlai/rbf-ftw
Browse files Browse the repository at this point in the history
add confirmation-spendability knob for bitcoind-rpc
  • Loading branch information
adlai committed Dec 21, 2015
2 parents 089c1a7 + 3a7966f commit 74a19be
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
15 changes: 10 additions & 5 deletions joinmarket/blockchaininterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import BaseHTTPServer
import abc
import ast
import json
import os
import pprint
Expand Down Expand Up @@ -613,19 +614,23 @@ def sync_unspent(self, wallet):
st = time.time()
wallet_name = self.get_wallet_name(wallet)
wallet.unspent = {}
unspent_list = self.rpc('listunspent', [])

listunspent_args = []
if 'listunspent_args' in jm_single().config.options('POLICY'):
listunspent_args = ast.literal_eval(
jm_single().config.get('POLICY', 'listunspent_args'))

unspent_list = self.rpc('listunspent', listunspent_args)
for u in unspent_list:
if 'account' not in u:
continue
if u['account'] != wallet_name:
continue
if u['address'] not in wallet.addr_cache:
continue
wallet.unspent[u['txid'] + ':' + str(u[
'vout'])] = {
wallet.unspent[u['txid'] + ':' + str(u['vout'])] = {
'address': u['address'],
'value':
int(Decimal(str(u['amount'])) * Decimal('1e8'))}
'value': int(Decimal(str(u['amount'])) * Decimal('1e8'))}
et = time.time()
log.debug('bitcoind sync_unspent took ' + str((et - st)) + 'sec')

Expand Down
13 changes: 13 additions & 0 deletions joinmarket/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,19 @@ def jm_single():
# as our default. Note that for clients not using a local blockchain
# instance, we retrieve an estimate from the API at blockcypher.com, currently.
tx_fees = 3
# the range of confirmations passed to the `listunspent` bitcoind RPC call
# 1st value is the inclusive minimum, defaults to one confirmation
# 2nd value is the exclusive maximum, defaults to most-positive-bignum (Google Me!)
# leaving it unset or empty defers to bitcoind's default values, ie [1, 9999999]
#listunspent_args = []
# that's what you should do, unless you have a specific reason, eg:
# spend from unconfirmed transactions: listunspent_args = [0]
# display only unconfirmed transactions: listunspent_args = [0, 1]
# defend against small reorganizations: listunspent_args = [3]
# who is at risk of reorganization?: listunspent_args = [0, 2]
# NB: using 0 for the 1st value with scripts other than wallet-tool could cause
# spends from unconfirmed inputs, which may then get malleated or double-spent!
# other counterparties are likely to reject unconfirmed inputs... don't do it.
"""


Expand Down
4 changes: 4 additions & 0 deletions wallet-tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@
extend_mixdepth=not maxmixdepth_configured,
storepassword=(method == 'importprivkey'))
if method not in noscan_methods:
# if nothing was configured, we override bitcoind's options so that
# unconfirmed balance is included in the wallet display by default
if 'listunspent_args' not in jm_single().config.options('POLICY'):
jm_single().config.set('POLICY','listunspent_args', '[0]')
jm_single().bc_interface.sync_wallet(wallet)

if method == 'display' or method == 'displayall' or method == 'summary':
Expand Down

0 comments on commit 74a19be

Please sign in to comment.