diff --git a/bitcoin/tx.c b/bitcoin/tx.c index 7877615f6..84f674381 100644 --- a/bitcoin/tx.c +++ b/bitcoin/tx.c @@ -30,6 +30,16 @@ int bitcoin_tx_add_output(struct bitcoin_tx *tx, const u8 *script, return i; } +int bitcoin_tx_add_multi_outputs(struct bitcoin_tx *tx, + struct bitcoin_tx_output **outputs) +{ + for (size_t j = 0; j < tal_count(outputs); j++) + bitcoin_tx_add_output(tx, outputs[j]->script, + outputs[j]->amount); + + return tx->wtx->num_outputs; +} + int bitcoin_tx_add_input(struct bitcoin_tx *tx, const struct bitcoin_txid *txid, u32 outnum, u32 sequence, struct amount_sat amount, u8 *script) diff --git a/bitcoin/tx.h b/bitcoin/tx.h index d8b4c9dc5..da9df2a97 100644 --- a/bitcoin/tx.h +++ b/bitcoin/tx.h @@ -74,10 +74,14 @@ bool bitcoin_txid_to_hex(const struct bitcoin_txid *txid, /* Internal de-linearization functions. */ struct bitcoin_tx *pull_bitcoin_tx(const tal_t *ctx, const u8 **cursor, size_t *max); - +/* Add one output to tx. */ int bitcoin_tx_add_output(struct bitcoin_tx *tx, const u8 *script, struct amount_sat amount); +/* Add mutiple output to tx. */ +int bitcoin_tx_add_multi_outputs(struct bitcoin_tx *tx, + struct bitcoin_tx_output **outputs); + int bitcoin_tx_add_input(struct bitcoin_tx *tx, const struct bitcoin_txid *txid, u32 outnum, u32 sequence, struct amount_sat amount, u8 *script);