From bd2573eafbae715c940af86b7fd7f95030ad9f9d Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Mon, 11 Mar 2019 11:10:43 +0100 Subject: [PATCH] wally: Build wally transactions in parallel with the old ones Signed-off-by: Christian Decker --- bitcoin/signature.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/bitcoin/signature.c b/bitcoin/signature.c index 655948265..5ff0c8820 100644 --- a/bitcoin/signature.c +++ b/bitcoin/signature.c @@ -109,12 +109,21 @@ void sign_tx_input(const struct bitcoin_tx *tx, enum sighash_type sighash_type, struct bitcoin_signature *sig) { - struct sha256_double hash; + struct sha256_double hash, whash; + int flags = witness_script != NULL ? WALLY_TX_FLAG_USE_WITNESS : 0; + const u8 *script = witness_script ? witness_script : subscript; assert(sighash_type_valid(sighash_type)); sig->sighash_type = sighash_type; + wally_tx_get_btc_signature_hash( + tx->wtx, in, script, tal_bytelen(script), + tx->input[in].amount->satoshis /* Raw: low-level helper */, + sighash_type, flags, whash.sha.u.u8, sizeof(whash)); sha256_tx_one_input(tx, in, subscript, witness_script, sighash_type, &hash); + + assert(memeq(&hash, sizeof(hash), &whash, sizeof(whash))); + dump_tx("Signing", tx, in, subscript, key, &hash); sign_hash(privkey, &hash, &sig->s); }