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

Function GetScriptForWitness

src/script/standard.cpp:514–530  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

512}
513
514CScript GetScriptForWitness(const CScript& redeemscript)
515{
516 CScript ret;
517
518 txnouttype typ;
519 std::vector<std::vector<unsigned char> > vSolutions;
520 if (Solver(redeemscript, typ, vSolutions)) {
521 if (typ == TX_PUBKEY) {
522 return GetScriptForDestination(WitnessV0KeyHash(Hash160(vSolutions[0].begin(), vSolutions[0].end())));
523 } else if (typ == TX_PUBKEYHASH) {
524 return GetScriptForDestination(WitnessV0KeyHash(vSolutions[0]));
525 }
526 }
527 uint256 hash;
528 CSHA256().Write(&redeemscript[0], redeemscript.size()).Finalize(hash.begin());
529 return GetScriptForDestination(WitnessV0ScriptHash(hash));
530}
531
532bool IsValidDestination(const CTxDestination& dest) {
533 return dest.which() != 0;

Callers 4

createwitnessaddressFunction · 0.85
signrawtransactionFunction · 0.85
BOOST_AUTO_TEST_CASEFunction · 0.85
BOOST_AUTO_TEST_CASEFunction · 0.85

Calls 11

SolverFunction · 0.85
GetScriptForDestinationFunction · 0.85
WitnessV0KeyHashClass · 0.85
Hash160Function · 0.85
CSHA256Class · 0.85
WitnessV0ScriptHashClass · 0.85
beginMethod · 0.45
endMethod · 0.45
FinalizeMethod · 0.45
WriteMethod · 0.45
sizeMethod · 0.45

Tested by 2

BOOST_AUTO_TEST_CASEFunction · 0.68
BOOST_AUTO_TEST_CASEFunction · 0.68