@@ -184,23 +184,10 @@ string dump_bitcoin_tx_outputs(const struct bitcoin_tx_output **outputs)
184184 return ostrm.str ();
185185}
186186
187- string dump_input_amounts (const struct amount_sat **ias)
188- {
189- ostringstream ostrm;
190- ostrm << " [" ;
191- if (*ias) {
192- for (size_t ii = 0 ; ii < tal_count (ias); ii++) {
193- if (ii != 0 )
194- ostrm << " ," ;
195- ostrm << ias[ii]->satoshis ;
196- }
197- }
198- ostrm << " ]" ;
199- return ostrm.str ();
200- }
201-
202187string dump_wally_tx_witness_stack (const struct wally_tx_witness_stack *sp)
203188{
189+ if (sp == NULL )
190+ return " []" ;
204191 ostringstream ostrm;
205192 ostrm << " [" ;
206193 for (size_t ii = 0 ; ii < sp->num_items ; ii++) {
@@ -247,6 +234,8 @@ string dump_wally_tx_inputs(const struct wally_tx_input *inputs,
247234
248235string dump_wally_tx_output (const struct wally_tx_output *out)
249236{
237+ if (out == NULL )
238+ return " {}" ;
250239 ostringstream ostrm;
251240 ostrm << " { " ;
252241 ostrm << " satoshi=" << out->satoshi ;
@@ -274,6 +263,8 @@ string dump_wally_tx_outputs(const struct wally_tx_output *outputs,
274263
275264string dump_wally_tx (const struct wally_tx *wtx)
276265{
266+ if (wtx == NULL )
267+ return " {}" ;
277268 ostringstream ostrm;
278269 ostrm << " { " ;
279270 ostrm << " version=" << wtx->version ;
@@ -288,32 +279,87 @@ string dump_wally_tx(const struct wally_tx *wtx)
288279 return ostrm.str ();
289280}
290281
291- string dump_output_witscripts (const struct witscript **wp)
282+ string dump_wally_psbt_input (const struct wally_psbt_input *in)
283+ {
284+ ostringstream ostrm;
285+ ostrm << " { " ;
286+ ostrm << " non_witness_utxo=" << dump_wally_tx (in->non_witness_utxo );
287+ ostrm << " , witness_utxo=" << dump_wally_tx_output (in->witness_utxo );
288+ ostrm << " , redeem_script=" << dump_hex (in->redeem_script ,
289+ in->redeem_script_len );
290+ ostrm << " , witness_script=" << dump_hex (in->witness_script ,
291+ in->witness_script_len );
292+ ostrm << " , final_script_sig=" << dump_hex (in->final_script_sig ,
293+ in->final_script_sig_len );
294+ ostrm << " , final_witness="
295+ << dump_wally_tx_witness_stack (in->final_witness );
296+ ostrm << " , keypaths=??, partial_sigs==??, unknown=??" ;
297+ ostrm << " , sighash_type=" << in->sighash_type ;
298+ ostrm << " }" ;
299+ return ostrm.str ();
300+ }
301+
302+ string dump_wally_psbt_inputs (const struct wally_psbt_input *inputs,
303+ size_t num_inputs)
304+ {
305+ ostringstream ostrm;
306+ ostrm << " [" ;
307+ for (size_t ii = 0 ; ii < num_inputs; ii++) {
308+ if (ii != 0 )
309+ ostrm << " ," ;
310+ ostrm << dump_wally_psbt_input (&inputs[ii]);
311+ }
312+ ostrm << " ]" ;
313+ return ostrm.str ();
314+ }
315+
316+ string dump_wally_psbt_output (const struct wally_psbt_output *out)
317+ {
318+ ostringstream ostrm;
319+ ostrm << " { " ;
320+ ostrm << " redeem_script=" << dump_hex (out->redeem_script ,
321+ out->redeem_script_len );
322+ ostrm << " , witness_script=" << dump_hex (out->witness_script ,
323+ out->witness_script_len );
324+ ostrm << " , keypaths=??, unknown=??" ;
325+ ostrm << " }" ;
326+ return ostrm.str ();
327+
328+ }
329+
330+ string dump_wally_psbt_outputs (const struct wally_psbt_output *outputs,
331+ size_t num_outputs)
292332{
293333 ostringstream ostrm;
294334 ostrm << " [" ;
295- for (size_t ii = 0 ; ii < tal_count (wp) ; ii++) {
335+ for (size_t ii = 0 ; ii < num_outputs ; ii++) {
296336 if (ii != 0 )
297337 ostrm << " ," ;
298- ostrm << (wp[ii] ?
299- dump_hex (wp[ii]->ptr , tal_count (wp[ii]->ptr )) :
300- " <none>" );
338+ ostrm << dump_wally_psbt_output (&outputs[ii]);
301339 }
302340 ostrm << " ]" ;
303341 return ostrm.str ();
304342}
305343
344+ string dump_wally_psbt (const struct wally_psbt *psbt)
345+ {
346+ ostringstream ostrm;
347+ ostrm << " { " ;
348+ ostrm << " tx=" << dump_wally_tx (psbt->tx );
349+ ostrm << " , inputs="
350+ << dump_wally_psbt_inputs (psbt->inputs , psbt->num_inputs );
351+ ostrm << " , outputs="
352+ << dump_wally_psbt_outputs (psbt->outputs , psbt->num_outputs );
353+ ostrm << " }" ;
354+ return ostrm.str ();
355+ }
356+
306357string dump_tx (const struct bitcoin_tx *tx)
307358{
308359 ostringstream ostrm;
309360 ostrm << " { " ;
310- ostrm << " input_amounts=" <<
311- dump_input_amounts (
312- (const struct amount_sat **)tx->input_amounts );
313- ostrm << " , wally_tx=" << dump_wally_tx (tx->wtx );
314- ostrm << " , output_witscripts=" <<
315- dump_output_witscripts (
316- (const struct witscript **)tx->output_witscripts );
361+ ostrm << " , wtx=" << dump_wally_tx (tx->wtx );
362+ ostrm << " , psbt=" << dump_wally_psbt (tx->psbt );
317363 ostrm << " }" ;
318364 return ostrm.str ();
319365}
0 commit comments