MCPcopy Create free account
hub / github.com/ElementsProject/lightning / check_tx_sig

Function check_tx_sig

bitcoin/signature.c:202–229  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

200}
201
202bool check_tx_sig(const struct bitcoin_tx *tx, size_t input_num,
203 const u8 *redeemscript,
204 const u8 *witness_script,
205 const struct pubkey *key,
206 const struct bitcoin_signature *sig)
207{
208 struct sha256_double hash;
209 bool use_segwit = witness_script != NULL;
210 const u8 *script = use_segwit ? witness_script : redeemscript;
211 bool ret;
212
213 /* We only support a limited subset of sighash types. */
214 if (sig->sighash_type != SIGHASH_ALL) {
215 if (!witness_script)
216 return false;
217 if (sig->sighash_type != (SIGHASH_SINGLE|SIGHASH_ANYONECANPAY))
218 return false;
219 }
220 assert(input_num < tx->wtx->num_inputs);
221
222 bitcoin_tx_hash_for_sig(tx, input_num, script, sig->sighash_type, &hash);
223 dump_tx("check_tx_sig", tx, input_num, script, key, &hash);
224
225 ret = check_signed_hash(&hash, &sig->s, key);
226 if (!ret)
227 dump_tx("Sig failed", tx, input_num, redeemscript, key, &hash);
228 return ret;
229}
230
231/* Stolen direct from bitcoin/src/script/sign.cpp:
232// Copyright (c) 2009-2010 Satoshi Nakamoto

Callers 11

receive_offerFunction · 0.85
grind_htlc_tx_feeFunction · 0.85
set_htlc_timeout_feeFunction · 0.85
set_htlc_success_feeFunction · 0.85
calc_commitsigsFunction · 0.85
handle_peer_commit_sigFunction · 0.85
fundee_channelFunction · 0.85
accepter_commitsFunction · 0.85
opener_commitsFunction · 0.85

Calls 3

bitcoin_tx_hash_for_sigFunction · 0.85
dump_txFunction · 0.85
check_signed_hashFunction · 0.85

Tested by

no test coverage detected