mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-03 18:57:06 +01:00
wally: Migrate the funding transaction
Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
parent
3937b17e2b
commit
710a2abc5f
1 changed files with 6 additions and 3 deletions
|
@ -1,4 +1,5 @@
|
|||
#include "funding_tx.h"
|
||||
#include <assert.h>
|
||||
#include <bitcoin/pubkey.h>
|
||||
#include <bitcoin/script.h>
|
||||
#include <bitcoin/tx.h>
|
||||
|
@ -22,9 +23,10 @@ struct bitcoin_tx *funding_tx(const tal_t *ctx,
|
|||
{
|
||||
u8 *wscript;
|
||||
struct bitcoin_tx *tx;
|
||||
bool has_change = !amount_sat_eq(change, AMOUNT_SAT(0));
|
||||
|
||||
tx = tx_spending_utxos(ctx, utxomap, bip32_base, has_change);
|
||||
|
||||
tx = tx_spending_utxos(ctx, utxomap, bip32_base,
|
||||
!amount_sat_eq(change, AMOUNT_SAT(0)));
|
||||
|
||||
wscript = bitcoin_redeem_2of2(tx, local_fundingkey, remote_fundingkey);
|
||||
SUPERVERBOSE("# funding witness script = %s\n",
|
||||
|
@ -32,7 +34,7 @@ struct bitcoin_tx *funding_tx(const tal_t *ctx,
|
|||
bitcoin_tx_add_output(tx, scriptpubkey_p2wsh(tx, wscript), &funding);
|
||||
tal_free(wscript);
|
||||
|
||||
if (!amount_sat_eq(change, AMOUNT_SAT(0))) {
|
||||
if (has_change) {
|
||||
const void *map[2];
|
||||
map[0] = int2ptr(0);
|
||||
map[1] = int2ptr(1);
|
||||
|
@ -45,5 +47,6 @@ struct bitcoin_tx *funding_tx(const tal_t *ctx,
|
|||
}
|
||||
|
||||
permute_inputs(tx, (const void **)utxomap);
|
||||
assert(bitcoin_tx_check(tx));
|
||||
return tx;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue