2WP: Refactor out GetAmountFromParentChainPegin

This commit is contained in:
Jorge Timón 2018-06-12 23:08:57 +02:00
parent 2be9cae539
commit a20986b40d
No known key found for this signature in database
GPG key ID: 8866C18EA1C944A2
2 changed files with 15 additions and 1 deletions

View file

@ -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<typename T>
static bool GetBlockAndTxFromMerkleBlock(uint256& block_hash, uint256& tx_hash, T& merkle_block, const std::vector<unsigned char>& merkle_block_raw)
{
@ -2405,7 +2411,10 @@ static bool CheckPeginTx(const std::vector<unsigned char>& 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;