Only use chainparams to access BITCOINID as pegged_asset

This commit is contained in:
Gregory Sanders 2017-08-09 16:32:45 -04:00
parent 000ab241f7
commit ae1f058433
17 changed files with 62 additions and 56 deletions

View file

@ -69,9 +69,6 @@ struct CAsset {
}
};
/** The sha256 of Bitcoin genesis block, for easy reference **/
static const CAsset BITCOINID(uint256S("09f663de96be771f50cab5ded00256ffe63773e2eaa9a604092951cc3d7c6621"));
/** Used for consensus fee and general wallet accounting*/
typedef std::map<CAsset, CAmount> CAmountMap;

View file

@ -3,6 +3,7 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "assetsdir.h"
#include "chainparams.h"
#include "tinyformat.h"
#include "utilstrencodings.h"
@ -47,7 +48,7 @@ void CAssetsDir::InitFromStrings(const std::vector<std::string>& assetsToInit)
SetHex(vAssets[0], vAssets[1]);
}
// Set "bitcoin" to the pegged asset for tests
Set(BITCOINID, AssetMetadata("bitcoin"));
Set(Params().GetConsensus().pegged_asset, AssetMetadata("bitcoin"));
}
CAsset CAssetsDir::GetAsset(const std::string& label) const

View file

@ -3,6 +3,7 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "bench.h"
#include "chainparams.h"
#include "wallet/wallet.h"
#include <boost/foreach.hpp>
@ -51,10 +52,10 @@ static void CoinSelection(benchmark::State& state)
std::set<std::pair<const CWalletTx*, unsigned int> > setCoinsRet;
CAmountMap nValueRet;
CAmountMap mapValue;
mapValue[BITCOINID] = 1003 * COIN;
mapValue[Params().GetConsensus().pegged_asset] = 1003 * COIN;
bool success = wallet.SelectCoinsMinConf(mapValue, 1, 6, 0, vCoins, setCoinsRet, nValueRet);
assert(success);
assert(nValueRet[BITCOINID] == 1003 * COIN);
assert(nValueRet[Params().GetConsensus().pegged_asset] == 1003 * COIN);
assert(setCoinsRet.size() == 2);
}
}

View file

@ -321,7 +321,7 @@ static void MutateTxAddOutPubKey(CMutableTransaction& tx, const std::string& str
}
// construct TxOut, append to transaction output list
CTxOut txout(BITCOINID, value, scriptPubKey);
CTxOut txout(Params().GetConsensus().pegged_asset, value, scriptPubKey);
tx.vout.push_back(txout);
}
@ -388,7 +388,7 @@ static void MutateTxAddOutMultiSig(CMutableTransaction& tx, const std::string& s
}
// construct TxOut, append to transaction output list
CTxOut txout(BITCOINID, value, scriptPubKey);
CTxOut txout(Params().GetConsensus().pegged_asset, value, scriptPubKey);
tx.vout.push_back(txout);
}
@ -415,7 +415,7 @@ static void MutateTxAddOutData(CMutableTransaction& tx, const std::string& strIn
std::vector<unsigned char> data = ParseHex(strData);
CTxOut txout(BITCOINID, value, CScript() << OP_RETURN << data);
CTxOut txout(Params().GetConsensus().pegged_asset, value, CScript() << OP_RETURN << data);
tx.vout.push_back(txout);
}

View file

