Skip to content

Commit 6fffba0

Browse files
jgriffithscdecker
authored andcommitted
tx_parts: use wally to clone tx inputs
Changelog-None Signed-off-by: Jon Griffiths <[email protected]>
1 parent a3d7f05 commit 6fffba0

File tree

1 file changed

+4
-34
lines changed

1 file changed

+4
-34
lines changed

bitcoin/tx_parts.c

Lines changed: 4 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -10,39 +10,6 @@ static void destroy_wally_tx_input(struct wally_tx_input *in)
1010
wally_tx_input_free(in);
1111
}
1212

13-
static struct wally_tx_input *clone_input(const struct wally_tx_input *src)
14-
{
15-
struct wally_tx_input *in;
16-
int ret;
17-
18-
if (is_elements(chainparams)) {
19-
ret = wally_tx_elements_input_init_alloc
20-
(src->txhash, sizeof(src->txhash),
21-
src->index, src->sequence,
22-
src->script, src->script_len,
23-
src->witness,
24-
src->blinding_nonce, sizeof(src->blinding_nonce),
25-
src->entropy, sizeof(src->entropy),
26-
src->issuance_amount, src->issuance_amount_len,
27-
src->inflation_keys, src->inflation_keys_len,
28-
src->issuance_amount_rangeproof,
29-
src->issuance_amount_rangeproof_len,
30-
src->inflation_keys_rangeproof,
31-
src->inflation_keys_rangeproof_len,
32-
src->pegin_witness,
33-
&in);
34-
} else {
35-
ret = wally_tx_input_init_alloc(src->txhash, sizeof(src->txhash),
36-
src->index, src->sequence,
37-
src->script, src->script_len,
38-
src->witness, &in);
39-
}
40-
assert(ret == WALLY_OK);
41-
42-
tal_add_destructor(in, destroy_wally_tx_input);
43-
return in;
44-
}
45-
4613
static void destroy_wally_tx_output(struct wally_tx_output *out)
4714
{
4815
wally_tx_output_free(out);
@@ -62,7 +29,10 @@ struct tx_parts *tx_parts_from_wally_tx(const tal_t *ctx,
6229
for (size_t i = 0; i < wtx->num_inputs; i++) {
6330
if (input != -1 && input != i)
6431
continue;
65-
txp->inputs[i] = clone_input(&wtx->inputs[i]);
32+
if (wally_tx_input_clone_alloc(&wtx->inputs[i],
33+
&txp->inputs[i]) != WALLY_OK)
34+
abort();
35+
tal_add_destructor(txp->inputs[i], destroy_wally_tx_input);
6636
}
6737

6838
for (size_t i = 0; i < wtx->num_outputs; i++) {

0 commit comments

Comments
 (0)