|
|
@ -7,6 +7,7 @@ |
|
|
|
# Test fee estimation code |
|
|
|
# Test fee estimation code |
|
|
|
# |
|
|
|
# |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from collections import OrderedDict |
|
|
|
from test_framework.test_framework import BitcoinTestFramework |
|
|
|
from test_framework.test_framework import BitcoinTestFramework |
|
|
|
from test_framework.util import * |
|
|
|
from test_framework.util import * |
|
|
|
|
|
|
|
|
|
|
@ -49,8 +50,8 @@ def small_txpuzzle_randfee(from_node, conflist, unconflist, amount, min_fee, fee |
|
|
|
if total_in <= amount + fee: |
|
|
|
if total_in <= amount + fee: |
|
|
|
raise RuntimeError("Insufficient funds: need %d, have %d"%(amount+fee, total_in)) |
|
|
|
raise RuntimeError("Insufficient funds: need %d, have %d"%(amount+fee, total_in)) |
|
|
|
outputs = {} |
|
|
|
outputs = {} |
|
|
|
outputs[P2SH_1] = total_in - amount - fee |
|
|
|
outputs = OrderedDict([(P2SH_1, total_in - amount - fee), |
|
|
|
outputs[P2SH_2] = amount |
|
|
|
(P2SH_2, amount)]) |
|
|
|
rawtx = from_node.createrawtransaction(inputs, outputs) |
|
|
|
rawtx = from_node.createrawtransaction(inputs, outputs) |
|
|
|
# Createrawtransaction constructions a transaction that is ready to be signed |
|
|
|
# Createrawtransaction constructions a transaction that is ready to be signed |
|
|
|
# These transactions don't need to be signed, but we still have to insert the ScriptSig |
|
|
|
# These transactions don't need to be signed, but we still have to insert the ScriptSig |
|
|
@ -78,12 +79,10 @@ def split_inputs(from_node, txins, txouts, initial_split = False): |
|
|
|
''' |
|
|
|
''' |
|
|
|
prevtxout = txins.pop() |
|
|
|
prevtxout = txins.pop() |
|
|
|
inputs = [] |
|
|
|
inputs = [] |
|
|
|
outputs = {} |
|
|
|
|
|
|
|
inputs.append({ "txid" : prevtxout["txid"], "vout" : prevtxout["vout"] }) |
|
|
|
inputs.append({ "txid" : prevtxout["txid"], "vout" : prevtxout["vout"] }) |
|
|
|
half_change = satoshi_round(prevtxout["amount"]/2) |
|
|
|
half_change = satoshi_round(prevtxout["amount"]/2) |
|
|
|
rem_change = prevtxout["amount"] - half_change - Decimal("0.00001000") |
|
|
|
rem_change = prevtxout["amount"] - half_change - Decimal("0.00001000") |
|
|
|
outputs[P2SH_1] = half_change |
|
|
|
outputs = OrderedDict([(P2SH_1, half_change), (P2SH_2, rem_change)]) |
|
|
|
outputs[P2SH_2] = rem_change |
|
|
|
|
|
|
|
rawtx = from_node.createrawtransaction(inputs, outputs) |
|
|
|
rawtx = from_node.createrawtransaction(inputs, outputs) |
|
|
|
# If this is the initial split we actually need to sign the transaction |
|
|
|
# If this is the initial split we actually need to sign the transaction |
|
|
|
# Otherwise we just need to insert the property ScriptSig |
|
|
|
# Otherwise we just need to insert the property ScriptSig |
|
|
|