psbt: add serialize to/from wire for psbts

This commit is contained in:
niftynei
2020-05-21 13:27:41 +09:30
committed by Rusty Russell
parent 5d0fc176e8
commit 559f88faa1
20 changed files with 168 additions and 1 deletions

View File

@@ -652,6 +652,10 @@ struct bitcoin_tx *fromwire_bitcoin_tx(const tal_t *ctx,
if (!tx)
return fromwire_fail(cursor, max);
/* pull_bitcoin_tx sets the psbt */
tal_free(tx->psbt);
tx->psbt = fromwire_psbt(tx, cursor, max);
input_amts_len = fromwire_u16(cursor, max);
/* They must give us none or all */
@@ -682,6 +686,7 @@ void towire_bitcoin_tx(u8 **pptr, const struct bitcoin_tx *tx)
u8 *lin = linearize_tx(tmpctx, tx);
towire_u8_array(pptr, lin, tal_count(lin));
towire_psbt(pptr, tx->psbt);
/* We only want to 'save' the amounts if every amount
* has been populated */
for (i = 0; i < tal_count(tx->input_amounts); i++) {