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

Function DecomposePeginWitness

src/pegins.cpp:551–592  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

549}
550
551bool DecomposePeginWitness(const CScriptWitness& witness, CAmount& value, CAsset& asset, uint256& genesis_hash, CScript& claim_script, std::variant<std::monostate, Sidechain::Bitcoin::CTransactionRef, CTransactionRef>& tx, std::variant<std::monostate, Sidechain::Bitcoin::CMerkleBlock, CMerkleBlock>& merkle_block)
552{
553 const auto& stack = witness.stack;
554
555 if (stack.size() < 5) return false;
556
557 CDataStream stream(stack[0], SER_NETWORK, PROTOCOL_VERSION);
558 stream >> value;
559
560 CAsset tmp_asset(stack[1]);
561 asset = tmp_asset;
562
563 uint256 gh(stack[2]);
564 genesis_hash = gh;
565
566 CScript s(stack[3].begin(), stack[3].end());
567 claim_script = s;
568
569 CDataStream ss_tx(stack[4], SER_NETWORK, PROTOCOL_VERSION);
570 if (Params().GetConsensus().ParentChainHasPow()) {
571 Sidechain::Bitcoin::CTransactionRef btc_tx;
572 ss_tx >> btc_tx;
573 tx = btc_tx;
574 } else {
575 CTransactionRef elem_tx;
576 ss_tx >> elem_tx;
577 tx = elem_tx;
578 }
579
580 CDataStream ss_proof(stack[5], SER_NETWORK, PROTOCOL_VERSION);
581 if (Params().GetConsensus().ParentChainHasPow()) {
582 Sidechain::Bitcoin::CMerkleBlock tx_proof;
583 ss_proof >> tx_proof;
584 merkle_block = tx_proof;
585 } else {
586 CMerkleBlock tx_proof;
587 ss_proof >> tx_proof;
588 merkle_block = tx_proof;
589 }
590
591 return true;
592}

Callers 1

SetupFromTxMethod · 0.85

Calls 5

ParentChainHasPowMethod · 0.80
ParamsClass · 0.70
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected