MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / CreateSig

Method CreateSig

src/script/sign.cpp:53–76  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

51}
52
53bool MutableTransactionSignatureCreator::CreateSig(const SigningProvider& provider, std::vector<unsigned char>& vchSig, const CKeyID& address, const CScript& scriptCode, SigVersion sigversion) const
54{
55 assert(sigversion == SigVersion::BASE || sigversion == SigVersion::WITNESS_V0);
56
57 CKey key;
58 if (!provider.GetKey(address, key))
59 return false;
60
61 // Signing with uncompressed keys is disabled in witness scripts
62 if (sigversion == SigVersion::WITNESS_V0 && !key.IsCompressed())
63 return false;
64
65 // Signing without known amount does not work in witness scripts.
66 if (sigversion == SigVersion::WITNESS_V0 && !MoneyRange(amount)) return false;
67
68 // BASE/WITNESS_V0 signatures don't support explicit SIGHASH_DEFAULT, use SIGHASH_ALL instead.
69 const int hashtype = m_options.sighash_type == SIGHASH_DEFAULT ? SIGHASH_ALL : m_options.sighash_type;
70
71 uint256 hash = SignatureHash(scriptCode, m_txto, nIn, hashtype, amount, sigversion, m_txdata);
72 if (!key.Sign(hash, vchSig))
73 return false;
74 vchSig.push_back((unsigned char)hashtype);
75 return true;
76}
77
78std::optional<uint256> MutableTransactionSignatureCreator::ComputeSchnorrSignatureHash(const uint256* leaf_hash, SigVersion sigversion) const
79{

Callers 2

CreateSigFunction · 0.45
script_sign.cppFile · 0.45

Calls 6

MoneyRangeFunction · 0.85
SignatureHashFunction · 0.85
GetKeyMethod · 0.45
IsCompressedMethod · 0.45
SignMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected