{
fprintf(stderr,"spentheight.%d reservevaluein: %s\nis less than out: %s\n", nSpendHeight,
ReserveValueIn.ToUniValue().write(1, 2).c_str(), tx.GetReserveValueOut().ToUniValue().write(1, 2).c_str());
- //UniValue jsonTx(UniValue::VOBJ);
- //TxToUniv(tx, uint256(), jsonTx);
- //fprintf(stderr,"%s\n", jsonTx.write(1,2).c_str());
+ UniValue jsonTx(UniValue::VOBJ);
+ TxToUniv(tx, uint256(), jsonTx);
+ fprintf(stderr,"%s\n", jsonTx.write(1,2).c_str());
return state.DoS(100, error("CheckInputs(): reserve value in < reserve value out"), REJECT_INVALID, "bad-txns-reservein-belowout");
}
void CReserveTransactionDescriptor::AddReserveTransfer(const CReserveTransfer &rt)
{
flags |= IS_RESERVE;
- for (auto &oneCur : rt.reserveValues.valueMap)
+ for (auto &oneCur : rt.TotalCurrencyOut().valueMap)
{
if (oneCur.first != ASSETCHAINS_CHAINID && oneCur.second)
{
std::vector<CTxDestination> dests = std::vector<CTxDestination>({pk.GetID(), refundDestination});
- oneOutput.nAmount = sourceCurrencyID == thisChainID ? sourceAmount + fees : fees;
+ oneOutput.nAmount = sourceCurrencyID == thisChainID ? sourceAmount : 0;
+ oneOutput.nAmount += feeCurrencyID == thisChainID ? fees : 0;
oneOutput.scriptPubKey = MakeMofNCCScript(CConditionObj<CReserveTransfer>(EVAL_RESERVE_TRANSFER, dests, 1, &rt));
}
else // direct to another system paying with acceptable fee currency
std::vector<CTxDestination> dests = std::vector<CTxDestination>({pk.GetID(), refundDestination});
oneOutput.nAmount = sourceCurrencyID == thisChainID ? sourceAmount : 0;
- assert(feeCurrencyID == destSystemID);
+ oneOutput.nAmount += feeCurrencyID == thisChainID ? fees : 0;
oneOutput.scriptPubKey = MakeMofNCCScript(CConditionObj<CReserveTransfer>(EVAL_RESERVE_TRANSFER, dests, 1, &rt));
}
}
// Create operation and add to global queue
CMutableTransaction contextualTx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), height + 1);
std::shared_ptr<AsyncRPCQueue> q = getAsyncRPCQueue();
- std::shared_ptr<AsyncRPCOperation> operation( new AsyncRPCOperation_sendmany(tb,
- contextualTx,
- sourceAddress,
- tOutputs,
- zOutputs,
- hasZSource ? 1 : 0,
- feeAmount,
- uniOutputs,
- true) );
+ std::shared_ptr<AsyncRPCOperation> operation(new AsyncRPCOperation_sendmany(tb,
+ contextualTx,
+ sourceAddress,
+ tOutputs,
+ zOutputs,
+ hasZSource ? 1 : 0,
+ feeAmount,
+ uniOutputs,
+ true) );
q->addOperation(operation);
AsyncRPCOperationId operationId = operation->getId();
return operationId;