mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
wally: Migrate the withdraw transaction
Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
committed by
Rusty Russell
parent
710a2abc5f
commit
12ec8dc137
@@ -1,4 +1,5 @@
|
|||||||
#include "withdraw_tx.h"
|
#include "withdraw_tx.h"
|
||||||
|
#include <assert.h>
|
||||||
#include <bitcoin/pubkey.h>
|
#include <bitcoin/pubkey.h>
|
||||||
#include <bitcoin/script.h>
|
#include <bitcoin/script.h>
|
||||||
#include <ccan/ptrint/ptrint.h>
|
#include <ccan/ptrint/ptrint.h>
|
||||||
@@ -20,18 +21,18 @@ struct bitcoin_tx *withdraw_tx(const tal_t *ctx,
|
|||||||
tx = tx_spending_utxos(ctx, utxos, bip32_base,
|
tx = tx_spending_utxos(ctx, utxos, bip32_base,
|
||||||
!amount_sat_eq(change, AMOUNT_SAT(0)));
|
!amount_sat_eq(change, AMOUNT_SAT(0)));
|
||||||
|
|
||||||
tx->output[0].amount = withdraw_amount;
|
bitcoin_tx_add_output(tx, destination, &withdraw_amount);
|
||||||
tx->output[0].script = destination;
|
|
||||||
|
|
||||||
if (!amount_sat_eq(change, AMOUNT_SAT(0))) {
|
if (!amount_sat_eq(change, AMOUNT_SAT(0))) {
|
||||||
const void *map[2];
|
const void *map[2];
|
||||||
map[0] = int2ptr(0);
|
map[0] = int2ptr(0);
|
||||||
map[1] = int2ptr(1);
|
map[1] = int2ptr(1);
|
||||||
tx->output[1].script = scriptpubkey_p2wpkh(tx, changekey);
|
bitcoin_tx_add_output(tx, scriptpubkey_p2wpkh(tx, changekey),
|
||||||
tx->output[1].amount = change;
|
&change);
|
||||||
permute_outputs(tx, NULL, map);
|
permute_outputs(tx, NULL, map);
|
||||||
}
|
}
|
||||||
permute_inputs(tx, (const void **)utxos);
|
permute_inputs(tx, (const void **)utxos);
|
||||||
|
assert(bitcoin_tx_check(tx));
|
||||||
return tx;
|
return tx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user