fix: disabling "use change addresses" did not work correctly
This commit is contained in:
parent
c4d31674ab
commit
72a443b688
|
@ -25,7 +25,7 @@
|
||||||
from collections import defaultdict, namedtuple
|
from collections import defaultdict, namedtuple
|
||||||
from math import floor, log10
|
from math import floor, log10
|
||||||
|
|
||||||
from .bitcoin import sha256, COIN, TYPE_ADDRESS
|
from .bitcoin import sha256, COIN, TYPE_ADDRESS, is_address
|
||||||
from .transaction import Transaction
|
from .transaction import Transaction
|
||||||
from .util import NotEnoughFunds, PrintError
|
from .util import NotEnoughFunds, PrintError
|
||||||
|
|
||||||
|
@ -240,6 +240,13 @@ class CoinChooserBase(PrintError):
|
||||||
tx.add_inputs([coin for b in buckets for coin in b.coins])
|
tx.add_inputs([coin for b in buckets for coin in b.coins])
|
||||||
tx_weight = get_tx_weight(buckets)
|
tx_weight = get_tx_weight(buckets)
|
||||||
|
|
||||||
|
# change is sent back to sending address unless specified
|
||||||
|
if not change_addrs:
|
||||||
|
change_addrs = [tx.inputs()[0]['address']]
|
||||||
|
# note: this is not necessarily the final "first input address"
|
||||||
|
# because the inputs had not been sorted at this point
|
||||||
|
assert is_address(change_addrs[0])
|
||||||
|
|
||||||
# This takes a count of change outputs and returns a tx fee
|
# This takes a count of change outputs and returns a tx fee
|
||||||
output_weight = 4 * Transaction.estimated_output_size(change_addrs[0])
|
output_weight = 4 * Transaction.estimated_output_size(change_addrs[0])
|
||||||
fee = lambda count: fee_estimator_w(tx_weight + count * output_weight)
|
fee = lambda count: fee_estimator_w(tx_weight + count * output_weight)
|
||||||
|
|
|
@ -1123,7 +1123,8 @@ class Abstract_Wallet(PrintError):
|
||||||
if not change_addrs:
|
if not change_addrs:
|
||||||
change_addrs = [random.choice(addrs)]
|
change_addrs = [random.choice(addrs)]
|
||||||
else:
|
else:
|
||||||
change_addrs = [inputs[0]['address']]
|
# coin_chooser will set change address
|
||||||
|
change_addrs = []
|
||||||
|
|
||||||
# Fee estimator
|
# Fee estimator
|
||||||
if fixed_fee is None:
|
if fixed_fee is None:
|
||||||
|
|
Loading…
Reference in New Issue