mirror of
https://github.com/aljazceru/lightning.git
synced 2026-01-09 00:54:22 +01:00
psbt: wipe global tx scriptSig/witness data after saved to PSBT
The global tx should be "free from sin" (no scriptSig data, no witness stacks).
This commit is contained in:
@@ -90,12 +90,21 @@ struct wally_psbt *new_psbt(const tal_t *ctx, const struct wally_tx *wtx)
|
||||
wtx->inputs[i].script,
|
||||
wtx->inputs[i].script_len);
|
||||
assert(wally_err == WALLY_OK);
|
||||
|
||||
/* Clear out script sig data */
|
||||
psbt->tx->inputs[i].script_len = 0;
|
||||
tal_free(psbt->tx->inputs[i].script);
|
||||
psbt->tx->inputs[i].script = NULL;
|
||||
}
|
||||
if (wtx->inputs[i].witness) {
|
||||
wally_err =
|
||||
wally_psbt_input_set_final_witness(&psbt->inputs[i],
|
||||
wtx->inputs[i].witness);
|
||||
assert(wally_err == WALLY_OK);
|
||||
|
||||
/* Delete the witness data */
|
||||
wally_tx_witness_stack_free(psbt->tx->inputs[i].witness);
|
||||
psbt->tx->inputs[i].witness = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -101,9 +101,12 @@ int main(int argc, char *argv[])
|
||||
|
||||
tx2 = fromwire_bitcoin_tx(tmpctx,
|
||||
cast_const2(const u8 **, &msg), &len);
|
||||
assert(tx2 != NULL);
|
||||
|
||||
/* FIXME: this should not be null! */
|
||||
assert(tx2 == NULL);
|
||||
/* Witness/scriptsig data is saved down into psbt */
|
||||
assert(tx2->psbt->num_inputs == 1);
|
||||
assert(tx2->psbt->inputs[0].final_scriptsig_len > 0);
|
||||
assert(tx2->psbt->inputs[0].final_witness != NULL);
|
||||
|
||||
common_shutdown();
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user