mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-22 14:42:40 +01:00
tx_parts: use wally to clone tx outputs
Input cloning has not been exposed yet; I'll add that to wally in a future release. Changelog-None Signed-off-by: Jon Griffiths <jon_p_griffiths@yahoo.com>
This commit is contained in:
parent
23a04d1bba
commit
2e670a2a62
1 changed files with 4 additions and 26 deletions
|
@ -48,31 +48,6 @@ static void destroy_wally_tx_output(struct wally_tx_output *out)
|
||||||
wally_tx_output_free(out);
|
wally_tx_output_free(out);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct wally_tx_output *clone_output(const struct wally_tx_output *src)
|
|
||||||
{
|
|
||||||
struct wally_tx_output *out;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
if (is_elements(chainparams)) {
|
|
||||||
ret = wally_tx_elements_output_init_alloc
|
|
||||||
(src->script, src->script_len,
|
|
||||||
src->asset, src->asset_len,
|
|
||||||
src->value, src->value_len,
|
|
||||||
src->nonce, src->nonce_len,
|
|
||||||
src->surjectionproof, src->surjectionproof_len,
|
|
||||||
src->rangeproof, src->rangeproof_len,
|
|
||||||
&out);
|
|
||||||
} else {
|
|
||||||
ret = wally_tx_output_init_alloc(src->satoshi,
|
|
||||||
src->script, src->script_len,
|
|
||||||
&out);
|
|
||||||
}
|
|
||||||
assert(ret == WALLY_OK);
|
|
||||||
|
|
||||||
tal_add_destructor(out, destroy_wally_tx_output);
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct tx_parts *tx_parts_from_wally_tx(const tal_t *ctx,
|
struct tx_parts *tx_parts_from_wally_tx(const tal_t *ctx,
|
||||||
const struct wally_tx *wtx,
|
const struct wally_tx *wtx,
|
||||||
int input, int output)
|
int input, int output)
|
||||||
|
@ -93,7 +68,10 @@ struct tx_parts *tx_parts_from_wally_tx(const tal_t *ctx,
|
||||||
for (size_t i = 0; i < wtx->num_outputs; i++) {
|
for (size_t i = 0; i < wtx->num_outputs; i++) {
|
||||||
if (output != -1 && output != i)
|
if (output != -1 && output != i)
|
||||||
continue;
|
continue;
|
||||||
txp->outputs[i] = clone_output(&wtx->outputs[i]);
|
if (wally_tx_output_clone_alloc(&wtx->outputs[i],
|
||||||
|
&txp->outputs[i]) != WALLY_OK)
|
||||||
|
abort();
|
||||||
|
tal_add_destructor(txp->outputs[i], destroy_wally_tx_output);
|
||||||
|
|
||||||
/* Cheat a bit by also setting the numeric satoshi
|
/* Cheat a bit by also setting the numeric satoshi
|
||||||
* value, otherwise we end up converting a
|
* value, otherwise we end up converting a
|
||||||
|
|
Loading…
Add table
Reference in a new issue