|
|
|
@ -47,20 +47,20 @@ class AbandonConflictTest(BitcoinTestFramework):
@@ -47,20 +47,20 @@ class AbandonConflictTest(BitcoinTestFramework):
|
|
|
|
|
inputs.append({"txid":txB, "vout":nB}) |
|
|
|
|
outputs = {} |
|
|
|
|
|
|
|
|
|
outputs[self.nodes[0].getnewaddress()] = Decimal("14.998") |
|
|
|
|
outputs[self.nodes[0].getnewaddress()] = Decimal("14.99998") |
|
|
|
|
outputs[self.nodes[1].getnewaddress()] = Decimal("5") |
|
|
|
|
signed = self.nodes[0].signrawtransaction(self.nodes[0].createrawtransaction(inputs, outputs)) |
|
|
|
|
txAB1 = self.nodes[0].sendrawtransaction(signed["hex"]) |
|
|
|
|
|
|
|
|
|
# Identify the 14.99998btc output |
|
|
|
|
nAB = next(i for i, vout in enumerate(self.nodes[0].getrawtransaction(txAB1, 1)["vout"]) if vout["value"] == Decimal("14.998")) |
|
|
|
|
nAB = next(i for i, vout in enumerate(self.nodes[0].getrawtransaction(txAB1, 1)["vout"]) if vout["value"] == Decimal("14.99998")) |
|
|
|
|
|
|
|
|
|
#Create a child tx spending AB1 and C |
|
|
|
|
inputs = [] |
|
|
|
|
inputs.append({"txid":txAB1, "vout":nAB}) |
|
|
|
|
inputs.append({"txid":txC, "vout":nC}) |
|
|
|
|
outputs = {} |
|
|
|
|
outputs[self.nodes[0].getnewaddress()] = Decimal("24.96") |
|
|
|
|
outputs[self.nodes[0].getnewaddress()] = Decimal("24.9996") |
|
|
|
|
signed2 = self.nodes[0].signrawtransaction(self.nodes[0].createrawtransaction(inputs, outputs)) |
|
|
|
|
txABC2 = self.nodes[0].sendrawtransaction(signed2["hex"]) |
|
|
|
|
|
|
|
|
@ -80,7 +80,7 @@ class AbandonConflictTest(BitcoinTestFramework):
@@ -80,7 +80,7 @@ class AbandonConflictTest(BitcoinTestFramework):
|
|
|
|
|
# Restart the node with a higher min relay fee so the parent tx is no longer in mempool |
|
|
|
|
# TODO: redo with eviction |
|
|
|
|
self.stop_node(0) |
|
|
|
|
self.start_node(0, extra_args=["-minrelaytxfee=0.01"]) |
|
|
|
|
self.start_node(0, extra_args=["-minrelaytxfee=0.0001"]) |
|
|
|
|
|
|
|
|
|
# Verify txs no longer in either node's mempool |
|
|
|
|
assert_equal(len(self.nodes[0].getrawmempool()), 0) |
|
|
|
@ -107,7 +107,7 @@ class AbandonConflictTest(BitcoinTestFramework):
@@ -107,7 +107,7 @@ class AbandonConflictTest(BitcoinTestFramework):
|
|
|
|
|
|
|
|
|
|
# Verify that even with a low min relay fee, the tx is not reaccepted from wallet on startup once abandoned |
|
|
|
|
self.stop_node(0) |
|
|
|
|
self.start_node(0, extra_args=["-minrelaytxfee=0.001"]) |
|
|
|
|
self.start_node(0, extra_args=["-minrelaytxfee=0.00001"]) |
|
|
|
|
assert_equal(len(self.nodes[0].getrawmempool()), 0) |
|
|
|
|
assert_equal(self.nodes[0].getbalance(), balance) |
|
|
|
|
|
|
|
|
@ -116,21 +116,21 @@ class AbandonConflictTest(BitcoinTestFramework):
@@ -116,21 +116,21 @@ class AbandonConflictTest(BitcoinTestFramework):
|
|
|
|
|
# But its child tx remains abandoned |
|
|
|
|
self.nodes[0].sendrawtransaction(signed["hex"]) |
|
|
|
|
newbalance = self.nodes[0].getbalance() |
|
|
|
|
assert_equal(newbalance, balance - Decimal("20") + Decimal("14.998")) |
|
|
|
|
assert_equal(newbalance, balance - Decimal("20") + Decimal("14.99998")) |
|
|
|
|
balance = newbalance |
|
|
|
|
|
|
|
|
|
# Send child tx again so its unabandoned |
|
|
|
|
self.nodes[0].sendrawtransaction(signed2["hex"]) |
|
|
|
|
newbalance = self.nodes[0].getbalance() |
|
|
|
|
assert_equal(newbalance, balance - Decimal("10") - Decimal("14.998") + Decimal("24.96")) |
|
|
|
|
assert_equal(newbalance, balance - Decimal("10") - Decimal("14.99998") + Decimal("24.9996")) |
|
|
|
|
balance = newbalance |
|
|
|
|
|
|
|
|
|
# Remove using high relay fee again |
|
|
|
|
self.stop_node(0) |
|
|
|
|
self.start_node(0, extra_args=["-minrelaytxfee=0.01"]) |
|
|
|
|
self.start_node(0, extra_args=["-minrelaytxfee=0.0001"]) |
|
|
|
|
assert_equal(len(self.nodes[0].getrawmempool()), 0) |
|
|
|
|
newbalance = self.nodes[0].getbalance() |
|
|
|
|
assert_equal(newbalance, balance - Decimal("24.96")) |
|
|
|
|
assert_equal(newbalance, balance - Decimal("24.9996")) |
|
|
|
|
balance = newbalance |
|
|
|
|
|
|
|
|
|
# Create a double spend of AB1 by spending again from only A's 10 output |
|
|
|
@ -138,7 +138,7 @@ class AbandonConflictTest(BitcoinTestFramework):
@@ -138,7 +138,7 @@ class AbandonConflictTest(BitcoinTestFramework):
|
|
|
|
|
inputs =[] |
|
|
|
|
inputs.append({"txid":txA, "vout":nA}) |
|
|
|
|
outputs = {} |
|
|
|
|
outputs[self.nodes[1].getnewaddress()] = Decimal("9.99") |
|
|
|
|
outputs[self.nodes[1].getnewaddress()] = Decimal("9.9999") |
|
|
|
|
tx = self.nodes[0].createrawtransaction(inputs, outputs) |
|
|
|
|
signed = self.nodes[0].signrawtransaction(tx) |
|
|
|
|
self.nodes[1].sendrawtransaction(signed["hex"]) |
|
|
|
@ -163,4 +163,4 @@ class AbandonConflictTest(BitcoinTestFramework):
@@ -163,4 +163,4 @@ class AbandonConflictTest(BitcoinTestFramework):
|
|
|
|
|
self.log.info(str(balance) + " -> " + str(newbalance) + " ?") |
|
|
|
|
|
|
|
|
|
if __name__ == '__main__': |
|
|
|
|
AbandonConflictTest().main() |
|
|
|
|
AbandonConflictTest().main() |