mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 21:35:11 +01:00
common/withdraw_tx: tell caller where we put the change output.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
09d9abf12e
commit
92da5ef5f4
@ -10,11 +10,12 @@
|
||||
|
||||
struct bitcoin_tx *withdraw_tx(const tal_t *ctx,
|
||||
const struct utxo **utxos,
|
||||
u8 *destination,
|
||||
const u8 *destination,
|
||||
struct amount_sat withdraw_amount,
|
||||
const struct pubkey *changekey,
|
||||
struct amount_sat change,
|
||||
const struct ext_key *bip32_base)
|
||||
const struct ext_key *bip32_base,
|
||||
int *change_outnum)
|
||||
{
|
||||
struct bitcoin_tx *tx;
|
||||
|
||||
@ -30,7 +31,10 @@ struct bitcoin_tx *withdraw_tx(const tal_t *ctx,
|
||||
bitcoin_tx_add_output(tx, scriptpubkey_p2wpkh(tx, changekey),
|
||||
&change);
|
||||
permute_outputs(tx, NULL, map);
|
||||
}
|
||||
if (change_outnum)
|
||||
*change_outnum = ptr2int(map[1]);
|
||||
} else if (change_outnum)
|
||||
*change_outnum = -1;
|
||||
permute_inputs(tx, (const void **)utxos);
|
||||
assert(bitcoin_tx_check(tx));
|
||||
return tx;
|
||||
|
@ -22,13 +22,15 @@ struct utxo;
|
||||
* @changekey: (in) key to send change to (only used if change_satoshis != 0).
|
||||
* @change: (in) amount to send as change.
|
||||
* @bip32_base: (in) bip32 base for key derivation, or NULL.
|
||||
* @change_outnum: (out) set to output index of change output or -1 if none, unless NULL.
|
||||
*/
|
||||
struct bitcoin_tx *withdraw_tx(const tal_t *ctx,
|
||||
const struct utxo **utxos,
|
||||
u8 *destination,
|
||||
const u8 *destination,
|
||||
struct amount_sat withdraw_amount,
|
||||
const struct pubkey *changekey,
|
||||
struct amount_sat change,
|
||||
const struct ext_key *bip32_base);
|
||||
const struct ext_key *bip32_base,
|
||||
int *change_outnum);
|
||||
|
||||
#endif /* LIGHTNING_COMMON_WITHDRAW_TX_H */
|
||||
|
@ -1456,7 +1456,7 @@ static struct io_plan *handle_sign_withdrawal_tx(struct io_conn *conn,
|
||||
pubkey_from_der(ext.pub_key, sizeof(ext.pub_key), &changekey);
|
||||
tx = withdraw_tx(tmpctx, cast_const2(const struct utxo **, utxos),
|
||||
scriptpubkey, satoshi_out,
|
||||
&changekey, change_out, NULL);
|
||||
&changekey, change_out, NULL, NULL);
|
||||
|
||||
sign_all_inputs(tx, utxos);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user