MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / AddAndGetDestinationForScript

Function AddAndGetDestinationForScript

src/outputtype.cpp:76–100  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74}
75
76CTxDestination AddAndGetDestinationForScript(CKeyStore& keystore, const CScript& script, OutputType type)
77{
78 // Add script to keystore
79 keystore.AddCScript(script);
80 // Note that scripts over 520 bytes are not yet supported.
81 switch (type) {
82 case OutputType::LEGACY:
83 return CScriptID(script);
84 case OutputType::P2SH_SEGWIT:
85 case OutputType::BECH32: {
86 CTxDestination witdest = WitnessV0ScriptHash(script);
87 CScript witprog = GetScriptForDestination(witdest);
88 // Check if the resulting program is solvable (i.e. doesn't use an uncompressed key)
89 if (!IsSolvable(keystore, witprog)) return CScriptID(script);
90 // Add the redeemscript, so that P2WSH and P2SH-P2WSH outputs are recognized as ours.
91 keystore.AddCScript(witprog);
92 if (type == OutputType::BECH32) {
93 return witdest;
94 } else {
95 return CScriptID(witprog);
96 }
97 }
98 default: assert(false);
99 }
100}
101

Callers 2

addmultisigaddressFunction · 0.85
createmultisigFunction · 0.85

Calls 5

WitnessV0ScriptHashClass · 0.85
GetScriptForDestinationFunction · 0.85
IsSolvableFunction · 0.85
CScriptIDClass · 0.70
AddCScriptMethod · 0.45

Tested by

no test coverage detected