put burntx opreturn at end of vout and fix crash with import tx
This commit is contained in:
@@ -59,7 +59,7 @@ bool Eval::ImportCoin(const std::vector<uint8_t> params, const CTransaction &imp
|
|||||||
|
|
||||||
// check burn amount
|
// check burn amount
|
||||||
{
|
{
|
||||||
uint64_t burnAmount = burnTx.vout[0].nValue;
|
uint64_t burnAmount = burnTx.vout.back().nValue;
|
||||||
if (burnAmount == 0)
|
if (burnAmount == 0)
|
||||||
return Invalid("invalid-burn-amount");
|
return Invalid("invalid-burn-amount");
|
||||||
uint64_t totalOut = 0;
|
uint64_t totalOut = 0;
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ bool UnmarshalBurnTx(const CTransaction &burnTx, std::string &targetSymbol, uint
|
|||||||
{
|
{
|
||||||
std::vector<uint8_t> burnOpret;
|
std::vector<uint8_t> burnOpret;
|
||||||
if (burnTx.vout.size() == 0) return false;
|
if (burnTx.vout.size() == 0) return false;
|
||||||
GetOpReturnData(burnTx.vout[0].scriptPubKey, burnOpret);
|
GetOpReturnData(burnTx.vout.back().scriptPubKey, burnOpret);
|
||||||
return E_UNMARSHAL(burnOpret, ss >> VARINT(*targetCCid);
|
return E_UNMARSHAL(burnOpret, ss >> VARINT(*targetCCid);
|
||||||
ss >> targetSymbol;
|
ss >> targetSymbol;
|
||||||
ss >> payoutsHash);
|
ss >> payoutsHash);
|
||||||
@@ -61,7 +61,7 @@ CAmount GetCoinImportValue(const CTransaction &tx)
|
|||||||
CTransaction burnTx;
|
CTransaction burnTx;
|
||||||
std::vector<CTxOut> payouts;
|
std::vector<CTxOut> payouts;
|
||||||
if (UnmarshalImportTx(tx, proof, burnTx, payouts)) {
|
if (UnmarshalImportTx(tx, proof, burnTx, payouts)) {
|
||||||
return burnTx.vout.size() ? burnTx.vout[0].nValue : 0;
|
return burnTx.vout.size() ? burnTx.vout.back().nValue : 0;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
17
src/main.cpp
17
src/main.cpp
@@ -1547,14 +1547,17 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
|
|||||||
KOMODO_ON_DEMAND++;
|
KOMODO_ON_DEMAND++;
|
||||||
pool.addUnchecked(hash, entry, !IsInitialBlockDownload());
|
pool.addUnchecked(hash, entry, !IsInitialBlockDownload());
|
||||||
|
|
||||||
// Add memory address index
|
if (!tx.IsCoinImport())
|
||||||
if (fAddressIndex) {
|
{
|
||||||
pool.addAddressIndex(entry, view);
|
// Add memory address index
|
||||||
}
|
if (fAddressIndex) {
|
||||||
|
pool.addAddressIndex(entry, view);
|
||||||
|
}
|
||||||
|
|
||||||
// Add memory spent index
|
// Add memory spent index
|
||||||
if (fSpentIndex) {
|
if (fSpentIndex) {
|
||||||
pool.addSpentIndex(entry, view);
|
pool.addSpentIndex(entry, view);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -180,7 +180,7 @@ TEST_F(TestCoinImport, testInvalidBurnOutputs)
|
|||||||
|
|
||||||
TEST_F(TestCoinImport, testInvalidBurnParams)
|
TEST_F(TestCoinImport, testInvalidBurnParams)
|
||||||
{
|
{
|
||||||
burnTx.vout[0].scriptPubKey = CScript() << OP_RETURN << E_MARSHAL(ss << VARINT(testCcid));
|
burnTx.vout.back().scriptPubKey = CScript() << OP_RETURN << E_MARSHAL(ss << VARINT(testCcid));
|
||||||
MoMoM = burnTx.GetHash(); // TODO: an actual branch
|
MoMoM = burnTx.GetHash(); // TODO: an actual branch
|
||||||
CTransaction tx = MakeImportCoinTransaction(proof, CTransaction(burnTx), payouts);
|
CTransaction tx = MakeImportCoinTransaction(proof, CTransaction(burnTx), payouts);
|
||||||
TestRunCCEval(tx);
|
TestRunCCEval(tx);
|
||||||
@@ -198,7 +198,7 @@ TEST_F(TestCoinImport, testWrongChainId)
|
|||||||
|
|
||||||
TEST_F(TestCoinImport, testInvalidBurnAmount)
|
TEST_F(TestCoinImport, testInvalidBurnAmount)
|
||||||
{
|
{
|
||||||
burnTx.vout[0].nValue = 0;
|
burnTx.vout.back().nValue = 0;
|
||||||
MoMoM = burnTx.GetHash(); // TODO: an actual branch
|
MoMoM = burnTx.GetHash(); // TODO: an actual branch
|
||||||
CTransaction tx = MakeImportCoinTransaction(proof, CTransaction(burnTx), payouts);
|
CTransaction tx = MakeImportCoinTransaction(proof, CTransaction(burnTx), payouts);
|
||||||
TestRunCCEval(tx);
|
TestRunCCEval(tx);
|
||||||
|
|||||||
Reference in New Issue
Block a user