|
|
@ -210,6 +210,8 @@ class WalletTest(BitcoinTestFramework):
|
|
|
|
assert_equal(self.nodes[2].getbalance(), node_2_bal)
|
|
|
|
assert_equal(self.nodes[2].getbalance(), node_2_bal)
|
|
|
|
node_0_bal = self.check_fee_amount(self.nodes[0].getbalance(), Decimal('20'), fee_per_byte, self.get_vsize(self.nodes[2].gettransaction(txid)['hex']))
|
|
|
|
node_0_bal = self.check_fee_amount(self.nodes[0].getbalance(), Decimal('20'), fee_per_byte, self.get_vsize(self.nodes[2].gettransaction(txid)['hex']))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.log.info("Test sendmany")
|
|
|
|
|
|
|
|
|
|
|
|
# Sendmany 10 BTC
|
|
|
|
# Sendmany 10 BTC
|
|
|
|
txid = self.nodes[2].sendmany('', {address: 10}, 0, "", [])
|
|
|
|
txid = self.nodes[2].sendmany('', {address: 10}, 0, "", [])
|
|
|
|
self.nodes[2].generate(1)
|
|
|
|
self.nodes[2].generate(1)
|
|
|
@ -226,7 +228,7 @@ class WalletTest(BitcoinTestFramework):
|
|
|
|
assert_equal(self.nodes[2].getbalance(), node_2_bal)
|
|
|
|
assert_equal(self.nodes[2].getbalance(), node_2_bal)
|
|
|
|
node_0_bal = self.check_fee_amount(self.nodes[0].getbalance(), node_0_bal + Decimal('10'), fee_per_byte, self.get_vsize(self.nodes[2].gettransaction(txid)['hex']))
|
|
|
|
node_0_bal = self.check_fee_amount(self.nodes[0].getbalance(), node_0_bal + Decimal('10'), fee_per_byte, self.get_vsize(self.nodes[2].gettransaction(txid)['hex']))
|
|
|
|
|
|
|
|
|
|
|
|
# Sendmany with explicit fee (BTC/kB)
|
|
|
|
self.log.info("Test case-insensitive explicit fee rate (sendmany as BTC/kB)")
|
|
|
|
# Throw if no conf_target provided
|
|
|
|
# Throw if no conf_target provided
|
|
|
|
assert_raises_rpc_error(-8, "Selected estimate_mode bTc/kB requires a fee rate to be specified in conf_target",
|
|
|
|
assert_raises_rpc_error(-8, "Selected estimate_mode bTc/kB requires a fee rate to be specified in conf_target",
|
|
|
|
self.nodes[2].sendmany,
|
|
|
|
self.nodes[2].sendmany,
|
|
|
@ -252,7 +254,7 @@ class WalletTest(BitcoinTestFramework):
|
|
|
|
node_0_bal += Decimal('10')
|
|
|
|
node_0_bal += Decimal('10')
|
|
|
|
assert_equal(self.nodes[0].getbalance(), node_0_bal)
|
|
|
|
assert_equal(self.nodes[0].getbalance(), node_0_bal)
|
|
|
|
|
|
|
|
|
|
|
|
# Sendmany with explicit fee (SAT/B)
|
|
|
|
self.log.info("Test case-insensitive explicit fee rate (sendmany as sat/B)")
|
|
|
|
# Throw if no conf_target provided
|
|
|
|
# Throw if no conf_target provided
|
|
|
|
assert_raises_rpc_error(-8, "Selected estimate_mode sat/b requires a fee rate to be specified in conf_target",
|
|
|
|
assert_raises_rpc_error(-8, "Selected estimate_mode sat/b requires a fee rate to be specified in conf_target",
|
|
|
|
self.nodes[2].sendmany,
|
|
|
|
self.nodes[2].sendmany,
|
|
|
@ -280,6 +282,12 @@ class WalletTest(BitcoinTestFramework):
|
|
|
|
node_0_bal += Decimal('10')
|
|
|
|
node_0_bal += Decimal('10')
|
|
|
|
assert_equal(self.nodes[0].getbalance(), node_0_bal)
|
|
|
|
assert_equal(self.nodes[0].getbalance(), node_0_bal)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Test setting explicit fee rate just below the minimum.
|
|
|
|
|
|
|
|
for unit, fee_rate in {"BTC/kB": 0.00000999, "sat/B": 0.99999999}.items():
|
|
|
|
|
|
|
|
self.log.info("Test sendmany raises 'fee rate too low' if conf_target {} and estimate_mode {} are passed".format(fee_rate, unit))
|
|
|
|
|
|
|
|
assert_raises_rpc_error(-6, "Fee rate (0.00000999 BTC/kB) is lower than the minimum fee rate setting (0.00001000 BTC/kB)",
|
|
|
|
|
|
|
|
self.nodes[2].sendmany, amounts={address: 10}, estimate_mode=unit, conf_target=fee_rate)
|
|
|
|
|
|
|
|
|
|
|
|
self.start_node(3, self.nodes[3].extra_args)
|
|
|
|
self.start_node(3, self.nodes[3].extra_args)
|
|
|
|
connect_nodes(self.nodes[0], 3)
|
|
|
|
connect_nodes(self.nodes[0], 3)
|
|
|
|
self.sync_all()
|
|
|
|
self.sync_all()
|
|
|
@ -413,8 +421,7 @@ class WalletTest(BitcoinTestFramework):
|
|
|
|
self.nodes[0].generate(1)
|
|
|
|
self.nodes[0].generate(1)
|
|
|
|
self.sync_all(self.nodes[0:3])
|
|
|
|
self.sync_all(self.nodes[0:3])
|
|
|
|
|
|
|
|
|
|
|
|
# send with explicit btc/kb fee
|
|
|
|
self.log.info("Test case-insensitive explicit fee rate (sendtoaddress as BTC/kB)")
|
|
|
|
self.log.info("test explicit fee (sendtoaddress as btc/kb)")
|
|
|
|
|
|
|
|
self.nodes[0].generate(1)
|
|
|
|
self.nodes[0].generate(1)
|
|
|
|
self.sync_all(self.nodes[0:3])
|
|
|
|
self.sync_all(self.nodes[0:3])
|
|
|
|
prebalance = self.nodes[2].getbalance()
|
|
|
|
prebalance = self.nodes[2].getbalance()
|
|
|
@ -447,9 +454,9 @@ class WalletTest(BitcoinTestFramework):
|
|
|
|
fee = prebalance - postbalance - Decimal('1')
|
|
|
|
fee = prebalance - postbalance - Decimal('1')
|
|
|
|
assert_fee_amount(fee, tx_size, Decimal('0.00002500'))
|
|
|
|
assert_fee_amount(fee, tx_size, Decimal('0.00002500'))
|
|
|
|
|
|
|
|
|
|
|
|
# send with explicit sat/b fee
|
|
|
|
|
|
|
|
self.sync_all(self.nodes[0:3])
|
|
|
|
self.sync_all(self.nodes[0:3])
|
|
|
|
self.log.info("test explicit fee (sendtoaddress as sat/b)")
|
|
|
|
|
|
|
|
|
|
|
|
self.log.info("Test case-insensitive explicit fee rate (sendtoaddress as sat/B)")
|
|
|
|
self.nodes[0].generate(1)
|
|
|
|
self.nodes[0].generate(1)
|
|
|
|
prebalance = self.nodes[2].getbalance()
|
|
|
|
prebalance = self.nodes[2].getbalance()
|
|
|
|
assert prebalance > 2
|
|
|
|
assert prebalance > 2
|
|
|
@ -481,6 +488,12 @@ class WalletTest(BitcoinTestFramework):
|
|
|
|
fee = prebalance - postbalance - Decimal('1')
|
|
|
|
fee = prebalance - postbalance - Decimal('1')
|
|
|
|
assert_fee_amount(fee, tx_size, Decimal('0.00002000'))
|
|
|
|
assert_fee_amount(fee, tx_size, Decimal('0.00002000'))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Test setting explicit fee rate just below the minimum.
|
|
|
|
|
|
|
|
for unit, fee_rate in {"BTC/kB": 0.00000999, "sat/B": 0.99999999}.items():
|
|
|
|
|
|
|
|
self.log.info("Test sendtoaddress raises 'fee rate too low' if conf_target {} and estimate_mode {} are passed".format(fee_rate, unit))
|
|
|
|
|
|
|
|
assert_raises_rpc_error(-6, "Fee rate (0.00000999 BTC/kB) is lower than the minimum fee rate setting (0.00001000 BTC/kB)",
|
|
|
|
|
|
|
|
self.nodes[2].sendtoaddress, address=address, amount=1, estimate_mode=unit, conf_target=fee_rate)
|
|
|
|
|
|
|
|
|
|
|
|
# 2. Import address from node2 to node1
|
|
|
|
# 2. Import address from node2 to node1
|
|
|
|
self.nodes[1].importaddress(address_to_import)
|
|
|
|
self.nodes[1].importaddress(address_to_import)
|
|
|
|
|
|
|
|
|
|
|
|