Skip to content

Commit

Permalink
Merge pull request KomodoPlatform#405 from VerusCoin/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Asherda authored May 2, 2022
2 parents bf5c5e9 + 301a880 commit 1c9adeb
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 5 deletions.
29 changes: 29 additions & 0 deletions src/pbaas/pbaas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1981,6 +1981,35 @@ bool PrecheckReserveTransfer(const CTransaction &tx, int32_t outNum, CValidation
(rt = CReserveTransfer(p.vData[0])).IsValid() &&
rt.TotalCurrencyOut().valueMap[ASSETCHAINS_CHAINID] == tx.vout[outNum].nValue)
{
// reserve transfers must be spendable by the export public / private key
CCcontract_info CC;
CCcontract_info *cp;

// make a currency definition
cp = CCinit(&CC, EVAL_RESERVE_TRANSFER);

bool haveRTKey = false;

CTxDestination RTKey = DecodeDestination(cp->unspendableCCaddr);
for (auto oneKey : p.vKeys)
{
if (oneKey == RTKey)
{
haveRTKey = true;
break;
}
}
COptCCParams master;
if (!haveRTKey ||
p.version < p.VERSION_V3 ||
p.m != 1 ||
p.vData.size() < 2 ||
!(master = COptCCParams(p.vData.back())).IsValid() ||
master.m > 1)
{
return state.Error("Reserve transfer must be spendable solely by private key of reserve transfer smart transaction " + rt.ToUniValue().write(1,2));
}

uint160 systemDestID, importCurrencyID;
CCurrencyDefinition systemDest, importCurrencyDef;

Expand Down
26 changes: 21 additions & 5 deletions src/rpc/pbaasrpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8794,7 +8794,7 @@ UniValue definecurrency(const UniValue& params, bool fHelp)
cp = CCinit(&CC, EVAL_RESERVE_TRANSFER);
CPubKey pk(ParseHex(CC.CChexstr));

dests = std::vector<CTxDestination>({pk});
dests = std::vector<CTxDestination>({pk.GetID()});

tb.AddTransparentOutput(MakeMofNCCScript(CConditionObj<CReserveTransfer>(EVAL_RESERVE_TRANSFER, dests, 1, &rt)),
newChain.currencies[i] == thisChainID ? contribution + fee : fee);
Expand Down Expand Up @@ -8947,7 +8947,7 @@ UniValue definecurrency(const UniValue& params, bool fHelp)
cp = CCinit(&CC, EVAL_RESERVE_TRANSFER);
CPubKey pk(ParseHex(CC.CChexstr));

dests = std::vector<CTxDestination>({pk});
dests = std::vector<CTxDestination>({pk.GetID()});

tb.AddTransparentOutput(MakeMofNCCScript(CConditionObj<CReserveTransfer>(EVAL_RESERVE_TRANSFER, dests, 1, &rt)),
newGatewayConverter.currencies[i] == thisChainID ? contribution + fee : fee);
Expand Down Expand Up @@ -9908,7 +9908,15 @@ UniValue registeridentity(const UniValue& params, bool fHelp)
issuerID,
DestinationToTransferDestination(CIdentityID(issuerID)));
registrationPaymentOut = outputs.size();
outputs.push_back({MakeMofNCCScript(CConditionObj<CReserveTransfer>(EVAL_RESERVE_TRANSFER, std::vector<CTxDestination>({CIdentityID(issuerID)}), 1, &rt)), ConnectedChains.ThisChain().IDImportFee(), false});

CCcontract_info CC;
CCcontract_info *cp;
cp = CCinit(&CC, EVAL_RESERVE_TRANSFER);
CPubKey pk(ParseHex(CC.CChexstr));

std::vector<CTxDestination> dests = std::vector<CTxDestination>({pk.GetID()});

outputs.push_back({MakeMofNCCScript(CConditionObj<CReserveTransfer>(EVAL_RESERVE_TRANSFER, dests, 1, &rt)), ConnectedChains.ThisChain().IDImportFee(), false});
}

// add referrals, Verus supports referrals
Expand Down Expand Up @@ -9999,11 +10007,19 @@ UniValue registeridentity(const UniValue& params, bool fHelp)
CReserveTransfer rt(CReserveTransfer::VALID + CReserveTransfer::BURN_CHANGE_PRICE,
CCurrencyValueMap(std::vector<uint160>({issuerID}), std::vector<int64_t>({feeOffer})),
ASSETCHAINS_CHAINID,
ConnectedChains.ThisChain().IDImportFee(),
ConnectedChains.ThisChain().GetTransactionTransferFee(),
issuerID,
DestinationToTransferDestination(CIdentityID(issuerID)));

CCcontract_info CC;
CCcontract_info *cp;
cp = CCinit(&CC, EVAL_RESERVE_TRANSFER);
CPubKey pk(ParseHex(CC.CChexstr));

std::vector<CTxDestination> dests = std::vector<CTxDestination>({pk.GetID()});

outputs[registrationPaymentOut].scriptPubKey = MakeMofNCCScript(CConditionObj<CReserveTransfer>(EVAL_RESERVE_TRANSFER,
std::vector<CTxDestination>({CIdentityID(issuerID)}),
dests,
1,
&rt));
}
Expand Down

0 comments on commit 1c9adeb

Please sign in to comment.