MCPcopy Create free account
hub / github.com/LUX-Core/lux / AddAndGetDestinationForScript

Method AddAndGetDestinationForScript

src/wallet.cpp:4705–4729  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4703}
4704
4705CTxDestination CWallet::AddAndGetDestinationForScript(const CScript& script, OutputType type)
4706{
4707 // Note that scripts over 520 bytes are not yet supported.
4708 switch (type) {
4709 case OUTPUT_TYPE_LEGACY:
4710 return CScriptID(script);
4711 case OUTPUT_TYPE_P2SH_SEGWIT:
4712 case OUTPUT_TYPE_BECH32: {
4713 WitnessV0ScriptHash hash;
4714 CSHA256().Write(&script[0], script.size()).Finalize(hash.begin());
4715 CTxDestination witdest = hash;
4716 CScript witprog = GetScriptForDestination(witdest);
4717 // Check if the resulting program is solvable (i.e. doesn't use an uncompressed key)
4718 if (!IsSolvable(*this, witprog)) return CScriptID(script);
4719 // Add the redeemscript, so that P2WSH and P2SH-P2WSH outputs are recognized as ours.
4720 AddCScript(witprog);
4721 if (type == OUTPUT_TYPE_BECH32) {
4722 return witdest;
4723 } else {
4724 return CScriptID(witprog);
4725 }
4726 }
4727 default: assert(false);
4728 }
4729}
4730bool CWallet::SetContractBook(const string &strAddress, const string &strName, const string &strAbi)
4731{
4732 bool fUpdated = false;

Callers 1

addmultisigaddressFunction · 0.80

Calls 8

CSHA256Class · 0.85
GetScriptForDestinationFunction · 0.85
IsSolvableFunction · 0.85
CScriptIDClass · 0.70
FinalizeMethod · 0.45
WriteMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected