|
@ -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) |
|
|