diff --git a/src/validation.cpp b/src/validation.cpp index c941553836..46bbd54186 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -2359,6 +2359,12 @@ CScript calculate_contract(const CScript& federationRedeemScript, const CScript& return scriptDestination; } +bool GetAmountFromParentChainPegin(CAmount& amount, const Sidechain::Bitcoin::CTransaction& txBTC, unsigned int nOut) +{ + amount = txBTC.vout[nOut].nValue; + return true; +} + template static bool GetBlockAndTxFromMerkleBlock(uint256& block_hash, uint256& tx_hash, T& merkle_block, const std::vector& merkle_block_raw) { @@ -2405,7 +2411,10 @@ static bool CheckPeginTx(const std::vector& tx_data, T& pegtx, co if (prevout.n >= pegtx->vout.size()) { return false; } - CAmount amount = pegtx->vout[prevout.n].nValue; + CAmount amount = 0; + if (!GetAmountFromParentChainPegin(amount, *pegtx, prevout.n)) { + return false; + } // Check the transaction nout/value matches if (claim_amount != amount) { return false; diff --git a/src/validation.h b/src/validation.h index 61d3425b8d..ded31539fc 100644 --- a/src/validation.h +++ b/src/validation.h @@ -32,6 +32,10 @@ #include #include +namespace Sidechain { namespace Bitcoin { +class CTransaction; +}} + class CBlockIndex; class CBlockTreeDB; class CBloomFilter; @@ -262,6 +266,7 @@ void UnloadBlockIndex(); void ThreadScriptCheck(); /** Check if bitcoind connection via RPC is correctly working*/ bool BitcoindRPCCheck(bool init); +bool GetAmountFromParentChainPegin(CAmount& amount, const Sidechain::Bitcoin::CTransaction& txBTC, unsigned int nOut); /** Checks pegin witness for validity */ bool IsValidPeginWitness(const CScriptWitness& pegin_witness, const COutPoint& prevout, bool check_depth = true); /** Extracts an output from pegin witness for evaluation as a normal output */