mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-21 14:24:09 +01:00
bitcoin/psbt: wallt_tx_output needs a tal ctx.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
480f671e91
commit
607075a3d4
4 changed files with 10 additions and 7 deletions
|
@ -178,7 +178,7 @@ struct wally_psbt_output *psbt_append_output(struct wally_psbt *psbt,
|
|||
struct amount_sat amount)
|
||||
{
|
||||
struct wally_psbt_output *out;
|
||||
struct wally_tx_output *tx_out = wally_tx_output(script, amount);
|
||||
struct wally_tx_output *tx_out = wally_tx_output(NULL, script, amount);
|
||||
|
||||
out = psbt_add_output(psbt, tx_out, psbt->tx->num_outputs);
|
||||
wally_tx_output_free(tx_out);
|
||||
|
@ -190,7 +190,7 @@ struct wally_psbt_output *psbt_insert_output(struct wally_psbt *psbt,
|
|||
size_t insert_at)
|
||||
{
|
||||
struct wally_psbt_output *out;
|
||||
struct wally_tx_output *tx_out = wally_tx_output(script, amount);
|
||||
struct wally_tx_output *tx_out = wally_tx_output(NULL, script, amount);
|
||||
|
||||
out = psbt_add_output(psbt, tx_out, insert_at);
|
||||
wally_tx_output_free(tx_out);
|
||||
|
|
|
@ -26,7 +26,8 @@ struct bitcoin_tx_output *new_tx_output(const tal_t *ctx,
|
|||
return output;
|
||||
}
|
||||
|
||||
struct wally_tx_output *wally_tx_output(const u8 *script,
|
||||
struct wally_tx_output *wally_tx_output(const tal_t *ctx,
|
||||
const u8 *script,
|
||||
struct amount_sat amount)
|
||||
{
|
||||
u64 satoshis = amount.satoshis; /* Raw: wally API */
|
||||
|
@ -53,7 +54,7 @@ struct wally_tx_output *wally_tx_output(const u8 *script,
|
|||
if (ret != WALLY_OK)
|
||||
return NULL;
|
||||
}
|
||||
return output;
|
||||
return tal_steal(ctx, output);
|
||||
}
|
||||
|
||||
int bitcoin_tx_add_output(struct bitcoin_tx *tx, const u8 *script,
|
||||
|
@ -69,7 +70,7 @@ int bitcoin_tx_add_output(struct bitcoin_tx *tx, const u8 *script,
|
|||
assert(tx->wtx != NULL);
|
||||
assert(chainparams);
|
||||
|
||||
output = wally_tx_output(script, amount);
|
||||
output = wally_tx_output(NULL, script, amount);
|
||||
assert(output);
|
||||
ret = wally_tx_add_output(tx->wtx, output);
|
||||
assert(ret == WALLY_OK);
|
||||
|
|
|
@ -83,7 +83,8 @@ struct bitcoin_tx *pull_bitcoin_tx(const tal_t *ctx,
|
|||
/* Helper to create a wally_tx_output: make sure to wally_tx_output_free!
|
||||
* Returns NULL if amount is extreme (wally doesn't like).
|
||||
*/
|
||||
struct wally_tx_output *wally_tx_output(const u8 *script,
|
||||
struct wally_tx_output *wally_tx_output(const tal_t *ctx,
|
||||
const u8 *script,
|
||||
struct amount_sat amount);
|
||||
|
||||
/* Add one output to tx. */
|
||||
|
|
|
@ -178,7 +178,7 @@ static struct command_result *finish_txprepare(struct command *cmd,
|
|||
for (size_t i = 0; i < tal_count(txp->outputs); i++) {
|
||||
struct wally_tx_output *out;
|
||||
|
||||
out = wally_tx_output(txp->outputs[i].script,
|
||||
out = wally_tx_output(NULL, txp->outputs[i].script,
|
||||
txp->outputs[i].amount);
|
||||
if (!out)
|
||||
return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
|
||||
|
@ -189,6 +189,7 @@ static struct command_result *finish_txprepare(struct command *cmd,
|
|||
struct amount_sat,
|
||||
&txp->outputs[i].amount));
|
||||
psbt_add_output(txp->psbt, out, i);
|
||||
wally_tx_output_free(out);
|
||||
}
|
||||
|
||||
/* If this is elements, we should normalize
|
||||
|
|
Loading…
Add table
Reference in a new issue