mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Merge branch 'pay'
This commit is contained in:
@@ -244,7 +244,7 @@ Json::Value RPCServer::doAccountInfo(Json::Value ¶ms)
|
||||
return "invalid params";
|
||||
}
|
||||
else if (!theApp->getOPs().available()) {
|
||||
return "network not available";
|
||||
return JSONRPCError(503, "network not available");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -363,6 +363,104 @@ Json::Value RPCServer::doPeers(Json::Value& params)
|
||||
return theApp->getConnectionPool().getPeersJson();
|
||||
}
|
||||
|
||||
// credit_set <seed> <paying_account> <destination_account> <limit_amount> <currency> [<borrow_rate>] [<borrow_start>] [<borrow_expire>]
|
||||
Json::Value RPCServer::doCreditSet(Json::Value& params)
|
||||
{
|
||||
NewcoinAddress naSeed;
|
||||
NewcoinAddress naSrcAccountID;
|
||||
NewcoinAddress naDstAccountID;
|
||||
STAmount saLimitAmount;
|
||||
std::string sBorrowRate;
|
||||
std::string sBorrowStart;
|
||||
std::string sBorrowExpire;
|
||||
uint32 uBorrowRate;
|
||||
uint32 uBorrowStart;
|
||||
uint32 uBorrowExpire;
|
||||
|
||||
if (params.size() >= 6)
|
||||
sBorrowRate = params[6u].asString();
|
||||
|
||||
if (params.size() >= 7)
|
||||
sBorrowStart = params[7u].asString();
|
||||
|
||||
if (params.size() >= 8)
|
||||
sBorrowExpire = params[8u].asString();
|
||||
|
||||
if (params.size() < 5 || params.size() > 8)
|
||||
{
|
||||
return JSONRPCError(500, "invalid parameters");
|
||||
}
|
||||
else if (!naSeed.setFamilySeedGeneric(params[0u].asString()))
|
||||
{
|
||||
return JSONRPCError(500, "disallowed seed");
|
||||
}
|
||||
else if (!naSrcAccountID.setAccountID(params[1u].asString()))
|
||||
{
|
||||
return JSONRPCError(500, "source account id needed");
|
||||
}
|
||||
else if (!naDstAccountID.setAccountID(params[2u].asString()))
|
||||
{
|
||||
return JSONRPCError(500, "destination account id needed");
|
||||
}
|
||||
else if (!saLimitAmount.setValue(params[5u].asString(), params[6u].asString()))
|
||||
{
|
||||
return JSONRPCError(500, "bad src amount/currency");
|
||||
}
|
||||
else if (!theApp->getOPs().available()) {
|
||||
return JSONRPCError(503, "network not available");
|
||||
}
|
||||
else
|
||||
{
|
||||
NewcoinAddress naAccountPublic;
|
||||
NewcoinAddress naAccountPrivate;
|
||||
SerializedLedgerEntry::pointer sleSrc;
|
||||
Json::Value obj = authorize(naSeed, naSrcAccountID, naAccountPublic, naAccountPrivate, sleSrc);
|
||||
|
||||
if (!obj.empty())
|
||||
{
|
||||
return obj;
|
||||
}
|
||||
|
||||
STAmount saSrcBalance = sleSrc->getIValueFieldAmount(sfBalance);
|
||||
|
||||
uBorrowRate = 0;
|
||||
uBorrowStart = 0;
|
||||
uBorrowExpire = 0;
|
||||
|
||||
if (saSrcBalance < theConfig.FEE_DEFAULT)
|
||||
{
|
||||
return JSONRPCError(500, "insufficent funds");
|
||||
}
|
||||
else
|
||||
{
|
||||
Transaction::pointer trans = Transaction::sharedCreditSet(
|
||||
naAccountPublic, naAccountPrivate,
|
||||
naSrcAccountID,
|
||||
sleSrc->getIFieldU32(sfSequence),
|
||||
theConfig.FEE_DEFAULT,
|
||||
0, // YYY No source tag
|
||||
naDstAccountID,
|
||||
saLimitAmount,
|
||||
uBorrowRate,
|
||||
uBorrowStart,
|
||||
uBorrowExpire);
|
||||
|
||||
(void) theApp->getOPs().processTransaction(trans);
|
||||
|
||||
obj["transaction"] = trans->getSTransaction()->getJson(0);
|
||||
obj["status"] = trans->getStatus();
|
||||
obj["seed"] = naSeed.humanFamilySeed();
|
||||
obj["srcAccountID"] = naSrcAccountID.humanAccountID();
|
||||
obj["dstAccountID"] = naDstAccountID.humanAccountID();
|
||||
obj["limitAmount"] = saLimitAmount.getText();
|
||||
obj["borrowRate"] = uBorrowRate;
|
||||
obj["borrowStart"] = uBorrowStart;
|
||||
obj["borrowExpire"] = uBorrowExpire;
|
||||
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// send regular_seed paying_account account_id amount [currency] [send_max] [send_currency]
|
||||
Json::Value RPCServer::doSend(Json::Value& params)
|
||||
@@ -406,7 +504,7 @@ Json::Value RPCServer::doSend(Json::Value& params)
|
||||
return JSONRPCError(500, "bad src amount/currency");
|
||||
}
|
||||
else if (!theApp->getOPs().available()) {
|
||||
return "network not available";
|
||||
return JSONRPCError(503, "network not available");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -423,6 +521,8 @@ Json::Value RPCServer::doSend(Json::Value& params)
|
||||
if (params.size() < 6)
|
||||
saSrcAmount = saDstAmount;
|
||||
|
||||
// XXX Confirm saSrcAmount >= saDstAmount.
|
||||
|
||||
STAmount saSrcBalance = sleSrc->getIValueFieldAmount(sfBalance);
|
||||
|
||||
if (saSrcBalance < theConfig.FEE_DEFAULT)
|
||||
@@ -460,6 +560,92 @@ Json::Value RPCServer::doSend(Json::Value& params)
|
||||
}
|
||||
}
|
||||
|
||||
// transit_set <seed> <paying_account> <transit_rate> <starts> <expires>
|
||||
Json::Value RPCServer::doTransitSet(Json::Value& params)
|
||||
{
|
||||
NewcoinAddress naSeed;
|
||||
NewcoinAddress naSrcAccountID;
|
||||
std::string sTransitRate;
|
||||
std::string sTransitStart;
|
||||
std::string sTransitExpire;
|
||||
uint32 uTransitRate;
|
||||
uint32 uTransitStart;
|
||||
uint32 uTransitExpire;
|
||||
|
||||
if (params.size() >= 6)
|
||||
sTransitRate = params[6u].asString();
|
||||
|
||||
if (params.size() >= 7)
|
||||
sTransitStart = params[7u].asString();
|
||||
|
||||
if (params.size() >= 8)
|
||||
sTransitExpire = params[8u].asString();
|
||||
|
||||
if (params.size() != 5)
|
||||
{
|
||||
return JSONRPCError(500, "invalid parameters");
|
||||
}
|
||||
else if (!naSeed.setFamilySeedGeneric(params[0u].asString()))
|
||||
{
|
||||
return JSONRPCError(500, "disallowed seed");
|
||||
}
|
||||
else if (!naSrcAccountID.setAccountID(params[1u].asString()))
|
||||
{
|
||||
return JSONRPCError(500, "source account id needed");
|
||||
}
|
||||
else if (!theApp->getOPs().available()) {
|
||||
return JSONRPCError(503, "network not available");
|
||||
}
|
||||
else
|
||||
{
|
||||
NewcoinAddress naAccountPublic;
|
||||
NewcoinAddress naAccountPrivate;
|
||||
SerializedLedgerEntry::pointer sleSrc;
|
||||
Json::Value obj = authorize(naSeed, naSrcAccountID, naAccountPublic, naAccountPrivate, sleSrc);
|
||||
|
||||
if (!obj.empty())
|
||||
{
|
||||
return obj;
|
||||
}
|
||||
|
||||
STAmount saSrcBalance = sleSrc->getIValueFieldAmount(sfBalance);
|
||||
|
||||
uTransitRate = 0;
|
||||
uTransitStart = 0;
|
||||
uTransitExpire = 0;
|
||||
|
||||
if (saSrcBalance < theConfig.FEE_DEFAULT)
|
||||
{
|
||||
return JSONRPCError(500, "insufficent funds");
|
||||
}
|
||||
else
|
||||
{
|
||||
Transaction::pointer trans = Transaction::sharedTransitSet(
|
||||
naAccountPublic, naAccountPrivate,
|
||||
naSrcAccountID,
|
||||
sleSrc->getIFieldU32(sfSequence),
|
||||
theConfig.FEE_DEFAULT,
|
||||
0, // YYY No source tag
|
||||
uTransitRate,
|
||||
uTransitStart,
|
||||
uTransitExpire);
|
||||
|
||||
(void) theApp->getOPs().processTransaction(trans);
|
||||
|
||||
obj["transaction"] = trans->getSTransaction()->getJson(0);
|
||||
obj["status"] = trans->getStatus();
|
||||
obj["seed"] = naSeed.humanFamilySeed();
|
||||
obj["srcAccountID"] = naSrcAccountID.humanAccountID();
|
||||
obj["transitRate"] = uTransitRate;
|
||||
obj["transitStart"] = uTransitStart;
|
||||
obj["transitExpire"] = uTransitExpire;
|
||||
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
return "Not implemented.";
|
||||
}
|
||||
|
||||
Json::Value RPCServer::doTx(Json::Value& params)
|
||||
{
|
||||
// tx
|
||||
@@ -720,7 +906,7 @@ Json::Value RPCServer::doWalletCreate(Json::Value& params)
|
||||
}
|
||||
else if (!theApp->getOPs().available()) {
|
||||
// We require access to the paying account's sequence number and key information.
|
||||
return "network not available";
|
||||
return JSONRPCError(503, "network not available");
|
||||
}
|
||||
else if (theApp->getMasterLedger().getCurrentLedger()->getAccountState(naDstAccountID))
|
||||
{
|
||||
@@ -965,29 +1151,30 @@ Json::Value RPCServer::doCommand(const std::string& command, Json::Value& params
|
||||
{
|
||||
std::cerr << "RPC:" << command << std::endl;
|
||||
|
||||
if (command == "account_info") return doAccountInfo(params);
|
||||
if (command == "connect") return doConnect(params);
|
||||
if (command == "peers") return doPeers(params);
|
||||
if (command == "account_info") return doAccountInfo(params);
|
||||
if (command == "connect") return doConnect(params);
|
||||
if (command == "credit_set") return doCreditSet(params);
|
||||
if (command == "peers") return doPeers(params);
|
||||
if (command == "send") return doSend(params);
|
||||
if (command == "stop") return doStop(params);
|
||||
if (command == "transit_set") return doTransitSet(params);
|
||||
|
||||
if (command == "send") return doSend(params);
|
||||
if (command == "stop") return doStop(params);
|
||||
if (command == "unl_add") return doUnlAdd(params);
|
||||
if (command == "unl_default") return doUnlDefault(params);
|
||||
if (command == "unl_delete") return doUnlDelete(params);
|
||||
if (command == "unl_list") return doUnlList(params);
|
||||
if (command == "unl_reset") return doUnlReset(params);
|
||||
if (command == "unl_score") return doUnlScore(params);
|
||||
|
||||
if (command == "unl_add") return doUnlAdd(params);
|
||||
if (command == "unl_default") return doUnlDefault(params);
|
||||
if (command == "unl_delete") return doUnlDelete(params);
|
||||
if (command == "unl_list") return doUnlList(params);
|
||||
if (command == "unl_reset") return doUnlReset(params);
|
||||
if (command == "unl_score") return doUnlScore(params);
|
||||
if (command == "validation_create") return doValidatorCreate(params);
|
||||
|
||||
if (command == "validation_create") return doValidatorCreate(params);
|
||||
|
||||
if (command == "wallet_accounts") return doWalletAccounts(params);
|
||||
if (command == "wallet_add") return doWalletAdd(params);
|
||||
if (command == "wallet_claim") return doWalletClaim(params);
|
||||
if (command == "wallet_create") return doWalletCreate(params);
|
||||
if (command == "wallet_propose") return doWalletPropose(params);
|
||||
if (command == "wallet_seed") return doWalletSeed(params);
|
||||
if (command == "wallet_verify") return doWalletVerify(params);
|
||||
if (command == "wallet_accounts") return doWalletAccounts(params);
|
||||
if (command == "wallet_add") return doWalletAdd(params);
|
||||
if (command == "wallet_claim") return doWalletClaim(params);
|
||||
if (command == "wallet_create") return doWalletCreate(params);
|
||||
if (command == "wallet_propose") return doWalletPropose(params);
|
||||
if (command == "wallet_seed") return doWalletSeed(params);
|
||||
if (command == "wallet_verify") return doWalletVerify(params);
|
||||
|
||||
//
|
||||
// Obsolete or need rewrite:
|
||||
|
||||
@@ -37,13 +37,16 @@ class RPCServer : public boost::enable_shared_from_this<RPCServer>
|
||||
SerializedLedgerEntry::pointer& sleSrc);
|
||||
|
||||
Json::Value doAccountInfo(Json::Value& params);
|
||||
Json::Value doBorrowSet(Json::Value& params);
|
||||
Json::Value doConnect(Json::Value& params);
|
||||
Json::Value doCreditSet(Json::Value& params);
|
||||
Json::Value doLedger(Json::Value& params);
|
||||
Json::Value doPeers(Json::Value& params);
|
||||
Json::Value doSend(Json::Value& params);
|
||||
Json::Value doSessionClose(Json::Value& params);
|
||||
Json::Value doSessionOpen(Json::Value& params);
|
||||
Json::Value doStop(Json::Value& params);
|
||||
Json::Value doTransitSet(Json::Value& params);
|
||||
Json::Value doTx(Json::Value& params);
|
||||
|
||||
Json::Value doUnlAdd(Json::Value& params);
|
||||
|
||||
@@ -31,6 +31,9 @@ enum SOE_Field
|
||||
sfAmountOut,
|
||||
sfAuthorizedKey,
|
||||
sfBalance,
|
||||
sfBorrowExpire,
|
||||
sfBorrowRate,
|
||||
sfBorrowStart,
|
||||
sfBorrower,
|
||||
sfCurrency,
|
||||
sfCurrencyIn,
|
||||
@@ -50,6 +53,7 @@ enum SOE_Field
|
||||
sfLedgerHash,
|
||||
sfLender,
|
||||
sfLimit,
|
||||
sfLimitAmount,
|
||||
sfMessageKey,
|
||||
sfMinimumOffer,
|
||||
sfNextRate,
|
||||
@@ -67,6 +71,9 @@ enum SOE_Field
|
||||
sfSourceTag,
|
||||
sfTarget,
|
||||
sfTargetLedger,
|
||||
sfTransitExpire,
|
||||
sfTransitRate,
|
||||
sfTransitStart,
|
||||
sfWalletLocator,
|
||||
|
||||
// test fields
|
||||
|
||||
@@ -155,11 +155,11 @@ Transaction::pointer Transaction::sharedClaim(
|
||||
Transaction::pointer Transaction::setCreate(
|
||||
const NewcoinAddress& naPrivateKey,
|
||||
const NewcoinAddress& naCreateAccountID,
|
||||
const STAmount& uFund)
|
||||
const STAmount& saFund)
|
||||
{
|
||||
mTransaction->setITFieldU32(sfFlags, tfCreateAccount);
|
||||
mTransaction->setITFieldAccount(sfDestination, naCreateAccountID);
|
||||
mTransaction->setITFieldAmount(sfAmount, uFund);
|
||||
mTransaction->setITFieldAmount(sfAmount, saFund);
|
||||
|
||||
sign(naPrivateKey);
|
||||
|
||||
@@ -173,13 +173,58 @@ Transaction::pointer Transaction::sharedCreate(
|
||||
const STAmount& saFee,
|
||||
uint32 uSourceTag,
|
||||
const NewcoinAddress& naCreateAccountID,
|
||||
const STAmount& uFund)
|
||||
const STAmount& saFund)
|
||||
{
|
||||
pointer tResult = boost::make_shared<Transaction>(ttPAYMENT,
|
||||
naPublicKey, naSourceAccount,
|
||||
uSeq, saFee, uSourceTag);
|
||||
|
||||
return tResult->setCreate(naPrivateKey, naCreateAccountID, uFund);
|
||||
return tResult->setCreate(naPrivateKey, naCreateAccountID, saFund);
|
||||
}
|
||||
|
||||
//
|
||||
// CreditSet
|
||||
//
|
||||
|
||||
Transaction::pointer Transaction::setCreditSet(
|
||||
const NewcoinAddress& naPrivateKey,
|
||||
const NewcoinAddress& naDstAccountID,
|
||||
const STAmount& saLimitAmount,
|
||||
uint32 uBorrowRate,
|
||||
uint32 uBorrowStart,
|
||||
uint32 uBorrowExpire)
|
||||
{
|
||||
mTransaction->setITFieldAccount(sfDestination, naDstAccountID);
|
||||
mTransaction->setITFieldAmount(sfLimitAmount, saLimitAmount);
|
||||
if (uBorrowRate)
|
||||
mTransaction->setITFieldU32(sfBorrowRate, uBorrowRate);
|
||||
if (uBorrowStart)
|
||||
mTransaction->setITFieldU32(sfBorrowStart, uBorrowStart);
|
||||
if (uBorrowExpire)
|
||||
mTransaction->setITFieldU32(sfBorrowExpire, uBorrowExpire);
|
||||
|
||||
sign(naPrivateKey);
|
||||
|
||||
return shared_from_this();
|
||||
}
|
||||
|
||||
Transaction::pointer Transaction::sharedCreditSet(
|
||||
const NewcoinAddress& naPublicKey, const NewcoinAddress& naPrivateKey,
|
||||
const NewcoinAddress& naSourceAccount,
|
||||
uint32 uSeq,
|
||||
const STAmount& saFee,
|
||||
uint32 uSourceTag,
|
||||
const NewcoinAddress& naDstAccountID,
|
||||
const STAmount& saLimitAmount,
|
||||
uint32 uBorrowRate,
|
||||
uint32 uBorrowStart,
|
||||
uint32 uBorrowExpire)
|
||||
{
|
||||
pointer tResult = boost::make_shared<Transaction>(ttCREDIT_SET,
|
||||
naPublicKey, naSourceAccount,
|
||||
uSeq, saFee, uSourceTag);
|
||||
|
||||
return tResult->setCreditSet(naPrivateKey, naDstAccountID, saLimitAmount, uBorrowRate, uBorrowStart, uBorrowExpire);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -188,12 +233,12 @@ Transaction::pointer Transaction::sharedCreate(
|
||||
|
||||
Transaction::pointer Transaction::setPayment(
|
||||
const NewcoinAddress& naPrivateKey,
|
||||
const NewcoinAddress& toAccount,
|
||||
const NewcoinAddress& naDstAccountID,
|
||||
const STAmount& saAmount,
|
||||
const STAmount& saSendMax,
|
||||
const STPathSet& spPaths)
|
||||
{
|
||||
mTransaction->setITFieldAccount(sfDestination, toAccount);
|
||||
mTransaction->setITFieldAccount(sfDestination, naDstAccountID);
|
||||
mTransaction->setITFieldAmount(sfAmount, saAmount);
|
||||
|
||||
if (saAmount != saSendMax)
|
||||
@@ -217,7 +262,7 @@ Transaction::pointer Transaction::sharedPayment(
|
||||
uint32 uSeq,
|
||||
const STAmount& saFee,
|
||||
uint32 uSourceTag,
|
||||
const NewcoinAddress& toAccount,
|
||||
const NewcoinAddress& naDstAccountID,
|
||||
const STAmount& saAmount,
|
||||
const STAmount& saSendMax,
|
||||
const STPathSet& saPaths)
|
||||
@@ -226,7 +271,46 @@ Transaction::pointer Transaction::sharedPayment(
|
||||
naPublicKey, naSourceAccount,
|
||||
uSeq, saFee, uSourceTag);
|
||||
|
||||
return tResult->setPayment(naPrivateKey, toAccount, saAmount, saSendMax, saPaths);
|
||||
return tResult->setPayment(naPrivateKey, naDstAccountID, saAmount, saSendMax, saPaths);
|
||||
}
|
||||
|
||||
//
|
||||
// TransitSet
|
||||
//
|
||||
|
||||
Transaction::pointer Transaction::setTransitSet(
|
||||
const NewcoinAddress& naPrivateKey,
|
||||
uint32 uTransitRate,
|
||||
uint32 uTransitStart,
|
||||
uint32 uTransitExpire)
|
||||
{
|
||||
if (uTransitRate)
|
||||
mTransaction->setITFieldU32(sfTransitRate, uTransitRate);
|
||||
if (uTransitStart)
|
||||
mTransaction->setITFieldU32(sfTransitStart, uTransitStart);
|
||||
if (uTransitExpire)
|
||||
mTransaction->setITFieldU32(sfTransitExpire, uTransitExpire);
|
||||
|
||||
sign(naPrivateKey);
|
||||
|
||||
return shared_from_this();
|
||||
}
|
||||
|
||||
Transaction::pointer Transaction::sharedTransitSet(
|
||||
const NewcoinAddress& naPublicKey, const NewcoinAddress& naPrivateKey,
|
||||
const NewcoinAddress& naSourceAccount,
|
||||
uint32 uSeq,
|
||||
const STAmount& saFee,
|
||||
uint32 uSourceTag,
|
||||
uint32 uTransitRate,
|
||||
uint32 uTransitStart,
|
||||
uint32 uTransitExpire)
|
||||
{
|
||||
pointer tResult = boost::make_shared<Transaction>(ttTRANSIT_SET,
|
||||
naPublicKey, naSourceAccount,
|
||||
uSeq, saFee, uSourceTag);
|
||||
|
||||
return tResult->setTransitSet(naPrivateKey, uTransitRate, uTransitStart, uTransitExpire);
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@@ -55,15 +55,29 @@ private:
|
||||
Transaction::pointer setCreate(
|
||||
const NewcoinAddress& naPrivateKey,
|
||||
const NewcoinAddress& naCreateAccountID,
|
||||
const STAmount& uFund);
|
||||
const STAmount& saFund);
|
||||
|
||||
Transaction::pointer setCreditSet(
|
||||
const NewcoinAddress& naPrivateKey,
|
||||
const NewcoinAddress& naDstAccountID,
|
||||
const STAmount& saLimitAmount,
|
||||
uint32 uBorrowRate,
|
||||
uint32 uBorrowStart,
|
||||
uint32 uBorrowExpire);
|
||||
|
||||
Transaction::pointer setPayment(
|
||||
const NewcoinAddress& naPrivateKey,
|
||||
const NewcoinAddress& toAccount,
|
||||
const NewcoinAddress& naDstAccountID,
|
||||
const STAmount& saAmount,
|
||||
const STAmount& saSendMax,
|
||||
const STPathSet& spPaths);
|
||||
|
||||
Transaction::pointer setTransitSet(
|
||||
const NewcoinAddress& naPrivateKey,
|
||||
uint32 uTransitRate,
|
||||
uint32 uTransitStart,
|
||||
uint32 uTransitExpire);
|
||||
|
||||
public:
|
||||
Transaction(const SerializedTransaction::pointer st, bool bValidate);
|
||||
|
||||
@@ -94,7 +108,20 @@ public:
|
||||
const STAmount& saFee,
|
||||
uint32 uSourceTag,
|
||||
const NewcoinAddress& naCreateAccountID, // Account to create.
|
||||
const STAmount& uFund); // Initial funds in XNC.
|
||||
const STAmount& saFund); // Initial funds in XNC.
|
||||
|
||||
// Set credit limit and borrow fees.
|
||||
static Transaction::pointer sharedCreditSet(
|
||||
const NewcoinAddress& naPublicKey, const NewcoinAddress& naPrivateKey,
|
||||
const NewcoinAddress& naSourceAccount,
|
||||
uint32 uSeq,
|
||||
const STAmount& saFee,
|
||||
uint32 uSourceTag,
|
||||
const NewcoinAddress& naDstAccountID,
|
||||
const STAmount& saLimitAmount,
|
||||
uint32 uBorrowRate,
|
||||
uint32 uBorrowStart,
|
||||
uint32 uBorrowExpire);
|
||||
|
||||
// Make a payment.
|
||||
static Transaction::pointer sharedPayment(
|
||||
@@ -103,11 +130,22 @@ public:
|
||||
uint32 uSeq,
|
||||
const STAmount& saFee,
|
||||
uint32 uSourceTag,
|
||||
const NewcoinAddress& toAccount,
|
||||
const NewcoinAddress& naDstAccountID,
|
||||
const STAmount& saAmount,
|
||||
const STAmount& saSendMax,
|
||||
const STPathSet& saPaths);
|
||||
|
||||
// Set transit fees.
|
||||
static Transaction::pointer sharedTransitSet(
|
||||
const NewcoinAddress& naPublicKey, const NewcoinAddress& naPrivateKey,
|
||||
const NewcoinAddress& naSourceAccount,
|
||||
uint32 uSeq,
|
||||
const STAmount& saFee,
|
||||
uint32 uSourceTag,
|
||||
uint32 uTransitRate,
|
||||
uint32 uTransitStart,
|
||||
uint32 uTransitExpire);
|
||||
|
||||
bool sign(const NewcoinAddress& naAccountPrivate);
|
||||
bool checkSign() const;
|
||||
void updateID() { mTransactionID=mTransaction->getTransactionID(); }
|
||||
|
||||
@@ -52,7 +52,7 @@ TransactionEngineResult TransactionEngine::applyTransaction(const SerializedTran
|
||||
break;
|
||||
|
||||
case ttINVOICE:
|
||||
case ttEXCHANGE_OFFER:
|
||||
case ttOFFER:
|
||||
result = terSUCCESS;
|
||||
break;
|
||||
|
||||
@@ -171,27 +171,35 @@ TransactionEngineResult TransactionEngine::applyTransaction(const SerializedTran
|
||||
|
||||
switch(txn.getTxnType())
|
||||
{
|
||||
case ttINVALID:
|
||||
std::cerr << "applyTransaction: invalid type" << std::endl;
|
||||
result = tenINVALID;
|
||||
break;
|
||||
|
||||
case ttCLAIM:
|
||||
result = doClaim(txn, accounts);
|
||||
break;
|
||||
|
||||
case ttPAYMENT:
|
||||
result = doPayment(txn, accounts, srcAccountID);
|
||||
case ttCREDIT_SET:
|
||||
result = doCreditSet(txn, accounts);
|
||||
break;
|
||||
|
||||
case ttINVALID:
|
||||
std::cerr << "applyTransaction: invalid type" << std::endl;
|
||||
result = tenINVALID;
|
||||
break;
|
||||
|
||||
case ttINVOICE:
|
||||
result = doInvoice(txn, accounts);
|
||||
break;
|
||||
|
||||
case ttEXCHANGE_OFFER:
|
||||
case ttOFFER:
|
||||
result = doOffer(txn, accounts);
|
||||
break;
|
||||
|
||||
case ttPAYMENT:
|
||||
result = doPayment(txn, accounts, srcAccountID);
|
||||
break;
|
||||
|
||||
case ttTRANSIT_SET:
|
||||
result = doTransitSet(txn, accounts);
|
||||
break;
|
||||
|
||||
default:
|
||||
result = tenUNKNOWN;
|
||||
break;
|
||||
@@ -228,6 +236,11 @@ TransactionEngineResult TransactionEngine::applyTransaction(const SerializedTran
|
||||
return result;
|
||||
}
|
||||
|
||||
TransactionEngineResult TransactionEngine::doCreditSet(const SerializedTransaction&, std::vector<AffectedAccount>&)
|
||||
{
|
||||
return tenINVALID;
|
||||
}
|
||||
|
||||
TransactionEngineResult TransactionEngine::doClaim(const SerializedTransaction& txn,
|
||||
std::vector<AffectedAccount>& accounts)
|
||||
{
|
||||
@@ -412,6 +425,11 @@ TransactionEngineResult TransactionEngine::doPayment(const SerializedTransaction
|
||||
return terSUCCESS;
|
||||
}
|
||||
|
||||
TransactionEngineResult TransactionEngine::doTransitSet(const SerializedTransaction&, std::vector<AffectedAccount>&)
|
||||
{
|
||||
return tenINVALID;
|
||||
}
|
||||
|
||||
TransactionEngineResult TransactionEngine::doInvoice(const SerializedTransaction& txn,
|
||||
std::vector<AffectedAccount>& accounts)
|
||||
{
|
||||
@@ -447,4 +465,5 @@ TransactionEngineResult TransactionEngine::doDelete(const SerializedTransaction&
|
||||
{
|
||||
return tenUNKNOWN;
|
||||
}
|
||||
|
||||
// vim:ts=4
|
||||
|
||||
@@ -67,6 +67,7 @@ class TransactionEngine
|
||||
protected:
|
||||
Ledger::pointer mLedger;
|
||||
|
||||
TransactionEngineResult doCreditSet(const SerializedTransaction&, std::vector<AffectedAccount>&);
|
||||
TransactionEngineResult doCancel(const SerializedTransaction&, std::vector<AffectedAccount>&);
|
||||
TransactionEngineResult doClaim(const SerializedTransaction&, std::vector<AffectedAccount>&);
|
||||
TransactionEngineResult doDelete(const SerializedTransaction&, std::vector<AffectedAccount>&);
|
||||
@@ -76,6 +77,7 @@ protected:
|
||||
uint160 srcAccountID);
|
||||
TransactionEngineResult doStore(const SerializedTransaction&, std::vector<AffectedAccount>&);
|
||||
TransactionEngineResult doTake(const SerializedTransaction&, std::vector<AffectedAccount>&);
|
||||
TransactionEngineResult doTransitSet(const SerializedTransaction&, std::vector<AffectedAccount>&);
|
||||
|
||||
public:
|
||||
TransactionEngine() { ; }
|
||||
|
||||
@@ -5,17 +5,6 @@
|
||||
|
||||
TransactionFormat InnerTxnFormats[]=
|
||||
{
|
||||
{ "Payment", ttPAYMENT, {
|
||||
{ S_FIELD(Flags), STI_UINT32, SOE_FLAGS, 0 },
|
||||
{ S_FIELD(Destination), STI_ACCOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(Amount), STI_AMOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(SendMax), STI_AMOUNT, SOE_IFFLAG, 1 },
|
||||
{ S_FIELD(Paths), STI_PATHSET, SOE_IFFLAG, 2 },
|
||||
{ S_FIELD(SourceTag), STI_UINT32, SOE_IFFLAG, 4 },
|
||||
{ S_FIELD(InvoiceID), STI_HASH256, SOE_IFFLAG, 8 },
|
||||
{ S_FIELD(Extensions), STI_TL, SOE_IFFLAG, 0x02000000 },
|
||||
{ sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } }
|
||||
},
|
||||
{ "Claim", ttCLAIM, {
|
||||
{ S_FIELD(Flags), STI_UINT32, SOE_FLAGS, 0 },
|
||||
{ S_FIELD(Generator), STI_VL, SOE_REQUIRED, 0 },
|
||||
@@ -25,6 +14,17 @@ TransactionFormat InnerTxnFormats[]=
|
||||
{ S_FIELD(Extensions), STI_TL, SOE_IFFLAG, 0x02000000 },
|
||||
{ sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } }
|
||||
},
|
||||
{ "CreditSet", ttCREDIT_SET, {
|
||||
{ S_FIELD(Flags), STI_UINT32, SOE_FLAGS, 0 },
|
||||
{ S_FIELD(Destination), STI_ACCOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(LimitAmount), STI_AMOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(BorrowRate), STI_UINT32, SOE_IFFLAG, 1 },
|
||||
{ S_FIELD(BorrowStart), STI_UINT32, SOE_IFFLAG, 2 },
|
||||
{ S_FIELD(BorrowExpire), STI_UINT32, SOE_IFFLAG, 4 },
|
||||
{ S_FIELD(SourceTag), STI_UINT32, SOE_IFFLAG, 8 },
|
||||
{ S_FIELD(Extensions), STI_TL, SOE_IFFLAG, 0x02000000 },
|
||||
{ sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } }
|
||||
},
|
||||
{ "Invoice", ttINVOICE, {
|
||||
{ S_FIELD(Flags), STI_UINT32, SOE_FLAGS, 0 },
|
||||
{ S_FIELD(Target), STI_ACCOUNT, SOE_REQUIRED, 0 },
|
||||
@@ -36,7 +36,7 @@ TransactionFormat InnerTxnFormats[]=
|
||||
{ S_FIELD(Extensions), STI_TL, SOE_IFFLAG, 0x02000000 },
|
||||
{ sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } }
|
||||
},
|
||||
{ "Offer", ttEXCHANGE_OFFER, {
|
||||
{ "Offer", ttOFFER, {
|
||||
{ S_FIELD(Flags), STI_UINT32, SOE_FLAGS, 0 },
|
||||
{ S_FIELD(AmountIn), STI_AMOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(CurrencyIn), STI_HASH160, SOE_IFFLAG, 2 },
|
||||
@@ -49,6 +49,26 @@ TransactionFormat InnerTxnFormats[]=
|
||||
{ S_FIELD(Extensions), STI_TL, SOE_IFFLAG, 0x02000000 },
|
||||
{ sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } }
|
||||
},
|
||||
{ "Payment", ttPAYMENT, {
|
||||
{ S_FIELD(Flags), STI_UINT32, SOE_FLAGS, 0 },
|
||||
{ S_FIELD(Destination), STI_ACCOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(Amount), STI_AMOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(SendMax), STI_AMOUNT, SOE_IFFLAG, 1 },
|
||||
{ S_FIELD(Paths), STI_PATHSET, SOE_IFFLAG, 2 },
|
||||
{ S_FIELD(SourceTag), STI_UINT32, SOE_IFFLAG, 4 },
|
||||
{ S_FIELD(InvoiceID), STI_HASH256, SOE_IFFLAG, 8 },
|
||||
{ S_FIELD(Extensions), STI_TL, SOE_IFFLAG, 0x02000000 },
|
||||
{ sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } }
|
||||
},
|
||||
{ "TransitSet", ttTRANSIT_SET, {
|
||||
{ S_FIELD(Flags), STI_UINT32, SOE_FLAGS, 0 },
|
||||
{ S_FIELD(TransitRate), STI_UINT32, SOE_IFFLAG, 1 },
|
||||
{ S_FIELD(TransitStart), STI_UINT32, SOE_IFFLAG, 2 },
|
||||
{ S_FIELD(TransitExpire),STI_UINT32, SOE_IFFLAG, 4 },
|
||||
{ S_FIELD(SourceTag), STI_UINT32, SOE_IFFLAG, 8 },
|
||||
{ S_FIELD(Extensions), STI_TL, SOE_IFFLAG, 0x02000000 },
|
||||
{ sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } }
|
||||
},
|
||||
{ NULL, ttINVALID }
|
||||
};
|
||||
|
||||
|
||||
@@ -9,7 +9,9 @@ enum TransactionType
|
||||
ttPAYMENT = 0,
|
||||
ttCLAIM = 1,
|
||||
ttINVOICE = 2,
|
||||
ttEXCHANGE_OFFER = 3
|
||||
ttOFFER = 3,
|
||||
ttCREDIT_SET = 20,
|
||||
ttTRANSIT_SET = 21,
|
||||
};
|
||||
|
||||
struct TransactionFormat
|
||||
@@ -28,8 +30,8 @@ const int TransactionISequence = 3;
|
||||
const int TransactionIType = 4;
|
||||
const int TransactionIFee = 5;
|
||||
|
||||
const int TransactionMinLen=32;
|
||||
const int TransactionMaxLen=1048576;
|
||||
const int TransactionMinLen = 32;
|
||||
const int TransactionMaxLen = 1048576;
|
||||
|
||||
// Transaction flags.
|
||||
const uint32 tfCreateAccount = 0x00010000;
|
||||
|
||||
@@ -40,10 +40,12 @@ void printHelp(const po::options_description& desc)
|
||||
cout << " account_info <account>|<nickname>" << endl;
|
||||
cout << " account_info <seed>|<pass_phrase>|<key> [<index>]" << endl;
|
||||
cout << " connect <ip> [<port>]" << endl;
|
||||
cout << " credit_set <seed> <paying_account> <destination_account> <limit_amount> <currency> [<borrow_rate>] [<borrow_start>] [<borrow_expire>]" << endl;
|
||||
cout << " ledger" << endl;
|
||||
cout << " peers" << endl;
|
||||
cout << " send <regular_seed> <paying_account> <account_id> <amount> [<currency>] [<send_max>] [<send_currency>]" << endl;
|
||||
cout << " send <seed> <paying_account> <account_id> <amount> [<currency>] [<send_max>] [<send_currency>]" << endl;
|
||||
cout << " stop" << endl;
|
||||
cout << " transit_set <seed> <paying_account> <transit_rate> <starts> <expires>" << endl;
|
||||
cout << " tx" << endl;
|
||||
cout << " unl_add <domain>|<public> [<comment>]" << endl;
|
||||
cout << " unl_delete <public_key>" << endl;
|
||||
|
||||
Reference in New Issue
Block a user