Browse Source

bitcoin: Add the interface to add multiple outputs to bitcoin transaction

pull/2803/head
trueptolemy 5 years ago
committed by neil saitug
parent
commit
6570c743c4
  1. 10
      bitcoin/tx.c
  2. 6
      bitcoin/tx.h

10
bitcoin/tx.c

@ -30,6 +30,16 @@ int bitcoin_tx_add_output(struct bitcoin_tx *tx, const u8 *script,
return i; 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, int bitcoin_tx_add_input(struct bitcoin_tx *tx, const struct bitcoin_txid *txid,
u32 outnum, u32 sequence, u32 outnum, u32 sequence,
struct amount_sat amount, u8 *script) struct amount_sat amount, u8 *script)

6
bitcoin/tx.h

@ -74,10 +74,14 @@ bool bitcoin_txid_to_hex(const struct bitcoin_txid *txid,
/* Internal de-linearization functions. */ /* Internal de-linearization functions. */
struct bitcoin_tx *pull_bitcoin_tx(const tal_t *ctx, struct bitcoin_tx *pull_bitcoin_tx(const tal_t *ctx,
const u8 **cursor, size_t *max); const u8 **cursor, size_t *max);
/* Add one output to tx. */
int bitcoin_tx_add_output(struct bitcoin_tx *tx, const u8 *script, int bitcoin_tx_add_output(struct bitcoin_tx *tx, const u8 *script,
struct amount_sat amount); 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, int bitcoin_tx_add_input(struct bitcoin_tx *tx, const struct bitcoin_txid *txid,
u32 outnum, u32 sequence, u32 outnum, u32 sequence,
struct amount_sat amount, u8 *script); struct amount_sat amount, u8 *script);

Loading…
Cancel
Save