@@ -137,6 +137,61 @@ def run_test(self):
137
137
self .nodes [2 ].createrawtransaction (inputs = [{'txid' : txid , 'vout' : 9 }], outputs = [{address : 99 }, {'data' : '99' }, {'data' : '99' }]),
138
138
)
139
139
140
+ for type in ["bech32" , "p2sh-segwit" , "legacy" ]:
141
+ addr = self .nodes [0 ].getnewaddress ("" , type )
142
+ addrinfo = self .nodes [0 ].getaddressinfo (addr )
143
+ pubkey = addrinfo ["scriptPubKey" ]
144
+
145
+ self .log .info ('sendrawtransaction with missing prevtx info (%s)' % (type ))
146
+
147
+ # Test `signrawtransactionwithwallet` invalid `prevtxs`
148
+ inputs = [ {'txid' : txid , 'vout' : 3 , 'sequence' : 1000 }]
149
+ outputs = { self .nodes [0 ].getnewaddress () : 1 }
150
+ rawtx = self .nodes [0 ].createrawtransaction (inputs , outputs )
151
+
152
+ prevtx = dict (txid = txid , scriptPubKey = pubkey , vout = 3 , amount = 1 )
153
+ succ = self .nodes [0 ].signrawtransactionwithwallet (rawtx , [prevtx ])
154
+ assert succ ["complete" ]
155
+ if type == "legacy" :
156
+ del prevtx ["amount" ]
157
+ succ = self .nodes [0 ].signrawtransactionwithwallet (rawtx , [prevtx ])
158
+ assert succ ["complete" ]
159
+
160
+ if type != "legacy" :
161
+ assert_raises_rpc_error (- 3 , "Missing amount" , self .nodes [0 ].signrawtransactionwithwallet , rawtx , [
162
+ {
163
+ "txid" : txid ,
164
+ "scriptPubKey" : pubkey ,
165
+ "vout" : 3 ,
166
+ }
167
+ ])
168
+
169
+ assert_raises_rpc_error (- 3 , "Missing vout" , self .nodes [0 ].signrawtransactionwithwallet , rawtx , [
170
+ {
171
+ "txid" : txid ,
172
+ "scriptPubKey" : pubkey ,
173
+ "amount" : 1 ,
174
+ }
175
+ ])
176
+ assert_raises_rpc_error (- 3 , "Missing txid" , self .nodes [0 ].signrawtransactionwithwallet , rawtx , [
177
+ {
178
+ "scriptPubKey" : pubkey ,
179
+ "vout" : 3 ,
180
+ "amount" : 1 ,
181
+ }
182
+ ])
183
+ assert_raises_rpc_error (- 3 , "Missing scriptPubKey" , self .nodes [0 ].signrawtransactionwithwallet , rawtx , [
184
+ {
185
+ "txid" : txid ,
186
+ "vout" : 3 ,
187
+ "amount" : 1
188
+ }
189
+ ])
190
+
191
+ #########################################
192
+ # sendrawtransaction with missing input #
193
+ #########################################
194
+
140
195
self .log .info ('sendrawtransaction with missing input' )
141
196
inputs = [ {'txid' : "1d1d4e24ed99057e84c3f80fd8fbec79ed9e1acee37da269356ecea000000000" , 'vout' : 1 }] #won't exists
142
197
outputs = { self .nodes [0 ].getnewaddress () : 4.998 }
0 commit comments