builder: Handle `std::ios_base::failure` exceptions during sighash

These can occur if e.g. `PrecomputedTransactionData` encounters an error
during parsing of its inputs on the Rust side.
This commit is contained in:
Jack Grigg 2022-03-28 19:44:07 +00:00
parent 8b68d73802
commit 52e039ebd8
1 changed files with 3 additions and 0 deletions

View File

@ -640,6 +640,9 @@ TransactionBuilderResult TransactionBuilder::Build()
const PrecomputedTransactionData txdata(mtx, tIns);
dataToBeSigned = SignatureHash(scriptCode, mtx, NOT_AN_INPUT, SIGHASH_ALL, 0, consensusBranchId, txdata);
}
} catch (std::ios_base::failure ex) {
librustzcash_sapling_proving_ctx_free(ctx);
return TransactionBuilderResult("Could not construct signature hash: " + std::string(ex.what()));
} catch (std::logic_error ex) {
librustzcash_sapling_proving_ctx_free(ctx);
return TransactionBuilderResult("Could not construct signature hash: " + std::string(ex.what()));