MCPcopy Create free account
hub / github.com/ElementsProject/elements / CreateSig

Method CreateSig

src/script/sign.cpp:39–62  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37}
38
39bool MutableTransactionSignatureCreator::CreateSig(const SigningProvider& provider, std::vector<unsigned char>& vchSig, const CKeyID& address, const CScript& scriptCode, SigVersion sigversion, unsigned int flags) const
40{
41 assert(sigversion == SigVersion::BASE || sigversion == SigVersion::WITNESS_V0);
42
43 CKey key;
44 if (!provider.GetKey(address, key))
45 return false;
46
47 // Signing with uncompressed keys is disabled in witness scripts
48 if (sigversion == SigVersion::WITNESS_V0 && !key.IsCompressed())
49 return false;
50
51 // Signing without known amount does not work in witness scripts.
52 if (sigversion == SigVersion::WITNESS_V0 && amount.IsNull()) return false;
53
54 // BASE/WITNESS_V0 signatures don't support explicit SIGHASH_DEFAULT, use SIGHASH_ALL instead.
55 const int hashtype = nHashType == SIGHASH_DEFAULT ? SIGHASH_ALL : nHashType;
56
57 uint256 hash = SignatureHash(scriptCode, *txTo, nIn, hashtype, amount, sigversion, flags, m_txdata);
58 if (!key.Sign(hash, vchSig))
59 return false;
60 vchSig.push_back((unsigned char)hashtype);
61 return true;
62}
63
64bool MutableTransactionSignatureCreator::CreateSchnorrSig(const SigningProvider& provider, std::vector<unsigned char>& sig, const XOnlyPubKey& pubkey, const uint256* leaf_hash, const uint256* merkle_root, SigVersion sigversion) const
65{

Callers 2

CreateSigFunction · 0.45
FUZZ_TARGET_INITFunction · 0.45

Calls 6

SignMethod · 0.80
SignatureHashFunction · 0.70
GetKeyMethod · 0.45
IsCompressedMethod · 0.45
IsNullMethod · 0.45
push_backMethod · 0.45

Tested by 1

FUZZ_TARGET_INITFunction · 0.36