mirror of
https://github.com/aljazceru/lightning.git
synced 2026-01-08 16:44:22 +01:00
psbt: return NULL instead of aborting on wally-lib problems
This lets us parse invalid/bad psbt data from user input without crashing
This commit is contained in:
committed by
Christian Decker
parent
5ecacf3dd0
commit
09815c7e7f
21
bitcoin/tx.c
21
bitcoin/tx.c
@@ -502,17 +502,22 @@ struct bitcoin_tx *bitcoin_tx_with_psbt(const tal_t *ctx, struct wally_psbt *psb
|
||||
* data, not the global tx. But 'finalizing' a tx destroys some fields
|
||||
* so we 'clone' it first and then finalize it */
|
||||
if (wally_psbt_clone(psbt, &tmppsbt) != WALLY_OK)
|
||||
abort();
|
||||
return NULL;
|
||||
|
||||
if (wally_finalize_psbt(tmppsbt) != WALLY_OK)
|
||||
abort();
|
||||
if (wally_finalize_psbt(tmppsbt) != WALLY_OK) {
|
||||
wally_psbt_free(tmppsbt);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (psbt_is_finalized(tmppsbt)) {
|
||||
if (wally_extract_psbt(tmppsbt, &tx->wtx) != WALLY_OK)
|
||||
abort();
|
||||
} else if (wally_tx_clone(psbt->tx, &tx->wtx) != WALLY_OK)
|
||||
abort();
|
||||
|
||||
if (wally_extract_psbt(tmppsbt, &tx->wtx) != WALLY_OK) {
|
||||
wally_psbt_free(tmppsbt);
|
||||
return NULL;
|
||||
}
|
||||
} else if (wally_tx_clone(psbt->tx, &tx->wtx) != WALLY_OK) {
|
||||
wally_psbt_free(tmppsbt);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
wally_psbt_free(tmppsbt);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user