@@ -106,6 +106,44 @@ def test_wallet_recovery(self):
106
106
# clean up blind_details
107
107
os .remove (file_path )
108
108
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
+
109
147
def test_null_rangeproof_enforcement (self ):
110
148
self .generate (self .nodes [0 ], 1 )
111
149
@@ -160,6 +198,12 @@ def test_null_rangeproof_enforcement(self):
160
198
161
199
def run_test (self ):
162
200
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
+
163
207
print ("Testing that null issuances must have null rangeproofs" )
164
208
self .test_null_rangeproof_enforcement ()
165
209
0 commit comments