@@ -71,9 +71,39 @@ def test_dust_output(self, node: TestNode, dust_relay_fee: Decimal,
71
71
# finally send the transaction to avoid running out of MiniWallet UTXOs
72
72
self .wallet .sendrawtransaction (from_node = node , tx_hex = tx_good_hex )
73
73
74
+ def test_dustrelay (self ):
75
+ self .log .info ("Test that small outputs are acceptable when dust relay rate is set to 0 that would otherwise trigger ephemeral dust rules" )
76
+
77
+ self .restart_node (0 , extra_args = ["-dustrelayfee=0" ])
78
+
79
+ assert_equal (self .nodes [0 ].getrawmempool (), [])
80
+
81
+ # Double dust, both unspent, with fees. Would have failed individual checks.
82
+ # Dust is 1 satoshi create_self_transfer_multi disallows 0
83
+ dusty_tx = self .wallet .create_self_transfer_multi (fee_per_output = 1000 , amount_per_output = 1 , num_outputs = 2 )
84
+ dust_txid = self .nodes [0 ].sendrawtransaction (hexstring = dusty_tx ["hex" ], maxfeerate = 0 )
85
+
86
+ assert_equal (self .nodes [0 ].getrawmempool (), [dust_txid ])
87
+
88
+ # Spends one dust along with fee input, leave other dust unspent to check ephemeral dust checks aren't being enforced
89
+ sweep_tx = self .wallet .create_self_transfer_multi (utxos_to_spend = [self .wallet .get_utxo (), dusty_tx ["new_utxos" ][0 ]])
90
+ sweep_txid = self .nodes [0 ].sendrawtransaction (sweep_tx ["hex" ])
91
+
92
+ mempool_entries = self .nodes [0 ].getrawmempool ()
93
+ assert dust_txid in mempool_entries
94
+ assert sweep_txid in mempool_entries
95
+ assert_equal (len (mempool_entries ), 2 )
96
+
97
+ # Wipe extra arg to reset dust relay
98
+ self .restart_node (0 , extra_args = [])
99
+
100
+ assert_equal (self .nodes [0 ].getrawmempool (), [])
101
+
74
102
def run_test (self ):
75
103
self .wallet = MiniWallet (self .nodes [0 ])
76
104
105
+ self .test_dustrelay ()
106
+
77
107
# prepare output scripts of each standard type
78
108
_ , uncompressed_pubkey = generate_keypair (compressed = False )
79
109
_ , pubkey = generate_keypair (compressed = True )
0 commit comments