@ -18,6 +18,9 @@
#include "chainparamsseeds.h"
/** The sha256 of Bitcoin genesis block, for easy reference **/
static const CAsset BITCOINID(uint256S("09f663de96be771f50cab5ded00256ffe63773e2eaa9a604092951cc3d7c6621"));
// Safer for users if they load incorrect parameters via arguments.
static std::vector<unsigned char> CommitToArguments(const Consensus::Params& params, const std::string& networkID, const CScript& signblockscript)
{

View file

@ -431,7 +431,7 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
if (amount > 0)
{
CTxOut txout(BITCOINID, amount, (CScript)std::vector<unsigned char>(24, 0));
CTxOut txout(Params().GetConsensus().pegged_asset, amount, (CScript)std::vector<unsigned char>(24, 0));
txDummy.vout.push_back(txout);
if (txout.IsDust(dustRelayFee))
fDust = true;
@ -545,7 +545,7 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
// Never create dust outputs; if we would, just add the dust to the fee.
if (nChange > 0 && nChange < MIN_CHANGE)
{
CTxOut txout(BITCOINID, nChange, (CScript)std::vector<unsigned char>(24, 0));
CTxOut txout(Params().GetConsensus().pegged_asset, nChange, (CScript)std::vector<unsigned char>(24, 0));
if (txout.IsDust(dustRelayFee))
{
if (CoinControlDialog::fSubtractFeeFromAmount) // dust-change will be raised until no dust

View file

@ -569,7 +569,7 @@ bool PaymentServer::processPaymentRequest(const PaymentRequestPlus& request, Sen
}
// Extract and check amounts
CTxOut txOut(BITCOINID, sendingTo.second, sendingTo.first);
CTxOut txOut(Params().GetConsensus().pegged_asset, sendingTo.second, sendingTo.first);
if (txOut.IsDust(dustRelayFee)) {
Q_EMIT message(tr("Payment request error"), tr("Requested payment amount of %1 is too small (considered dust).")
.arg(BitcoinUnits::formatWithUnit(optionsModel->getDisplayUnit(), sendingTo.second)),

View file

@ -56,8 +56,8 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, TransactionReco
strHTML += "<html><font face='verdana, arial, helvetica, sans-serif'>";
int64_t nTime = wtx.GetTxTime();
CAmount nCredit = wtx.GetCredit(ISMINE_ALL)[BITCOINID];
CAmount nDebit = wtx.GetDebit(ISMINE_ALL)[BITCOINID];
CAmount nCredit = wtx.GetCredit(ISMINE_ALL)[Params().GetConsensus().pegged_asset];
CAmount nDebit = wtx.GetDebit(ISMINE_ALL)[Params().GetConsensus().pegged_asset];
CAmount nNet = nCredit - nDebit;
strHTML += "<b>" + tr("Status") + ":</b> " + FormatTxStatus(wtx);
@ -132,7 +132,7 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, TransactionReco
//
// Coinbase
//
CAmount nUnmatured = wallet->GetCredit(wtx, ISMINE_ALL)[BITCOINID];
CAmount nUnmatured = wallet->GetCredit(wtx, ISMINE_ALL)[Params().GetConsensus().pegged_asset];
strHTML += "<b>" + tr("Credit") + ":</b> ";
if (wtx.IsInMainChain())
strHTML += BitcoinUnits::formatHtmlWithUnit(unit, nUnmatured)+ " (" + tr("matures in %n more block(s)", "", wtx.GetBlocksToMaturity()) + ")";
@ -205,13 +205,13 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, TransactionReco
if (fAllToMe)
{
// Payment to self
CAmount nChange = wtx.GetChange()[BITCOINID];
CAmount nChange = wtx.GetChange()[Params().GetConsensus().pegged_asset];
CAmount nValue = nCredit - nChange;
strHTML += "<b>" + tr("Total debit") + ":</b> " + BitcoinUnits::formatHtmlWithUnit(unit, -nValue) + "<br>";
strHTML += "<b>" + tr("Total credit") + ":</b> " + BitcoinUnits::formatHtmlWithUnit(unit, nValue) + "<br>";
}
CAmount nTxFee = wtx.tx->GetFee()[BITCOINID];
CAmount nTxFee = wtx.tx->GetFee()[Params().GetConsensus().pegged_asset];
if (nTxFee > 0)
strHTML += "<b>" + tr("Transaction fee") + ":</b> " + BitcoinUnits::formatHtmlWithUnit(unit, -nTxFee) + "<br>";
}
@ -222,7 +222,7 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, TransactionReco
//
BOOST_FOREACH(const CTxIn& txin, wtx.tx->vin)
if (wallet->IsMine(txin))
strHTML += "<b>" + tr("Debit") + ":</b> " + BitcoinUnits::formatHtmlWithUnit(unit, -wallet->GetDebit(txin, ISMINE_ALL)[BITCOINID]) + "<br>";
strHTML += "<b>" + tr("Debit") + ":</b> " + BitcoinUnits::formatHtmlWithUnit(unit, -wallet->GetDebit(txin, ISMINE_ALL)[Params().GetConsensus().pegged_asset]) + "<br>";
for (unsigned int i = 0; i < wtx.tx->vout.size(); i++)
if (wallet->IsMine(wtx.tx->vout[i]) & ISMINE_ALL)
strHTML += "<b>" + tr("Credit") + ":</b> " + BitcoinUnits::formatHtmlWithUnit(unit, wtx.GetOutputValueOut(i)) + "<br>";
@ -277,10 +277,10 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, TransactionReco
strHTML += "<hr><br>" + tr("Debug information") + "<br><br>";
BOOST_FOREACH(const CTxIn& txin, wtx.tx->vin)
if(wallet->IsMine(txin))
strHTML += "<b>" + tr("Debit") + ":</b> " + BitcoinUnits::formatHtmlWithUnit(unit, -wallet->GetDebit(txin, ISMINE_ALL)[BITCOINID]) + "<br>";
strHTML += "<b>" + tr("Debit") + ":</b> " + BitcoinUnits::formatHtmlWithUnit(unit, -wallet->GetDebit(txin, ISMINE_ALL)[Params().GetConsensus().pegged_asset]) + "<br>";
for (unsigned int i = 0; i < wtx.tx->vout.size(); i++)
if(wallet->IsMine(wtx.tx->vout[i]) & ISMINE_ALL)
strHTML += "<b>" + tr("Credit") + ":</b> " + BitcoinUnits::formatHtmlWithUnit(unit, wtx.GetCredit(i)[BITCOINID]) + "<br>";
strHTML += "<b>" + tr("Credit") + ":</b> " + BitcoinUnits::formatHtmlWithUnit(unit, wtx.GetCredit(i)[Params().GetConsensus().pegged_asset]) + "<br>";
strHTML += "<br><b>" + tr("Transaction") + ":</b><br>";
strHTML += GUIUtil::HtmlEscape(wtx.tx->ToString(), true);

View file

@ -36,8 +36,8 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *
{
QList<TransactionRecord> parts;
int64_t nTime = wtx.GetTxTime();
CAmount nCredit = wtx.GetCredit(ISMINE_ALL)[BITCOINID];
CAmount nDebit = wtx.GetDebit(ISMINE_ALL)[BITCOINID];
CAmount nCredit = wtx.GetCredit(ISMINE_ALL)[Params().GetConsensus().pegged_asset];
CAmount nDebit = wtx.GetDebit(ISMINE_ALL)[Params().GetConsensus().pegged_asset];
CAmount nNet = nCredit - nDebit;
uint256 hash = wtx.GetHash();
std::map<std::string, std::string> mapValue = wtx.mapValue;
@ -102,7 +102,7 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *
if (fAllFromMe && fAllToMe)
{
// Payment to self
CAmount nChange = wtx.GetChange()[BITCOINID];
CAmount nChange = wtx.GetChange()[Params().GetConsensus().pegged_asset];
parts.append(TransactionRecord(hash, nTime, TransactionRecord::SendToSelf, "",
-(nDebit - nChange), nCredit - nChange));
@ -113,7 +113,7 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *
//
// Debit
//
CAmount nTxFee = wtx.tx->GetFee()[BITCOINID];
CAmount nTxFee = wtx.tx->GetFee()[Params().GetConsensus().pegged_asset];
for (unsigned int nOut = 0; nOut < wtx.tx->vout.size(); nOut++)
{

View file

@ -72,17 +72,17 @@ CAmount WalletModel::getBalance(const CCoinControl *coinControl) const
return nBalance;
}
return wallet->GetBalance()[BITCOINID];
return wallet->GetBalance()[Params().GetConsensus().pegged_asset];
}
CAmount WalletModel::getUnconfirmedBalance() const
{
return wallet->GetUnconfirmedBalance()[BITCOINID];
return wallet->GetUnconfirmedBalance()[Params().GetConsensus().pegged_asset];
}
CAmount WalletModel::getImmatureBalance() const
{
return wallet->GetImmatureBalance()[BITCOINID];
return wallet->GetImmatureBalance()[Params().GetConsensus().pegged_asset];
}
bool WalletModel::haveWatchOnly() const
@ -92,17 +92,17 @@ bool WalletModel::haveWatchOnly() const
CAmount WalletModel::getWatchBalance() const
{
return wallet->GetWatchOnlyBalance()[BITCOINID];
return wallet->GetWatchOnlyBalance()[Params().GetConsensus().pegged_asset];
}
CAmount WalletModel::getWatchUnconfirmedBalance() const
{
return wallet->GetUnconfirmedWatchOnlyBalance()[BITCOINID];
return wallet->GetUnconfirmedWatchOnlyBalance()[Params().GetConsensus().pegged_asset];
}
CAmount WalletModel::getWatchImmatureBalance() const
{
return wallet->GetImmatureWatchOnlyBalance()[BITCOINID];
return wallet->GetImmatureWatchOnlyBalance()[Params().GetConsensus().pegged_asset];
}
void WalletModel::updateStatus()
@ -225,7 +225,7 @@ WalletModel::SendCoinsReturn WalletModel::prepareTransaction(WalletModelTransact
const unsigned char* scriptStr = (const unsigned char*)out.script().data();
CScript scriptPubKey(scriptStr, scriptStr+out.script().size());
CAmount nAmount = out.amount();
CRecipient recipient = {scriptPubKey, nAmount, BITCOINID, CPubKey(), rcp.fSubtractFeeFromAmount};
CRecipient recipient = {scriptPubKey, nAmount, Params().GetConsensus().pegged_asset, CPubKey(), rcp.fSubtractFeeFromAmount};
vecSend.push_back(recipient);
}
if (subtotal <= 0)
@ -253,7 +253,7 @@ WalletModel::SendCoinsReturn WalletModel::prepareTransaction(WalletModelTransact
if (addr.IsBlinded()) {
confidentiality_pubkey = addr.GetBlindingKey();
}
CRecipient recipient = {scriptPubKey, rcp.amount, BITCOINID, confidentiality_pubkey, rcp.fSubtractFeeFromAmount};
CRecipient recipient = {scriptPubKey, rcp.amount, Params().GetConsensus().pegged_asset, confidentiality_pubkey, rcp.fSubtractFeeFromAmount};
vecSend.push_back(recipient);
total += rcp.amount;

View file

@ -3,6 +3,7 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "assetsdir.h"
#include "chainparams.h"
#include "test/test_bitcoin.h"
@ -15,7 +16,7 @@ BOOST_AUTO_TEST_CASE(assetsdirTests)
CAssetsDir tAssetsDir;
const std::string defaultPeggedLabel = "bitcoin";
const std::string defaultPeggedAssetHex = "09f663de96be771f50cab5ded00256ffe63773e2eaa9a604092951cc3d7c6621";
const CAsset defaultPeggedAsset = BITCOINID;
const CAsset defaultPeggedAsset = Params().GetConsensus().pegged_asset;
const std::string exampleAssetHex = "fa821b0be5e1387adbcb69dbb3ad33edb5e470831c7c938c4e7b344edbe8bb11";
const CAsset exampleAsset = CAsset(uint256S(exampleAssetHex));
const std::vector<std::string> protectedLabels = {"*", defaultPeggedLabel, "bitcoin", "Bitcoin", "btc"};

View file

@ -32,13 +32,13 @@ BOOST_AUTO_TEST_CASE(Getlocked_validity)
uint256 gen0 = uint256S("0");
CMutableTransaction mtx0;
mtx0.vout.push_back(CTxOut(CConfidentialAsset(BITCOINID), CConfidentialValue(1000), CScript() << OP_TRUE));
mtx0.vout.push_back(CTxOut(CConfidentialAsset(Params().GetConsensus().pegged_asset), CConfidentialValue(1000), CScript() << OP_TRUE));
CMutableTransaction mtx1;
mtx1.vout.push_back(CTxOut(CConfidentialAsset(BITCOINID), CConfidentialValue(100), CScript() << OP_TRUE));
mtx1.vout.push_back(CTxOut(CConfidentialAsset(Params().GetConsensus().pegged_asset), CConfidentialValue(100), CScript() << OP_TRUE));
CMutableTransaction mtx2;
mtx2.vout.push_back(CTxOut(CConfidentialAsset(BITCOINID), CConfidentialValue(10), CScript() << OP_TRUE));
mtx2.vout.push_back(CTxOut(CConfidentialAsset(Params().GetConsensus().pegged_asset), CConfidentialValue(10), CScript() << OP_TRUE));
CMutableTransaction mtx3;
mtx3.vout.push_back(CTxOut(CConfidentialAsset(BITCOINID), CConfidentialValue(1), CScript() << OP_TRUE));
mtx3.vout.push_back(CTxOut(CConfidentialAsset(Params().GetConsensus().pegged_asset), CConfidentialValue(1), CScript() << OP_TRUE));
//Push vout of size 1 for each CCoin
pcoinsTip->ModifyCoins(uint256S("0"))->FromTx(CTransaction(mtx0), 0);

View file

@ -2,6 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "chainparams.h"
#include "consensus/validation.h"
#include "data/sighash.json.h"
#include "hash.h"
@ -114,7 +115,7 @@ void static RandomTransaction(CMutableTransaction &tx, bool fSingle) {
tx.vout.push_back(CTxOut());
CTxOut &txout = tx.vout.back();
txout.nValue = insecure_rand() % 100000000;
txout.nAsset = BITCOINID;
txout.nAsset = Params().GetConsensus().pegged_asset;
RandomScript(txout.scriptPubKey);
}
}

View file

@ -7,6 +7,7 @@
#include "test/test_bitcoin.h"
#include "clientversion.h"
#include "chainparams.h"
#include "checkqueue.h"
#include "consensus/validation.h"
#include "core_io.h"
@ -305,19 +306,19 @@ SetupDummyInputs(CBasicKeyStore& keystoreRet, CCoinsViewCache& coinsRet)
dummyTransactions[0].vout.resize(2);
dummyTransactions[0].vout[0].nValue = 11*CENT;
dummyTransactions[0].vout[0].scriptPubKey << ToByteVector(key[0].GetPubKey()) << OP_CHECKSIG;
dummyTransactions[0].vout[0].nAsset = BITCOINID;
dummyTransactions[0].vout[0].nAsset = Params().GetConsensus().pegged_asset;
dummyTransactions[0].vout[1].nValue = 50*CENT;
dummyTransactions[0].vout[1].scriptPubKey << ToByteVector(key[1].GetPubKey()) << OP_CHECKSIG;
dummyTransactions[0].vout[1].nAsset = BITCOINID;
dummyTransactions[0].vout[1].nAsset = Params().GetConsensus().pegged_asset;
coinsRet.ModifyCoins(dummyTransactions[0].GetHash())->FromTx(dummyTransactions[0], 0);
dummyTransactions[1].vout.resize(2);
dummyTransactions[1].vout[0].nValue = 21*CENT;
dummyTransactions[1].vout[0].scriptPubKey = GetScriptForDestination(key[2].GetPubKey().GetID());
dummyTransactions[1].vout[0].nAsset = BITCOINID;
dummyTransactions[1].vout[0].nAsset = Params().GetConsensus().pegged_asset;
dummyTransactions[1].vout[1].nValue = 22*CENT;
dummyTransactions[1].vout[1].scriptPubKey = GetScriptForDestination(key[3].GetPubKey().GetID());
dummyTransactions[1].vout[1].nAsset = BITCOINID;
dummyTransactions[1].vout[1].nAsset = Params().GetConsensus().pegged_asset;
coinsRet.ModifyCoins(dummyTransactions[1].GetHash())->FromTx(dummyTransactions[1], 0);
return dummyTransactions;
@ -344,11 +345,11 @@ BOOST_AUTO_TEST_CASE(test_Get)
t1.vout.resize(2);
t1.vout[0].nValue = 90*CENT;
t1.vout[0].scriptPubKey << OP_1;
t1.vout[0].nAsset = BITCOINID;
t1.vout[0].nAsset = Params().GetConsensus().pegged_asset;
t1.vout[1].nValue = (50+21+22)*CENT - 90*CENT;
t1.vout[1].scriptPubKey = CScript();
t1.vout[1].nAsset = BITCOINID;
BOOST_CHECK(CTransaction(t1).GetFee()[BITCOINID] == (50+21+22)*CENT - 90*CENT);
t1.vout[1].nAsset = Params().GetConsensus().pegged_asset;
BOOST_CHECK(CTransaction(t1).GetFee()[Params().GetConsensus().pegged_asset] == (50+21+22)*CENT - 90*CENT);
BOOST_CHECK(AreInputsStandard(t1, coins));
BOOST_CHECK(VerifyAmounts(coins, t1));

View file

@ -2,6 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "chainparams.h"
#include "consensus/validation.h"
#include "key.h"
#include "validation.h"
@ -46,9 +47,9 @@ BOOST_FIXTURE_TEST_CASE(tx_mempool_block_doublespend, TestChain100Setup)
spends[i].vout.resize(2);
spends[i].vout[0].nValue = 11*CENT;
spends[i].vout[0].scriptPubKey = scriptPubKey;
spends[i].vout[0].nAsset = BITCOINID;
spends[i].vout[0].nAsset = Params().GetConsensus().pegged_asset;
spends[i].vout[1].nValue = MAX_MONEY/100-11*CENT;
spends[i].vout[1].nAsset = BITCOINID;
spends[i].vout[1].nAsset = Params().GetConsensus().pegged_asset;
spends[i].vout[1].scriptPubKey = CScript();
// Sign:

View file

@ -1697,7 +1697,7 @@ bool GetLockedOutputs(const uint256 &genesisHash, const CAmount &nAmount, std::v
}
// Only written locks are filtered previously for invalid type
if (txout.nValue.IsCommitment() || txout.nAsset.IsCommitment() || txout.nAsset.GetAsset() != BITCOINID) {
if (txout.nValue.IsCommitment() || txout.nAsset.IsCommitment() || txout.nAsset.GetAsset() != Params().GetConsensus().pegged_asset) {
continue;
}
@ -2526,7 +2526,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
vPos.push_back(std::make_pair(tx.GetHash(), pos));
for (unsigned int i = 0; i < tx.vout.size(); i++) {
CTxOut txout= tx.vout[i];
if (txout.scriptPubKey.IsWithdrawLock() && txout.nValue.IsExplicit() && txout.nAsset.IsExplicit() && txout.nAsset.GetAsset() == BITCOINID)
if (txout.scriptPubKey.IsWithdrawLock() && txout.nValue.IsExplicit() && txout.nAsset.IsExplicit() && txout.nAsset.GetAsset() == Params().GetConsensus().pegged_asset)
mLocksCreated.insert(std::make_pair(txout.scriptPubKey.GetWithdrawLockGenesisHash(), std::make_pair(COutPoint(tx.GetHash(), i), txout.nValue.GetAmount())));
}
@ -2718,7 +2718,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
for (unsigned int j = 0; j < tx.vout.size(); j++) {
CTxOut txout = tx.vout[j];
if (txout.scriptPubKey.IsWithdrawLock() && txout.nValue.IsExplicit() && txout.nAsset.IsExplicit() && txout.nAsset.GetAsset() == BITCOINID) {
if (txout.scriptPubKey.IsWithdrawLock() && txout.nValue.IsExplicit() && txout.nAsset.IsExplicit() && txout.nAsset.GetAsset() == Params().GetConsensus().pegged_asset) {
mLocksCreated.insert(std::make_pair(txout.scriptPubKey.GetWithdrawLockGenesisHash(), std::make_pair(COutPoint(tx.GetHash(), j), txout.nValue.GetAmount())));
}
}

View file

@ -3186,7 +3186,7 @@ UniValue bumpfee(const JSONRPCRequest& request)
}
// calculate the old fee and fee-rate
CAmount nOldFee = wtx.tx->GetFee()[BITCOINID];
CAmount nOldFee = wtx.tx->GetFee()[Params().GetConsensus().pegged_asset];
CFeeRate nOldFeeRate(nOldFee, txSize);
CAmount nNewFee;
CFeeRate nNewFeeRate;
@ -3576,7 +3576,7 @@ UniValue sendtomainchain(const JSONRPCRequest& request)
EnsureWalletIsUnlocked();
CWalletTx wtxNew;
SendMoney(scriptPubKey, nAmount, BITCOINID, false, CPubKey(), wtxNew, true);
SendMoney(scriptPubKey, nAmount, Params().GetConsensus().pegged_asset, false, CPubKey(), wtxNew, true);
std::string blinds;
for (unsigned int i=0; i<wtxNew.tx->vout.size(); i++) {
@ -3700,7 +3700,7 @@ UniValue claimpegin(const JSONRPCRequest& request)
throw JSONRPCError(RPC_VERIFY_REJECTED, "IsStandard rules prevent pegging-in > 0.105 million BTC reliably at a time - please work with your functionary to mine a large lock-merge transaction first");
//Pad the locked outputs by the IsStandard lock dust value
CTxOut dummyTxOut(BITCOINID, 0, relock_spk);
CTxOut dummyTxOut(Params().GetConsensus().pegged_asset, 0, relock_spk);
CAmount lockDust(dummyTxOut.GetDustThreshold(withdrawLockTxFee));
LOCK(cs_main);
@ -3714,7 +3714,7 @@ UniValue claimpegin(const JSONRPCRequest& request)
mtxn.vin.push_back(CTxIn(lockedUTXO[0].first.hash, lockedUTXO[0].first.n, CScript(), ~(uint32_t)0));
mtxn.vin.push_back(CTxIn(lockedUTXO[1].first.hash, lockedUTXO[1].first.n, CScript(), ~(uint32_t)0));
CAmount out_value = lockedUTXO[0].second + lockedUTXO[1].second;
mtxn.vout.push_back(CTxOut(BITCOINID, out_value, relock_spk));
mtxn.vout.push_back(CTxOut(Params().GetConsensus().pegged_asset, out_value, relock_spk));
CValidationState state;
bool fMissingInputs;
@ -3747,8 +3747,8 @@ UniValue claimpegin(const JSONRPCRequest& request)
//Build the transaction
CMutableTransaction mtxn;
CTxIn txin(utxo_txid, utxo_vout, scriptSig, ~(uint32_t)0);
CTxOut txout(BITCOINID, value, GetScriptForDestination(sidechainAddress.Get()));
CTxOut txrelock(BITCOINID, utxo_value - value, relock_spk);
CTxOut txout(Params().GetConsensus().pegged_asset, value, GetScriptForDestination(sidechainAddress.Get()));
CTxOut txrelock(Params().GetConsensus().pegged_asset, utxo_value - value, relock_spk);
mtxn.vin.push_back(txin);
mtxn.vout.push_back(txout);
mtxn.vout.push_back(txrelock);