From 12ec8dc1373a6dad56a467d173bcb92b2ed64fc9 Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Fri, 15 Mar 2019 14:20:07 +0100 Subject: [PATCH] wally: Migrate the withdraw transaction Signed-off-by: Christian Decker --- common/withdraw_tx.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/common/withdraw_tx.c b/common/withdraw_tx.c index 092a392dd..0c2b12c38 100644 --- a/common/withdraw_tx.c +++ b/common/withdraw_tx.c @@ -1,4 +1,5 @@ #include "withdraw_tx.h" +#include #include #include #include @@ -20,18 +21,18 @@ struct bitcoin_tx *withdraw_tx(const tal_t *ctx, tx = tx_spending_utxos(ctx, utxos, bip32_base, !amount_sat_eq(change, AMOUNT_SAT(0))); - tx->output[0].amount = withdraw_amount; - tx->output[0].script = destination; + bitcoin_tx_add_output(tx, destination, &withdraw_amount); if (!amount_sat_eq(change, AMOUNT_SAT(0))) { const void *map[2]; map[0] = int2ptr(0); map[1] = int2ptr(1); - tx->output[1].script = scriptpubkey_p2wpkh(tx, changekey); - tx->output[1].amount = change; + bitcoin_tx_add_output(tx, scriptpubkey_p2wpkh(tx, changekey), + &change); permute_outputs(tx, NULL, map); } permute_inputs(tx, (const void **)utxos); + assert(bitcoin_tx_check(tx)); return tx; }