@@ -95,6 +95,7 @@ def run_test(self):
9595 self .test_address_reuse ()
9696 self .test_option_subtract_fee_from_outputs ()
9797 self .test_subtract_fee_with_presets ()
98+ self .test_surjectionproof_many_inputs ()
9899
99100 def test_change_position (self ):
100101 """Ensure setting changePosition in fundraw with an exact match is handled properly."""
@@ -953,5 +954,33 @@ def test_subtract_fee_with_presets(self):
953954 signedtx = self .nodes [0 ].signrawtransactionwithwallet (blindedtx )
954955 self .nodes [0 ].sendrawtransaction (signedtx ['hex' ])
955956
957+ def test_surjectionproof_many_inputs (self ):
958+ self .log .info ("Test fundrawtx with more than 256 inputs" )
959+
960+ self .nodes [0 ].createwallet ("surjection" )
961+ wallet = self .nodes [0 ].get_wallet_rpc (self .default_wallet_name )
962+ recipient = self .nodes [0 ].get_wallet_rpc ("surjection" )
963+
964+ # Make 500 0.1 BTC outputs...
965+ for j in range (0 , 10 ):
966+ outputs = {}
967+ for i in range (0 , 50 ):
968+ outputs [recipient .getnewaddress ()] = 0.1
969+ wallet .sendmany ("" , outputs )
970+ self .nodes [0 ].generate (10 )
971+
972+ # ...and try to send them all in one transaction
973+ # This should fail but we should not see an assertation failure.
974+ rawtx = recipient .createrawtransaction ([], {wallet .getnewaddress (): 49.99 })
975+ assert_raises_rpc_error (- 4 , "Unable to blind the transaction properly. This should not happen." , recipient .fundrawtransaction , rawtx )
976+
977+ # Try to send them across two transactions. This should succeed.
978+ rawtx = recipient .createrawtransaction ([], {wallet .getnewaddress (): 24.99 })
979+ for i in range (0 , 2 ):
980+ fundedtx = recipient .fundrawtransaction (rawtx )
981+ blindedtx = recipient .blindrawtransaction (fundedtx ['hex' ])
982+ signedtx = recipient .signrawtransactionwithwallet (blindedtx )
983+ self .nodes [0 ].sendrawtransaction (signedtx ['hex' ])
984+
956985if __name__ == '__main__' :
957986 RawTransactionsTest ().main ()
0 commit comments