@@ -106,6 +106,44 @@ def test_wallet_recovery(self):
106106 # clean up blind_details
107107 os .remove (file_path )
108108
109+ def test_no_surj (self ):
110+ self .generate (self .nodes [0 ], 1 )
111+
112+ tx_hex = self .nodes [0 ].createrawtransaction ([], [{self .nodes [1 ].getnewaddress (): 1000 }])
113+ tx_hex = self .nodes [0 ].fundrawtransaction (tx_hex )['hex' ]
114+ tx_hex = self .nodes [0 ].blindrawtransaction (tx_hex )
115+ # coming from initial free coins: no need to sign
116+ assert_equal (self .nodes [0 ].testmempoolaccept ([tx_hex ])[0 ]['allowed' ], True ) # tx is ok
117+
118+ # remove a surjection proof from the tx
119+ tx = CTransaction ()
120+ tx .deserialize (io .BytesIO (bytes .fromhex (tx_hex )))
121+ tx .wit .vtxoutwit [0 ].vchSurjectionproof = b''
122+ tx_hex = tx .serialize ().hex ()
123+
124+ # Both of these make the node crash
125+ assert_equal (self .nodes [0 ].testmempoolaccept ([tx_hex ])[0 ]['allowed' ], False )
126+ assert_raises_rpc_error (- 26 , "bad-txns-in-ne-out" , self .nodes [0 ].sendrawtransaction , tx_hex )
127+
128+ def test_no_range (self ):
129+ self .generate (self .nodes [0 ], 1 )
130+
131+ tx_hex = self .nodes [0 ].createrawtransaction ([], [{self .nodes [1 ].getnewaddress (): 1000 }])
132+ tx_hex = self .nodes [0 ].fundrawtransaction (tx_hex )['hex' ]
133+ tx_hex = self .nodes [0 ].blindrawtransaction (tx_hex )
134+ # coming from initial free coins: no need to sign
135+ assert_equal (self .nodes [0 ].testmempoolaccept ([tx_hex ])[0 ]['allowed' ], True ) # tx is ok
136+
137+ # remove a surjection proof from the tx
138+ tx = CTransaction ()
139+ tx .deserialize (io .BytesIO (bytes .fromhex (tx_hex )))
140+ tx .wit .vtxoutwit [0 ].vchRangeproof = b''
141+ tx_hex = tx .serialize ().hex ()
142+
143+ # Both of these make the node crash
144+ assert_equal (self .nodes [0 ].testmempoolaccept ([tx_hex ])[0 ]['allowed' ], False )
145+ assert_raises_rpc_error (- 26 , "bad-txns-in-ne-out" , self .nodes [0 ].sendrawtransaction , tx_hex )
146+
109147 def test_null_rangeproof_enforcement (self ):
110148 self .generate (self .nodes [0 ], 1 )
111149
@@ -160,6 +198,12 @@ def test_null_rangeproof_enforcement(self):
160198
161199 def run_test (self ):
162200
201+ print ("Testing a transaction with a missing surjection proof" )
202+ self .test_no_surj ()
203+
204+ print ("Testing a transaction with a missing range proof" )
205+ self .test_no_range ()
206+
163207 print ("Testing that null issuances must have null rangeproofs" )
164208 self .test_null_rangeproof_enforcement ()
165209
0 commit comments