mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Update RPC, transactions, and ledger for new accountRootNode format.
This commit is contained in:
@@ -18,6 +18,8 @@ LedgerEntryFormat LedgerFormats[]=
|
|||||||
{ S_FIELD(MessageKey), STI_VL, SOE_IFFLAG, 8 },
|
{ S_FIELD(MessageKey), STI_VL, SOE_IFFLAG, 8 },
|
||||||
{ S_FIELD(TransferRate), STI_UINT32, SOE_IFFLAG, 16 },
|
{ S_FIELD(TransferRate), STI_UINT32, SOE_IFFLAG, 16 },
|
||||||
{ S_FIELD(Domain), STI_VL, SOE_IFFLAG, 32 },
|
{ S_FIELD(Domain), STI_VL, SOE_IFFLAG, 32 },
|
||||||
|
{ S_FIELD(PublishHash), STI_HASH256, SOE_IFFLAG, 64 },
|
||||||
|
{ S_FIELD(PublishSize), STI_UINT32, SOE_IFFLAG, 128 },
|
||||||
{ S_FIELD(Extensions), STI_TL, SOE_IFFLAG, 0x01000000 },
|
{ S_FIELD(Extensions), STI_TL, SOE_IFFLAG, 0x01000000 },
|
||||||
{ sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } }
|
{ sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } }
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -414,6 +414,60 @@ Json::Value RPCServer::accountFromString(const uint256& uLedger, NewcoinAddress&
|
|||||||
return Json::Value(Json::objectValue);
|
return Json::Value(Json::objectValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// account_domain_set <seed> <paying_account> [<domain>]
|
||||||
|
Json::Value RPCServer::doAccountDomainSet(const Json::Value ¶ms)
|
||||||
|
{
|
||||||
|
NewcoinAddress naSrcAccountID;
|
||||||
|
NewcoinAddress naSeed;
|
||||||
|
uint256 uLedger = mNetOps->getCurrentLedger();
|
||||||
|
|
||||||
|
if (!naSeed.setSeedGeneric(params[0u].asString()))
|
||||||
|
{
|
||||||
|
return RPCError(rpcBAD_SEED);
|
||||||
|
}
|
||||||
|
else if (!naSrcAccountID.setAccountID(params[1u].asString()))
|
||||||
|
{
|
||||||
|
return RPCError(rpcSRC_ACT_MALFORMED);
|
||||||
|
}
|
||||||
|
|
||||||
|
NewcoinAddress naVerifyGenerator;
|
||||||
|
NewcoinAddress naAccountPublic;
|
||||||
|
NewcoinAddress naAccountPrivate;
|
||||||
|
AccountState::pointer asSrc;
|
||||||
|
STAmount saSrcBalance;
|
||||||
|
Json::Value obj = authorize(uLedger, naSeed, naSrcAccountID, naAccountPublic, naAccountPrivate,
|
||||||
|
saSrcBalance, theConfig.FEE_DEFAULT, asSrc, naVerifyGenerator);
|
||||||
|
|
||||||
|
if (!obj.empty())
|
||||||
|
return obj;
|
||||||
|
|
||||||
|
Transaction::pointer trans = Transaction::sharedAccountSet(
|
||||||
|
naAccountPublic, naAccountPrivate,
|
||||||
|
naSrcAccountID,
|
||||||
|
asSrc->getSeq(),
|
||||||
|
theConfig.FEE_DEFAULT,
|
||||||
|
0, // YYY No source tag
|
||||||
|
false,
|
||||||
|
uint128(),
|
||||||
|
false,
|
||||||
|
0,
|
||||||
|
NewcoinAddress(),
|
||||||
|
true,
|
||||||
|
strCopy(params[2u].asString()),
|
||||||
|
false,
|
||||||
|
0,
|
||||||
|
false,
|
||||||
|
uint256(),
|
||||||
|
0);
|
||||||
|
|
||||||
|
trans = mNetOps->submitTransaction(trans);
|
||||||
|
|
||||||
|
obj["transaction"] = trans->getSTransaction()->getJson(0);
|
||||||
|
obj["status"] = trans->getStatus();
|
||||||
|
|
||||||
|
return Json::Value(Json::objectValue);
|
||||||
|
}
|
||||||
|
|
||||||
// account_email_set <seed> <paying_account> [<email_address>]
|
// account_email_set <seed> <paying_account> [<email_address>]
|
||||||
Json::Value RPCServer::doAccountEmailSet(const Json::Value ¶ms)
|
Json::Value RPCServer::doAccountEmailSet(const Json::Value ¶ms)
|
||||||
{
|
{
|
||||||
@@ -450,6 +504,7 @@ Json::Value RPCServer::doAccountEmailSet(const Json::Value ¶ms)
|
|||||||
MD5(reinterpret_cast<const unsigned char*>(strEmail.c_str()), strEmail.size(), &vucMD5.front());
|
MD5(reinterpret_cast<const unsigned char*>(strEmail.c_str()), strEmail.size(), &vucMD5.front());
|
||||||
|
|
||||||
uint128 uEmailHash(vucMD5);
|
uint128 uEmailHash(vucMD5);
|
||||||
|
std::vector<unsigned char> vucDomain;
|
||||||
|
|
||||||
Transaction::pointer trans = Transaction::sharedAccountSet(
|
Transaction::pointer trans = Transaction::sharedAccountSet(
|
||||||
naAccountPublic, naAccountPrivate,
|
naAccountPublic, naAccountPrivate,
|
||||||
@@ -457,11 +512,18 @@ Json::Value RPCServer::doAccountEmailSet(const Json::Value ¶ms)
|
|||||||
asSrc->getSeq(),
|
asSrc->getSeq(),
|
||||||
theConfig.FEE_DEFAULT,
|
theConfig.FEE_DEFAULT,
|
||||||
0, // YYY No source tag
|
0, // YYY No source tag
|
||||||
strEmail.empty(),
|
true,
|
||||||
uEmailHash,
|
strEmail.empty() ? uint128() : uEmailHash,
|
||||||
false,
|
false,
|
||||||
uint256(),
|
uint256(),
|
||||||
NewcoinAddress());
|
NewcoinAddress(),
|
||||||
|
false,
|
||||||
|
vucDomain,
|
||||||
|
false,
|
||||||
|
0,
|
||||||
|
false,
|
||||||
|
uint256(),
|
||||||
|
0);
|
||||||
|
|
||||||
trans = mNetOps->submitTransaction(trans);
|
trans = mNetOps->submitTransaction(trans);
|
||||||
|
|
||||||
@@ -556,6 +618,7 @@ Json::Value RPCServer::doAccountMessageSet(const Json::Value& params) {
|
|||||||
STAmount saSrcBalance;
|
STAmount saSrcBalance;
|
||||||
Json::Value obj = authorize(uLedger, naSeed, naSrcAccountID, naAccountPublic, naAccountPrivate,
|
Json::Value obj = authorize(uLedger, naSeed, naSrcAccountID, naAccountPublic, naAccountPrivate,
|
||||||
saSrcBalance, theConfig.FEE_DEFAULT, asSrc, naVerifyGenerator);
|
saSrcBalance, theConfig.FEE_DEFAULT, asSrc, naVerifyGenerator);
|
||||||
|
std::vector<unsigned char> vucDomain;
|
||||||
|
|
||||||
if (!obj.empty())
|
if (!obj.empty())
|
||||||
return obj;
|
return obj;
|
||||||
@@ -570,7 +633,14 @@ Json::Value RPCServer::doAccountMessageSet(const Json::Value& params) {
|
|||||||
uint128(),
|
uint128(),
|
||||||
false,
|
false,
|
||||||
uint256(),
|
uint256(),
|
||||||
naMessagePubKey);
|
naMessagePubKey,
|
||||||
|
false,
|
||||||
|
vucDomain,
|
||||||
|
false,
|
||||||
|
0,
|
||||||
|
false,
|
||||||
|
uint256(),
|
||||||
|
0);
|
||||||
|
|
||||||
trans = mNetOps->submitTransaction(trans);
|
trans = mNetOps->submitTransaction(trans);
|
||||||
|
|
||||||
@@ -581,6 +651,121 @@ Json::Value RPCServer::doAccountMessageSet(const Json::Value& params) {
|
|||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// account_publish_set <seed> <paying_account> <hash> <size>
|
||||||
|
Json::Value RPCServer::doAccountPublishSet(const Json::Value ¶ms)
|
||||||
|
{
|
||||||
|
NewcoinAddress naSrcAccountID;
|
||||||
|
NewcoinAddress naSeed;
|
||||||
|
uint256 uLedger = mNetOps->getCurrentLedger();
|
||||||
|
|
||||||
|
if (!naSeed.setSeedGeneric(params[0u].asString()))
|
||||||
|
{
|
||||||
|
return RPCError(rpcBAD_SEED);
|
||||||
|
}
|
||||||
|
else if (!naSrcAccountID.setAccountID(params[1u].asString()))
|
||||||
|
{
|
||||||
|
return RPCError(rpcSRC_ACT_MALFORMED);
|
||||||
|
}
|
||||||
|
|
||||||
|
NewcoinAddress naVerifyGenerator;
|
||||||
|
NewcoinAddress naAccountPublic;
|
||||||
|
NewcoinAddress naAccountPrivate;
|
||||||
|
AccountState::pointer asSrc;
|
||||||
|
STAmount saSrcBalance;
|
||||||
|
Json::Value obj = authorize(uLedger, naSeed, naSrcAccountID, naAccountPublic, naAccountPrivate,
|
||||||
|
saSrcBalance, theConfig.FEE_DEFAULT, asSrc, naVerifyGenerator);
|
||||||
|
|
||||||
|
if (!obj.empty())
|
||||||
|
return obj;
|
||||||
|
|
||||||
|
uint256 uPublishHash(params[2u].asString());
|
||||||
|
uint32 uPublishSize = lexical_cast_s<int>(params[3u].asString());
|
||||||
|
std::vector<unsigned char> vucDomain;
|
||||||
|
|
||||||
|
Transaction::pointer trans = Transaction::sharedAccountSet(
|
||||||
|
naAccountPublic, naAccountPrivate,
|
||||||
|
naSrcAccountID,
|
||||||
|
asSrc->getSeq(),
|
||||||
|
theConfig.FEE_DEFAULT,
|
||||||
|
0, // YYY No source tag
|
||||||
|
false,
|
||||||
|
uint128(),
|
||||||
|
false,
|
||||||
|
0,
|
||||||
|
NewcoinAddress(),
|
||||||
|
false,
|
||||||
|
vucDomain,
|
||||||
|
false,
|
||||||
|
0,
|
||||||
|
true,
|
||||||
|
uPublishHash,
|
||||||
|
uPublishSize);
|
||||||
|
|
||||||
|
trans = mNetOps->submitTransaction(trans);
|
||||||
|
|
||||||
|
obj["transaction"] = trans->getSTransaction()->getJson(0);
|
||||||
|
obj["status"] = trans->getStatus();
|
||||||
|
|
||||||
|
return Json::Value(Json::objectValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
// account_rate_set <seed> <paying_account> <rate>
|
||||||
|
Json::Value RPCServer::doAccountRateSet(const Json::Value ¶ms)
|
||||||
|
{
|
||||||
|
NewcoinAddress naSrcAccountID;
|
||||||
|
NewcoinAddress naSeed;
|
||||||
|
uint256 uLedger = mNetOps->getCurrentLedger();
|
||||||
|
|
||||||
|
if (!naSeed.setSeedGeneric(params[0u].asString()))
|
||||||
|
{
|
||||||
|
return RPCError(rpcBAD_SEED);
|
||||||
|
}
|
||||||
|
else if (!naSrcAccountID.setAccountID(params[1u].asString()))
|
||||||
|
{
|
||||||
|
return RPCError(rpcSRC_ACT_MALFORMED);
|
||||||
|
}
|
||||||
|
|
||||||
|
NewcoinAddress naVerifyGenerator;
|
||||||
|
NewcoinAddress naAccountPublic;
|
||||||
|
NewcoinAddress naAccountPrivate;
|
||||||
|
AccountState::pointer asSrc;
|
||||||
|
STAmount saSrcBalance;
|
||||||
|
Json::Value obj = authorize(uLedger, naSeed, naSrcAccountID, naAccountPublic, naAccountPrivate,
|
||||||
|
saSrcBalance, theConfig.FEE_DEFAULT, asSrc, naVerifyGenerator);
|
||||||
|
|
||||||
|
if (!obj.empty())
|
||||||
|
return obj;
|
||||||
|
|
||||||
|
uint32 uRate = lexical_cast_s<int>(params[2u].asString());
|
||||||
|
std::vector<unsigned char> vucDomain;
|
||||||
|
|
||||||
|
Transaction::pointer trans = Transaction::sharedAccountSet(
|
||||||
|
naAccountPublic, naAccountPrivate,
|
||||||
|
naSrcAccountID,
|
||||||
|
asSrc->getSeq(),
|
||||||
|
theConfig.FEE_DEFAULT,
|
||||||
|
0, // YYY No source tag
|
||||||
|
false,
|
||||||
|
uint128(),
|
||||||
|
false,
|
||||||
|
0,
|
||||||
|
NewcoinAddress(),
|
||||||
|
false,
|
||||||
|
vucDomain,
|
||||||
|
true,
|
||||||
|
uRate,
|
||||||
|
false,
|
||||||
|
uint256(),
|
||||||
|
0);
|
||||||
|
|
||||||
|
trans = mNetOps->submitTransaction(trans);
|
||||||
|
|
||||||
|
obj["transaction"] = trans->getSTransaction()->getJson(0);
|
||||||
|
obj["status"] = trans->getStatus();
|
||||||
|
|
||||||
|
return Json::Value(Json::objectValue);
|
||||||
|
}
|
||||||
|
|
||||||
// account_wallet_set <seed> <paying_account> [<wallet_hash>]
|
// account_wallet_set <seed> <paying_account> [<wallet_hash>]
|
||||||
Json::Value RPCServer::doAccountWalletSet(const Json::Value& params) {
|
Json::Value RPCServer::doAccountWalletSet(const Json::Value& params) {
|
||||||
NewcoinAddress naSrcAccountID;
|
NewcoinAddress naSrcAccountID;
|
||||||
@@ -603,6 +788,7 @@ Json::Value RPCServer::doAccountWalletSet(const Json::Value& params) {
|
|||||||
STAmount saSrcBalance;
|
STAmount saSrcBalance;
|
||||||
Json::Value obj = authorize(uLedger, naSeed, naSrcAccountID, naAccountPublic, naAccountPrivate,
|
Json::Value obj = authorize(uLedger, naSeed, naSrcAccountID, naAccountPublic, naAccountPrivate,
|
||||||
saSrcBalance, theConfig.FEE_DEFAULT, asSrc, naMasterGenerator);
|
saSrcBalance, theConfig.FEE_DEFAULT, asSrc, naMasterGenerator);
|
||||||
|
std::vector<unsigned char> vucDomain;
|
||||||
|
|
||||||
if (!obj.empty())
|
if (!obj.empty())
|
||||||
return obj;
|
return obj;
|
||||||
@@ -610,6 +796,7 @@ Json::Value RPCServer::doAccountWalletSet(const Json::Value& params) {
|
|||||||
std::string strWalletLocator = params.size() == 3 ? params[2u].asString() : "";
|
std::string strWalletLocator = params.size() == 3 ? params[2u].asString() : "";
|
||||||
uint256 uWalletLocator;
|
uint256 uWalletLocator;
|
||||||
|
|
||||||
|
if (!strWalletLocator.empty())
|
||||||
uWalletLocator.SetHex(strWalletLocator);
|
uWalletLocator.SetHex(strWalletLocator);
|
||||||
|
|
||||||
Transaction::pointer trans = Transaction::sharedAccountSet(
|
Transaction::pointer trans = Transaction::sharedAccountSet(
|
||||||
@@ -620,9 +807,16 @@ Json::Value RPCServer::doAccountWalletSet(const Json::Value& params) {
|
|||||||
0, // YYY No source tag
|
0, // YYY No source tag
|
||||||
false,
|
false,
|
||||||
uint128(),
|
uint128(),
|
||||||
strWalletLocator.empty(),
|
true,
|
||||||
uWalletLocator,
|
uWalletLocator,
|
||||||
NewcoinAddress());
|
NewcoinAddress(),
|
||||||
|
false,
|
||||||
|
vucDomain,
|
||||||
|
false,
|
||||||
|
0,
|
||||||
|
false,
|
||||||
|
uint256(),
|
||||||
|
0);
|
||||||
|
|
||||||
trans = mNetOps->submitTransaction(trans);
|
trans = mNetOps->submitTransaction(trans);
|
||||||
|
|
||||||
@@ -2117,9 +2311,12 @@ Json::Value RPCServer::doCommand(const std::string& command, Json::Value& params
|
|||||||
bool mAdminRequired;
|
bool mAdminRequired;
|
||||||
unsigned int iOptions;
|
unsigned int iOptions;
|
||||||
} commandsA[] = {
|
} commandsA[] = {
|
||||||
|
{ "account_domain_set", &RPCServer::doAccountDomainSet, 2, 3, false, optCurrent },
|
||||||
{ "account_email_set", &RPCServer::doAccountEmailSet, 2, 3, false, optCurrent },
|
{ "account_email_set", &RPCServer::doAccountEmailSet, 2, 3, false, optCurrent },
|
||||||
{ "account_info", &RPCServer::doAccountInfo, 1, 2, false, optCurrent },
|
{ "account_info", &RPCServer::doAccountInfo, 1, 2, false, optCurrent },
|
||||||
{ "account_message_set", &RPCServer::doAccountMessageSet, 3, 3, false, optCurrent },
|
{ "account_message_set", &RPCServer::doAccountMessageSet, 3, 3, false, optCurrent },
|
||||||
|
{ "account_publish_set", &RPCServer::doAccountPublishSet, 4, 4, false, optCurrent },
|
||||||
|
{ "account_rate_set", &RPCServer::doAccountRateSet, 3, 3, false, optCurrent },
|
||||||
{ "account_tx", &RPCServer::doAccountTransactions, 2, 3, false, optNetwork },
|
{ "account_tx", &RPCServer::doAccountTransactions, 2, 3, false, optNetwork },
|
||||||
{ "account_wallet_set", &RPCServer::doAccountWalletSet, 2, 3, false, optCurrent },
|
{ "account_wallet_set", &RPCServer::doAccountWalletSet, 2, 3, false, optCurrent },
|
||||||
{ "connect", &RPCServer::doConnect, 1, 2, true },
|
{ "connect", &RPCServer::doConnect, 1, 2, true },
|
||||||
|
|||||||
@@ -125,9 +125,12 @@ private:
|
|||||||
|
|
||||||
Json::Value accountFromString(const uint256& uLedger, NewcoinAddress& naAccount, bool& bIndex, const std::string& strIdent, const int iIndex);
|
Json::Value accountFromString(const uint256& uLedger, NewcoinAddress& naAccount, bool& bIndex, const std::string& strIdent, const int iIndex);
|
||||||
|
|
||||||
|
Json::Value doAccountDomainSet(const Json::Value ¶ms);
|
||||||
Json::Value doAccountEmailSet(const Json::Value ¶ms);
|
Json::Value doAccountEmailSet(const Json::Value ¶ms);
|
||||||
Json::Value doAccountInfo(const Json::Value& params);
|
Json::Value doAccountInfo(const Json::Value& params);
|
||||||
Json::Value doAccountMessageSet(const Json::Value ¶ms);
|
Json::Value doAccountMessageSet(const Json::Value ¶ms);
|
||||||
|
Json::Value doAccountPublishSet(const Json::Value ¶ms);
|
||||||
|
Json::Value doAccountRateSet(const Json::Value ¶ms);
|
||||||
Json::Value doAccountTransactions(const Json::Value& params);
|
Json::Value doAccountTransactions(const Json::Value& params);
|
||||||
Json::Value doAccountWalletSet(const Json::Value ¶ms);
|
Json::Value doAccountWalletSet(const Json::Value ¶ms);
|
||||||
Json::Value doConnect(const Json::Value& params);
|
Json::Value doConnect(const Json::Value& params);
|
||||||
|
|||||||
@@ -85,6 +85,8 @@ enum SOE_Field
|
|||||||
sfPaths,
|
sfPaths,
|
||||||
sfPaysIssuer,
|
sfPaysIssuer,
|
||||||
sfPubKey,
|
sfPubKey,
|
||||||
|
sfPublishHash,
|
||||||
|
sfPublishSize,
|
||||||
sfQualityIn,
|
sfQualityIn,
|
||||||
sfQualityOut,
|
sfQualityOut,
|
||||||
sfSendMax,
|
sfSendMax,
|
||||||
|
|||||||
@@ -117,25 +117,41 @@ bool Transaction::sign(const NewcoinAddress& naAccountPrivate)
|
|||||||
|
|
||||||
Transaction::pointer Transaction::setAccountSet(
|
Transaction::pointer Transaction::setAccountSet(
|
||||||
const NewcoinAddress& naPrivateKey,
|
const NewcoinAddress& naPrivateKey,
|
||||||
bool bUnsetEmailHash,
|
bool bEmailHash,
|
||||||
const uint128& uEmailHash,
|
const uint128& uEmailHash,
|
||||||
bool bUnsetWalletLocator,
|
bool bWalletLocator,
|
||||||
const uint256& uWalletLocator,
|
const uint256& uWalletLocator,
|
||||||
const NewcoinAddress& naMessagePublic)
|
const NewcoinAddress& naMessagePublic,
|
||||||
|
bool bDomain,
|
||||||
|
const std::vector<unsigned char>& vucDomain,
|
||||||
|
bool bTransferRate,
|
||||||
|
const uint32 uTransferRate,
|
||||||
|
bool bPublish,
|
||||||
|
const uint256& uPublishHash,
|
||||||
|
const uint32 uPublishSize
|
||||||
|
)
|
||||||
{
|
{
|
||||||
mTransaction->setITFieldU32(sfFlags,
|
if (!bEmailHash)
|
||||||
(bUnsetEmailHash ? tfUnsetEmailHash : 0)
|
|
||||||
| (bUnsetWalletLocator ? tfUnsetWalletLocator : 0));
|
|
||||||
|
|
||||||
if (!bUnsetEmailHash && !!uEmailHash)
|
|
||||||
mTransaction->setITFieldH128(sfEmailHash, uEmailHash);
|
mTransaction->setITFieldH128(sfEmailHash, uEmailHash);
|
||||||
|
|
||||||
if (!bUnsetWalletLocator && !!uWalletLocator)
|
if (!bWalletLocator)
|
||||||
mTransaction->setITFieldH256(sfWalletLocator, uWalletLocator);
|
mTransaction->setITFieldH256(sfWalletLocator, uWalletLocator);
|
||||||
|
|
||||||
if (naMessagePublic.isValid())
|
if (naMessagePublic.isValid())
|
||||||
mTransaction->setITFieldVL(sfMessageKey, naMessagePublic.getAccountPublic());
|
mTransaction->setITFieldVL(sfMessageKey, naMessagePublic.getAccountPublic());
|
||||||
|
|
||||||
|
if (bDomain)
|
||||||
|
mTransaction->setITFieldVL(sfDomain, vucDomain);
|
||||||
|
|
||||||
|
if (bTransferRate)
|
||||||
|
mTransaction->setITFieldU32(sfTransferRate, uTransferRate);
|
||||||
|
|
||||||
|
if (bPublish)
|
||||||
|
{
|
||||||
|
mTransaction->setITFieldH256(sfPublishHash, uPublishHash);
|
||||||
|
mTransaction->setITFieldU32(sfPublishSize, uPublishSize);
|
||||||
|
}
|
||||||
|
|
||||||
sign(naPrivateKey);
|
sign(naPrivateKey);
|
||||||
|
|
||||||
return shared_from_this();
|
return shared_from_this();
|
||||||
@@ -147,15 +163,24 @@ Transaction::pointer Transaction::sharedAccountSet(
|
|||||||
uint32 uSeq,
|
uint32 uSeq,
|
||||||
const STAmount& saFee,
|
const STAmount& saFee,
|
||||||
uint32 uSourceTag,
|
uint32 uSourceTag,
|
||||||
bool bUnsetEmailHash,
|
bool bEmailHash,
|
||||||
const uint128& uEmailHash,
|
const uint128& uEmailHash,
|
||||||
bool bUnsetWalletLocator,
|
bool bWalletLocator,
|
||||||
const uint256& uWalletLocator,
|
const uint256& uWalletLocator,
|
||||||
const NewcoinAddress& naMessagePublic)
|
const NewcoinAddress& naMessagePublic,
|
||||||
|
bool bDomain,
|
||||||
|
const std::vector<unsigned char>& vucDomain,
|
||||||
|
bool bTransferRate,
|
||||||
|
const uint32 uTransferRate,
|
||||||
|
bool bPublish,
|
||||||
|
const uint256& uPublishHash,
|
||||||
|
const uint32 uPublishSize)
|
||||||
{
|
{
|
||||||
pointer tResult = boost::make_shared<Transaction>(ttACCOUNT_SET, naPublicKey, naSourceAccount, uSeq, saFee, uSourceTag);
|
pointer tResult = boost::make_shared<Transaction>(ttACCOUNT_SET, naPublicKey, naSourceAccount, uSeq, saFee, uSourceTag);
|
||||||
|
|
||||||
return tResult->setAccountSet(naPrivateKey, bUnsetEmailHash, uEmailHash, bUnsetWalletLocator, uWalletLocator, naMessagePublic);
|
return tResult->setAccountSet(naPrivateKey, bEmailHash, uEmailHash, bWalletLocator, uWalletLocator,
|
||||||
|
naMessagePublic,
|
||||||
|
bDomain, vucDomain, bTransferRate, uTransferRate, bPublish, uPublishHash, uPublishSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -48,11 +48,18 @@ private:
|
|||||||
|
|
||||||
Transaction::pointer setAccountSet(
|
Transaction::pointer setAccountSet(
|
||||||
const NewcoinAddress& naPrivateKey,
|
const NewcoinAddress& naPrivateKey,
|
||||||
bool bUnsetEmailHash,
|
bool bEmailHash,
|
||||||
const uint128& uEmailHash,
|
const uint128& uEmailHash,
|
||||||
bool bUnsetWalletLocator,
|
bool bWalletLocator,
|
||||||
const uint256& uWalletLocator,
|
const uint256& uWalletLocator,
|
||||||
const NewcoinAddress& naMessagePublic);
|
const NewcoinAddress& naMessagePublic,
|
||||||
|
bool bDomain,
|
||||||
|
const std::vector<unsigned char>& vucDomain,
|
||||||
|
bool bTransferRate,
|
||||||
|
const uint32 uTransferRate,
|
||||||
|
bool bPublish,
|
||||||
|
const uint256& uPublishHash,
|
||||||
|
const uint32 uPublishSize);
|
||||||
|
|
||||||
Transaction::pointer setClaim(
|
Transaction::pointer setClaim(
|
||||||
const NewcoinAddress& naPrivateKey,
|
const NewcoinAddress& naPrivateKey,
|
||||||
@@ -138,11 +145,18 @@ public:
|
|||||||
uint32 uSeq,
|
uint32 uSeq,
|
||||||
const STAmount& saFee,
|
const STAmount& saFee,
|
||||||
uint32 uSourceTag,
|
uint32 uSourceTag,
|
||||||
bool bUnsetEmailHash,
|
bool bEmailHash,
|
||||||
const uint128& uEmailHash,
|
const uint128& uEmailHash,
|
||||||
bool bUnsetWalletLocator,
|
bool bWalletLocator,
|
||||||
const uint256& uWalletLocator,
|
const uint256& uWalletLocator,
|
||||||
const NewcoinAddress& naMessagePublic);
|
const NewcoinAddress& naMessagePublic,
|
||||||
|
bool bDomain,
|
||||||
|
const std::vector<unsigned char>& vucDomain,
|
||||||
|
bool bTransferRate,
|
||||||
|
const uint32 uTransferRate,
|
||||||
|
bool bPublish,
|
||||||
|
const uint256& uPublishHash,
|
||||||
|
const uint32 uPublishSize);
|
||||||
|
|
||||||
// Claim a wallet.
|
// Claim a wallet.
|
||||||
static Transaction::pointer sharedClaim(
|
static Transaction::pointer sharedClaim(
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ bool transResultInfo(TransactionEngineResult terCode, std::string& strToken, std
|
|||||||
{ tenBAD_ISSUER, "tenBAD_ISSUER", "Malformed." },
|
{ tenBAD_ISSUER, "tenBAD_ISSUER", "Malformed." },
|
||||||
{ tenBAD_OFFER, "tenBAD_OFFER", "Malformed." },
|
{ tenBAD_OFFER, "tenBAD_OFFER", "Malformed." },
|
||||||
{ tenBAD_PATH_COUNT, "tenBAD_PATH_COUNT", "Malformed: too many paths." },
|
{ tenBAD_PATH_COUNT, "tenBAD_PATH_COUNT", "Malformed: too many paths." },
|
||||||
|
{ tenBAD_PUBLISH, "tenBAD_PUBLISH", "Malformed: bad publish." },
|
||||||
{ tenBAD_RIPPLE, "tenBAD_RIPPLE", "Ledger prevents ripple from succeeding." },
|
{ tenBAD_RIPPLE, "tenBAD_RIPPLE", "Ledger prevents ripple from succeeding." },
|
||||||
{ tenBAD_SET_ID, "tenBAD_SET_ID", "Malformed." },
|
{ tenBAD_SET_ID, "tenBAD_SET_ID", "Malformed." },
|
||||||
{ tenCLAIMED, "tenCLAIMED", "Can not claim a previously claimed account." },
|
{ tenCLAIMED, "tenCLAIMED", "Can not claim a previously claimed account." },
|
||||||
@@ -1203,42 +1204,50 @@ TransactionEngineResult TransactionEngine::applyTransaction(const SerializedTran
|
|||||||
|
|
||||||
TransactionEngineResult TransactionEngine::doAccountSet(const SerializedTransaction& txn)
|
TransactionEngineResult TransactionEngine::doAccountSet(const SerializedTransaction& txn)
|
||||||
{
|
{
|
||||||
std::cerr << "doAccountSet>" << std::endl;
|
Log(lsINFO) << "doAccountSet>";
|
||||||
|
|
||||||
uint32 txFlags = txn.getFlags();
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// EmailHash
|
// EmailHash
|
||||||
//
|
//
|
||||||
|
|
||||||
if (txFlags & tfUnsetEmailHash)
|
if (txn.getITFieldPresent(sfEmailHash))
|
||||||
{
|
{
|
||||||
std::cerr << "doAccountSet: unset email hash" << std::endl;
|
uint128 uHash = txn.getITFieldH128(sfEmailHash);
|
||||||
|
|
||||||
|
if (uHash.isZero())
|
||||||
|
{
|
||||||
|
Log(lsINFO) << "doAccountSet: unset email hash";
|
||||||
|
|
||||||
mTxnAccount->makeIFieldAbsent(sfEmailHash);
|
mTxnAccount->makeIFieldAbsent(sfEmailHash);
|
||||||
}
|
}
|
||||||
else if (txn.getITFieldPresent(sfEmailHash))
|
else
|
||||||
{
|
{
|
||||||
std::cerr << "doAccountSet: set email hash" << std::endl;
|
Log(lsINFO) << "doAccountSet: set email hash";
|
||||||
|
|
||||||
mTxnAccount->setIFieldH128(sfEmailHash, txn.getITFieldH128(sfEmailHash));
|
mTxnAccount->setIFieldH128(sfEmailHash, uHash);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// WalletLocator
|
// WalletLocator
|
||||||
//
|
//
|
||||||
|
|
||||||
if (txFlags & tfUnsetWalletLocator)
|
if (txn.getITFieldPresent(sfWalletLocator))
|
||||||
{
|
{
|
||||||
std::cerr << "doAccountSet: unset wallet locator" << std::endl;
|
uint256 uHash = txn.getITFieldH256(sfWalletLocator);
|
||||||
|
|
||||||
mTxnAccount->makeIFieldAbsent(sfWalletLocator);
|
if (uHash.isZero())
|
||||||
|
{
|
||||||
|
Log(lsINFO) << "doAccountSet: unset wallet locator";
|
||||||
|
|
||||||
|
mTxnAccount->makeIFieldAbsent(sfEmailHash);
|
||||||
}
|
}
|
||||||
else if (txn.getITFieldPresent(sfWalletLocator))
|
else
|
||||||
{
|
{
|
||||||
std::cerr << "doAccountSet: set wallet locator" << std::endl;
|
Log(lsINFO) << "doAccountSet: set wallet locator";
|
||||||
|
|
||||||
mTxnAccount->setIFieldH256(sfWalletLocator, txn.getITFieldH256(sfWalletLocator));
|
mTxnAccount->setIFieldH256(sfWalletLocator, uHash);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -1248,33 +1257,110 @@ TransactionEngineResult TransactionEngine::doAccountSet(const SerializedTransact
|
|||||||
if (!txn.getITFieldPresent(sfMessageKey))
|
if (!txn.getITFieldPresent(sfMessageKey))
|
||||||
{
|
{
|
||||||
nothing();
|
nothing();
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (mTxnAccount->getIFieldPresent(sfMessageKey))
|
else if (mTxnAccount->getIFieldPresent(sfMessageKey))
|
||||||
{
|
{
|
||||||
std::cerr << "doAccountSet: can not change message key" << std::endl;
|
Log(lsINFO) << "doAccountSet: can not change message key";
|
||||||
|
|
||||||
return tenMSG_SET;
|
return tenMSG_SET;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::cerr << "doAccountSet: set message key" << std::endl;
|
Log(lsINFO) << "doAccountSet: set message key";
|
||||||
|
|
||||||
mTxnAccount->setIFieldVL(sfMessageKey, txn.getITFieldVL(sfMessageKey));
|
mTxnAccount->setIFieldVL(sfMessageKey, txn.getITFieldVL(sfMessageKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cerr << "doAccountSet<" << std::endl;
|
//
|
||||||
|
// Domain
|
||||||
|
//
|
||||||
|
|
||||||
|
if (txn.getITFieldPresent(sfDomain))
|
||||||
|
{
|
||||||
|
std::vector<unsigned char> vucDomain = txn.getITFieldVL(sfDomain);
|
||||||
|
|
||||||
|
if (vucDomain.empty())
|
||||||
|
{
|
||||||
|
Log(lsINFO) << "doAccountSet: unset domain";
|
||||||
|
|
||||||
|
mTxnAccount->makeIFieldAbsent(sfDomain);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Log(lsINFO) << "doAccountSet: set domain";
|
||||||
|
|
||||||
|
mTxnAccount->setIFieldVL(sfDomain, vucDomain);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// TransferRate
|
||||||
|
//
|
||||||
|
|
||||||
|
if (txn.getITFieldPresent(sfTransferRate))
|
||||||
|
{
|
||||||
|
uint32 uRate = txn.getITFieldU32(sfTransferRate);
|
||||||
|
|
||||||
|
if (!uRate)
|
||||||
|
{
|
||||||
|
Log(lsINFO) << "doAccountSet: unset transfer rate";
|
||||||
|
|
||||||
|
mTxnAccount->makeIFieldAbsent(sfTransferRate);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Log(lsINFO) << "doAccountSet: set transfer rate";
|
||||||
|
|
||||||
|
mTxnAccount->setIFieldU32(sfTransferRate, uRate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// PublishHash && PublishSize
|
||||||
|
//
|
||||||
|
|
||||||
|
bool bPublishHash = txn.getITFieldPresent(sfPublishHash);
|
||||||
|
bool bPublishSize = txn.getITFieldPresent(sfPublishSize);
|
||||||
|
|
||||||
|
if (bPublishHash ^ bPublishSize)
|
||||||
|
{
|
||||||
|
Log(lsINFO) << "doAccountSet: bad publish";
|
||||||
|
|
||||||
|
return tenBAD_PUBLISH;
|
||||||
|
}
|
||||||
|
else if (bPublishHash && bPublishSize)
|
||||||
|
{
|
||||||
|
uint256 uHash = txn.getITFieldH256(sfPublishHash);
|
||||||
|
uint32 uSize = txn.getITFieldU32(sfPublishSize);
|
||||||
|
|
||||||
|
if (uHash.isZero())
|
||||||
|
{
|
||||||
|
Log(lsINFO) << "doAccountSet: unset publish";
|
||||||
|
|
||||||
|
mTxnAccount->makeIFieldAbsent(sfPublishHash);
|
||||||
|
mTxnAccount->makeIFieldAbsent(sfPublishSize);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Log(lsINFO) << "doAccountSet: set publish";
|
||||||
|
|
||||||
|
mTxnAccount->setIFieldH256(sfPublishHash, uHash);
|
||||||
|
mTxnAccount->setIFieldU32(sfPublishSize, uSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Log(lsINFO) << "doAccountSet<";
|
||||||
|
|
||||||
return terSUCCESS;
|
return terSUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
TransactionEngineResult TransactionEngine::doClaim(const SerializedTransaction& txn)
|
TransactionEngineResult TransactionEngine::doClaim(const SerializedTransaction& txn)
|
||||||
{
|
{
|
||||||
std::cerr << "doClaim>" << std::endl;
|
Log(lsINFO) << "doClaim>";
|
||||||
|
|
||||||
TransactionEngineResult terResult = setAuthorized(txn, true);
|
TransactionEngineResult terResult = setAuthorized(txn, true);
|
||||||
|
|
||||||
std::cerr << "doClaim<" << std::endl;
|
Log(lsINFO) << "doClaim<";
|
||||||
|
|
||||||
return terResult;
|
return terResult;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ enum TransactionEngineResult
|
|||||||
tenBAD_ISSUER,
|
tenBAD_ISSUER,
|
||||||
tenBAD_OFFER,
|
tenBAD_OFFER,
|
||||||
tenBAD_PATH_COUNT,
|
tenBAD_PATH_COUNT,
|
||||||
|
tenBAD_PUBLISH,
|
||||||
tenBAD_SET_ID,
|
tenBAD_SET_ID,
|
||||||
tenCREATEXNS,
|
tenCREATEXNS,
|
||||||
tenDST_IS_SRC,
|
tenDST_IS_SRC,
|
||||||
|
|||||||
@@ -12,6 +12,9 @@ TransactionFormat InnerTxnFormats[]=
|
|||||||
{ S_FIELD(WalletLocator), STI_HASH256, SOE_IFFLAG, 4 },
|
{ S_FIELD(WalletLocator), STI_HASH256, SOE_IFFLAG, 4 },
|
||||||
{ S_FIELD(MessageKey), STI_VL, SOE_IFFLAG, 8 },
|
{ S_FIELD(MessageKey), STI_VL, SOE_IFFLAG, 8 },
|
||||||
{ S_FIELD(Domain), STI_VL, SOE_IFFLAG, 16 },
|
{ S_FIELD(Domain), STI_VL, SOE_IFFLAG, 16 },
|
||||||
|
{ S_FIELD(TransferRate), STI_UINT32, SOE_IFFLAG, 32 },
|
||||||
|
{ S_FIELD(PublishHash), STI_HASH256, SOE_IFFLAG, 64 },
|
||||||
|
{ S_FIELD(PublishSize), STI_UINT32, SOE_IFFLAG, 128 },
|
||||||
{ S_FIELD(Extensions), STI_TL, SOE_IFFLAG, 0x02000000 },
|
{ S_FIELD(Extensions), STI_TL, SOE_IFFLAG, 0x02000000 },
|
||||||
{ sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } }
|
{ sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } }
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -39,10 +39,6 @@ const int TransactionMaxLen = 1048576;
|
|||||||
// Transaction flags.
|
// Transaction flags.
|
||||||
//
|
//
|
||||||
|
|
||||||
// AccountSet flags:
|
|
||||||
const uint32 tfUnsetEmailHash = 0x00010000;
|
|
||||||
const uint32 tfUnsetWalletLocator = 0x00020000;
|
|
||||||
|
|
||||||
// OfferCreate flags:
|
// OfferCreate flags:
|
||||||
const uint32 tfPassive = 0x00010000;
|
const uint32 tfPassive = 0x00010000;
|
||||||
|
|
||||||
|
|||||||
@@ -38,10 +38,13 @@ void printHelp(const po::options_description& desc)
|
|||||||
cout << desc << endl;
|
cout << desc << endl;
|
||||||
|
|
||||||
cout << "Commands: " << endl;
|
cout << "Commands: " << endl;
|
||||||
|
cout << " account_domain_set <seed> <paying_account> [<domain>]" << endl;
|
||||||
cout << " account_email_set <seed> <paying_account> [<email_address>]" << endl;
|
cout << " account_email_set <seed> <paying_account> [<email_address>]" << endl;
|
||||||
cout << " account_info <account>|<nickname>" << endl;
|
cout << " account_info <account>|<nickname>" << endl;
|
||||||
cout << " account_info <seed>|<pass_phrase>|<key> [<index>]" << endl;
|
cout << " account_info <seed>|<pass_phrase>|<key> [<index>]" << endl;
|
||||||
cout << " account_message_set <seed> <paying_account> <pub_key>" << endl;
|
cout << " account_message_set <seed> <paying_account> <pub_key>" << endl;
|
||||||
|
cout << " account_publish_set <seed> <paying_account> <hash> <size>" << endl;
|
||||||
|
cout << " account_rate_set <seed> <paying_account> <rate>" << endl;
|
||||||
cout << " account_wallet_set <seed> <paying_account> [<wallet_hash>]" << endl;
|
cout << " account_wallet_set <seed> <paying_account> [<wallet_hash>]" << endl;
|
||||||
cout << " connect <ip> [<port>]" << endl;
|
cout << " connect <ip> [<port>]" << endl;
|
||||||
cout << " data_delete <key>" << endl;
|
cout << " data_delete <key>" << endl;
|
||||||
|
|||||||
Reference in New Issue
Block a user