psbt: if a transaction has witnesses/scriptSig set, add it to psbt

For any transaction that's got 'finalized' signature data for an input,
we should add this information to the psbt also
This commit is contained in:
niftynei 2020-05-28 22:05:35 -05:00 committed by Christian Decker
parent 891f61ad48
commit 58282819a9

View file

@ -68,9 +68,26 @@ struct wally_psbt *new_psbt(const tal_t *ctx, const struct wally_tx *wtx)
/* set the scripts + witnesses back */ /* set the scripts + witnesses back */
for (size_t i = 0; i < wtx->num_inputs; i++) { for (size_t i = 0; i < wtx->num_inputs; i++) {
int wally_err;
wtx->inputs[i].script = (unsigned char *)scripts[i]; wtx->inputs[i].script = (unsigned char *)scripts[i];
wtx->inputs[i].script_len = script_lens[i]; wtx->inputs[i].script_len = script_lens[i];
wtx->inputs[i].witness = witnesses[i]; wtx->inputs[i].witness = witnesses[i];
/* add these scripts + witnesses to the psbt */
if (scripts[i]) {
wally_err =
wally_psbt_input_set_final_script_sig(&psbt->inputs[i],
(unsigned char *)scripts[i],
script_lens[i]);
assert(wally_err == WALLY_OK);
}
if (witnesses[i]) {
wally_err =
wally_psbt_input_set_final_witness(&psbt->inputs[i],
witnesses[i]);
assert(wally_err == WALLY_OK);
}
} }
tal_free(witnesses); tal_free(witnesses);