mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-13 12:33:42 +02:00
2WP: Refactor out GetAmountFromParentChainPegin
This commit is contained in:
parent
2be9cae539
commit
a20986b40d
2 changed files with 15 additions and 1 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -32,6 +32,10 @@
|
|||
#include <boost/unordered_map.hpp>
|
||||
#include <boost/filesystem/path.hpp>
|
||||
|
||||
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 */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue