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