mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Comment out lots of obsolete LocalAccount stuff.
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
|
||||
#include "UniqueNodeList.h"
|
||||
#include "ConnectionPool.h"
|
||||
#include "PubKeyCache.h"
|
||||
#include "ScopedLock.h"
|
||||
#include "LedgerMaster.h"
|
||||
#include "LedgerAcquire.h"
|
||||
@@ -38,7 +37,6 @@ class Application
|
||||
NetworkOPs mNetOps;
|
||||
Wallet mWallet;
|
||||
UniqueNodeList mUNL;
|
||||
PubKeyCache mPKCache;
|
||||
LedgerMaster mMasterLedger;
|
||||
LedgerAcquireMaster mMasterLedgerAcquire;
|
||||
TransactionMaster mMasterTransaction;
|
||||
@@ -63,8 +61,6 @@ public:
|
||||
Wallet& getWallet() { return mWallet ; }
|
||||
NetworkOPs& getOPs() { return mNetOps; }
|
||||
|
||||
PubKeyCache& getPubKeyCache() { return mPKCache; }
|
||||
|
||||
boost::asio::io_service& getIOService() { return mIOService; }
|
||||
|
||||
LedgerMaster& getMasterLedger() { return mMasterLedger; }
|
||||
|
||||
@@ -11,6 +11,10 @@ bool LocalTransaction::makeTransaction()
|
||||
{
|
||||
if(!!mTransaction) return true;
|
||||
|
||||
std::cerr << "LocalTransaction is obsolete." << std::endl;
|
||||
return false;
|
||||
|
||||
#if 0
|
||||
LocalAccount::pointer lac(theApp->getWallet().findAccountForTransaction(mAmount));
|
||||
if(!lac)
|
||||
{
|
||||
@@ -18,10 +22,6 @@ bool LocalTransaction::makeTransaction()
|
||||
return false;
|
||||
}
|
||||
|
||||
std::cerr << "LocalTransaction is obsolete." << std::endl;
|
||||
return false;
|
||||
|
||||
#if 0
|
||||
mTransaction=Transaction::pointer(new Transaction(lac, mDestAcctID, mAmount, mTag,
|
||||
theApp->getOPs().getCurrentLedgerID()));
|
||||
if(mTransaction->getStatus()!=NEW)
|
||||
|
||||
@@ -160,6 +160,7 @@ bool RPCServer::extractString(std::string& param, const Json::Value& params, int
|
||||
return true;
|
||||
}
|
||||
|
||||
#if 0
|
||||
NewcoinAddress RPCServer::parseFamily(const std::string& fParam)
|
||||
{
|
||||
NewcoinAddress family;
|
||||
@@ -171,6 +172,7 @@ NewcoinAddress RPCServer::parseFamily(const std::string& fParam)
|
||||
|
||||
return family;
|
||||
}
|
||||
#endif
|
||||
|
||||
// account_info <account>|<nickname>|<account_public_key>
|
||||
// account_info <seed>|<pass_phrase>|<key> [<index>]
|
||||
@@ -348,7 +350,9 @@ Json::Value RPCServer::doSendTo(Json::Value& params)
|
||||
if (!extractString(sDest, params, 0) || !extractString(sAmount, params, 1))
|
||||
return JSONRPCError(500, "Invalid parameters");
|
||||
|
||||
NewcoinAddress destAccount = parseAccount(sDest);
|
||||
NewcoinAddress destAccount;
|
||||
|
||||
destAccount.setAccountID(sDest) || destAccount.setAccountPublic(sDest);
|
||||
if (!destAccount.isValid())
|
||||
return JSONRPCError(500, "Unable to parse destination account");
|
||||
|
||||
@@ -400,9 +404,13 @@ Json::Value RPCServer::doTx(Json::Value& params)
|
||||
std::string param1, param2;
|
||||
if (!extractString(param1, params, 0))
|
||||
{ // all local transactions
|
||||
#if 1
|
||||
return "not implemented";
|
||||
#else
|
||||
Json::Value ret(Json::objectValue);
|
||||
theApp->getWallet().addLocalTransactions(ret);
|
||||
return ret;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (Transaction::isHexTxID(param1))
|
||||
@@ -419,13 +427,7 @@ Json::Value RPCServer::doTx(Json::Value& params)
|
||||
|
||||
if (extractString(param2, params, 1))
|
||||
{ // family seq
|
||||
LocalAccount::pointer account=theApp->getWallet().parseAccount(param1+":"+param2);
|
||||
if (!account)
|
||||
return JSONRPCError(500, "Account not found");
|
||||
Json::Value ret;
|
||||
if (!theApp->getWallet().getTxsJson(account->getAddress(), ret))
|
||||
return JSONRPCError(500, "Unable to get wallet transactions");
|
||||
return ret;
|
||||
return "not implemented";
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -626,6 +628,96 @@ Json::Value RPCServer::doWalletClaim(Json::Value& params)
|
||||
}
|
||||
}
|
||||
|
||||
// wallet_create paying_account account_id [initial_funds]
|
||||
Json::Value RPCServer::doWalletCreate(Json::Value& params)
|
||||
{
|
||||
NewcoinAddress naSourceID;
|
||||
NewcoinAddress naCreateID;
|
||||
|
||||
if (params.size() < 2 || params.size() > 3)
|
||||
{
|
||||
return "invalid params";
|
||||
}
|
||||
else if (!naSourceID.setAccountID(params[0u].asString()))
|
||||
{
|
||||
return "source account id needed";
|
||||
}
|
||||
else if (!naCreateID.setAccountID(params[1u].asString()))
|
||||
{
|
||||
return "create account id needed";
|
||||
}
|
||||
else
|
||||
{
|
||||
// Trying to build:
|
||||
// peer_payment
|
||||
//
|
||||
// Which has no confidential information.
|
||||
|
||||
return "not implemented";
|
||||
#if 0
|
||||
// XXX Need better parsing.
|
||||
uint64 uInitalFunds = 0;
|
||||
uint32 uSourceTag = (params.size() == 2) ? 0 : boost::lexical_cast<uint32>(params[2u].asString());
|
||||
// XXX Annotation is ignored.
|
||||
std::string strAnnotation = (params.size() == 3) ? "" : params[3u].asString();
|
||||
|
||||
NewcoinAddress naMasterSeed;
|
||||
NewcoinAddress naMasterGenerator;
|
||||
|
||||
NewcoinAddress naRegularSeed;
|
||||
NewcoinAddress naRegularGenerator;
|
||||
NewcoinAddress naRegularReservedPublic;
|
||||
NewcoinAddress naRegularReservedPrivate;
|
||||
|
||||
NewcoinAddress naAccountPublic;
|
||||
NewcoinAddress naAccountPrivate;
|
||||
|
||||
naMasterSeed.setFamilySeedGeneric(params[0u].asString());
|
||||
naRegularSeed.setFamilySeedGeneric(params[1u].asString());
|
||||
|
||||
naMasterGenerator.setFamilyGenerator(naMasterSeed);
|
||||
naAccountPublic.setAccountPublic(naMasterGenerator, 0);
|
||||
naAccountPrivate.setAccountPrivate(naMasterGenerator, naMasterSeed, 0);
|
||||
|
||||
naRegularGenerator.setFamilyGenerator(naRegularSeed);
|
||||
|
||||
naRegularReservedPublic.setAccountPublic(naRegularGenerator, -1);
|
||||
naRegularReservedPrivate.setAccountPrivate(naRegularGenerator, naRegularSeed, -1);
|
||||
|
||||
// hash of regular account #reserved public key.
|
||||
uint160 uGeneratorID = naRegularReservedPublic.getAccountID();
|
||||
std::vector<unsigned char> vucGeneratorCipher = naRegularReservedPrivate.accountPrivateEncrypt(naRegularReservedPublic, naMasterGenerator.getFamilyGenerator());
|
||||
std::vector<unsigned char> vucGeneratorSig;
|
||||
|
||||
// XXX Check result.
|
||||
naRegularReservedPrivate.accountPrivateSign(Serializer::getSHA512Half(vucGeneratorCipher), vucGeneratorSig);
|
||||
|
||||
Transaction::pointer trns = Transaction::sharedWalletCreate(
|
||||
naAccountPublic, naAccountPrivate,
|
||||
naAccountPublic,
|
||||
uSourceTag,
|
||||
vucGeneratorCipher,
|
||||
naRegularReservedPublic.getAccountPublic(),
|
||||
vucGeneratorSig);
|
||||
|
||||
(void) theApp->getOPs().processTransaction(trns);
|
||||
|
||||
Json::Value obj(Json::objectValue);
|
||||
|
||||
|
||||
obj["account_id"] = naAccountPublic.humanAccountID();
|
||||
obj["generator_id"] = strHex(uGeneratorID);
|
||||
obj["generator"] = strHex(vucGeneratorCipher);
|
||||
obj["annotation"] = strAnnotation;
|
||||
|
||||
obj["transaction"] = trns->getSTransaction()->getJson(0);
|
||||
obj["status"] = trns->getStatus();
|
||||
|
||||
return obj;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
// wallet_propose
|
||||
Json::Value RPCServer::doWalletPropose(Json::Value& params)
|
||||
{
|
||||
@@ -856,21 +948,4 @@ void RPCServer::handle_write(const boost::system::error_code& /*error*/)
|
||||
{
|
||||
}
|
||||
|
||||
NewcoinAddress RPCServer::parseAccount(const std::string& account)
|
||||
{ // FIXME: Support local wallet key names
|
||||
if (account.find(':')!=std::string::npos)
|
||||
{ // local account in family:seq form
|
||||
LocalAccount::pointer lac(theApp->getWallet().parseAccount(account));
|
||||
|
||||
return lac
|
||||
? lac->getAddress()
|
||||
: NewcoinAddress();
|
||||
}
|
||||
|
||||
NewcoinAddress *nap = new NewcoinAddress();
|
||||
|
||||
nap->setAccountID(account) || nap->setAccountPublic(account);
|
||||
|
||||
return *nap;
|
||||
}
|
||||
// vim:ts=4
|
||||
|
||||
@@ -31,18 +31,15 @@ class RPCServer : public boost::enable_shared_from_this<RPCServer>
|
||||
int getParamCount(const Json::Value& params);
|
||||
bool extractString(std::string& param, const Json::Value& params, int index);
|
||||
|
||||
NewcoinAddress parseFamily(const std::string& family);
|
||||
|
||||
Json::Value doAccountInfo(Json::Value& params);
|
||||
Json::Value doLock(Json::Value& params);
|
||||
Json::Value doUnlock(Json::Value& params);
|
||||
Json::Value doSendTo(Json::Value& params);
|
||||
Json::Value doConnect(Json::Value& params);
|
||||
Json::Value doPeers(Json::Value& params);
|
||||
Json::Value doTx(Json::Value& params);
|
||||
Json::Value doLedger(Json::Value& params);
|
||||
Json::Value doAccount(Json::Value& params);
|
||||
Json::Value doPeers(Json::Value& params);
|
||||
Json::Value doSendTo(Json::Value& params);
|
||||
Json::Value doSessionClose(Json::Value& params);
|
||||
Json::Value doSessionOpen(Json::Value& params);
|
||||
Json::Value doStop(Json::Value& params);
|
||||
Json::Value doTx(Json::Value& params);
|
||||
|
||||
Json::Value doUnlAdd(Json::Value& params);
|
||||
Json::Value doUnlDefault(Json::Value& params);
|
||||
@@ -54,12 +51,14 @@ class RPCServer : public boost::enable_shared_from_this<RPCServer>
|
||||
|
||||
Json::Value doValidatorCreate(Json::Value& params);
|
||||
|
||||
Json::Value doWalletAccounts(Json::Value& params);
|
||||
Json::Value doWalletClaim(Json::Value& params);
|
||||
Json::Value doWalletCreate(Json::Value& params);
|
||||
Json::Value doWalletLock(Json::Value& params);
|
||||
Json::Value doWalletPropose(Json::Value& params);
|
||||
Json::Value doWalletSeed(Json::Value& params);
|
||||
Json::Value doWalletUnlock(Json::Value& params);
|
||||
|
||||
// Parses a string account name into a local or remote NewcoinAddress.
|
||||
NewcoinAddress parseAccount(const std::string& account);
|
||||
void validatorsResponse(const boost::system::error_code& err, std::string strResponse);
|
||||
|
||||
public:
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
// LocalAccount - an account
|
||||
//
|
||||
|
||||
#if 0
|
||||
LocalAccount::LocalAccount(boost::shared_ptr<LocalAccountFamily> family, int familySeq) :
|
||||
mPublicKey(family->getPublicKey(familySeq)), mFamily(family), mAccountFSeq(familySeq)
|
||||
{
|
||||
@@ -94,6 +95,7 @@ CKey::pointer LocalAccount::getPrivateKey()
|
||||
{
|
||||
return mFamily->getPrivateKey(mAccountFSeq);
|
||||
}
|
||||
|
||||
//
|
||||
// LocalAccountFamily - a sequences of accounts
|
||||
//
|
||||
@@ -258,10 +260,12 @@ LocalAccount::pointer LocalAccountFamily::get(int seq)
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
Wallet::Wallet() : mLedger(0) {
|
||||
}
|
||||
|
||||
#if 0
|
||||
NewcoinAddress Wallet::addFamily(const NewcoinAddress& familySeed, bool lock)
|
||||
{
|
||||
LocalAccountFamily::pointer fam(doPrivate(familySeed, true, !lock));
|
||||
@@ -324,7 +328,6 @@ bool Wallet::getFamilyInfo(const NewcoinAddress& family, std::string& comment)
|
||||
return true;
|
||||
}
|
||||
|
||||
#if 0
|
||||
bool Wallet::getFullFamilyInfo(const NewcoinAddress& family, std::string& comment,
|
||||
std::string& pubGen, bool& isLocked)
|
||||
{
|
||||
@@ -337,7 +340,6 @@ bool Wallet::getFullFamilyInfo(const NewcoinAddress& family, std::string& commen
|
||||
isLocked=fit->second->isLocked();
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
Json::Value Wallet::getFamilyJson(const NewcoinAddress& family)
|
||||
{
|
||||
@@ -347,6 +349,7 @@ Json::Value Wallet::getFamilyJson(const NewcoinAddress& family)
|
||||
assert(fit->second->getFamily()==family);
|
||||
return fit->second->getJson();
|
||||
}
|
||||
#endif
|
||||
|
||||
void Wallet::start()
|
||||
{
|
||||
@@ -443,6 +446,7 @@ bool Wallet::nodeIdentityCreate() {
|
||||
|
||||
void Wallet::load()
|
||||
{
|
||||
#if 0
|
||||
std::string sql("SELECT * FROM LocalAcctFamilies;");
|
||||
|
||||
ScopedLock sl(theApp->getWalletDB()->getDBLock());
|
||||
@@ -479,8 +483,10 @@ void Wallet::load()
|
||||
} while(db->getNextRow());
|
||||
|
||||
db->endIterRows();
|
||||
#endif
|
||||
}
|
||||
|
||||
#if 0
|
||||
// YYY Perhaps this should take a comment.
|
||||
LocalAccount::pointer Wallet::getNewLocalAccount(const NewcoinAddress& family)
|
||||
{
|
||||
@@ -684,13 +690,16 @@ bool Wallet::lock(const NewcoinAddress& family)
|
||||
fit->second->lock();
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
void Wallet::lock()
|
||||
{
|
||||
#if 0
|
||||
boost::recursive_mutex::scoped_lock sl(mLock);
|
||||
for(std::map<NewcoinAddress, LocalAccountFamily::pointer>::iterator fit=mFamilies.begin();
|
||||
fit!=mFamilies.end(); ++fit)
|
||||
fit->second->lock();
|
||||
#endif
|
||||
}
|
||||
|
||||
bool Wallet::unitTest()
|
||||
@@ -841,6 +850,7 @@ void Wallet::applyTransaction(Transaction::pointer txn)
|
||||
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
void Wallet::addLocalTransactions(Json::Value& ret)
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock sl(mLock);
|
||||
@@ -848,19 +858,22 @@ void Wallet::addLocalTransactions(Json::Value& ret)
|
||||
it!=mTransactions.end(); ++it)
|
||||
ret[it->first.GetHex()]=it->second->getJson();
|
||||
}
|
||||
#endif
|
||||
|
||||
bool Wallet::getTxJson(const uint256& txn, Json::Value& ret)
|
||||
{
|
||||
#if 0
|
||||
boost::recursive_mutex::scoped_lock sl(mLock);
|
||||
std::map<uint256, LocalTransaction::pointer>::iterator it = mTransactions.find(txn);
|
||||
if (it == mTransactions.end()) return false;
|
||||
ret = it->second->getJson();
|
||||
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Wallet::getTxsJson(const NewcoinAddress& account, Json::Value& ret)
|
||||
{
|
||||
#if 0
|
||||
boost::recursive_mutex::scoped_lock sl(mLock);
|
||||
for(std::map<uint256, LocalTransaction::pointer>::iterator it = mTransactions.begin(),
|
||||
end = mTransactions.end(); it != end; ++it)
|
||||
@@ -869,7 +882,7 @@ bool Wallet::getTxsJson(const NewcoinAddress& account, Json::Value& ret)
|
||||
if(txn && (account == txn->getFromAccount())) // FIXME: Need a way to get all accounts a txn affects
|
||||
ret[it->first.GetHex()] = it->second->getJson();
|
||||
}
|
||||
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
// vim:ts=4
|
||||
|
||||
17
src/Wallet.h
17
src/Wallet.h
@@ -16,8 +16,8 @@
|
||||
|
||||
#include "uint256.h"
|
||||
#include "Serializer.h"
|
||||
#include "LocalAccount.h"
|
||||
#include "LocalTransaction.h"
|
||||
// #include "LocalAccount.h"
|
||||
// #include "LocalTransaction.h"
|
||||
|
||||
class Ledger;
|
||||
|
||||
@@ -35,15 +35,16 @@ protected:
|
||||
DH* mDh512;
|
||||
DH* mDh1024;
|
||||
|
||||
uint32 mLedger; // ledger we last synched to
|
||||
|
||||
#if 0
|
||||
std::map<NewcoinAddress, LocalAccountFamily::pointer> mFamilies;
|
||||
std::map<NewcoinAddress, LocalAccount::pointer> mAccounts;
|
||||
std::map<uint256, LocalTransaction::pointer> mTransactions;
|
||||
|
||||
uint32 mLedger; // ledger we last synched to
|
||||
|
||||
LocalAccountFamily::pointer doPrivate(const NewcoinAddress& familySeed, bool do_create, bool do_unlock);
|
||||
LocalAccountFamily::pointer doPublic(const NewcoinAddress& familyGenerator, bool do_create, bool do_db);
|
||||
|
||||
#endif
|
||||
// void addFamily(const NewcoinAddress& family, const std::string& pubKey, int seq, const std::string& name, const std::string& comment);
|
||||
|
||||
public:
|
||||
@@ -58,6 +59,7 @@ public:
|
||||
DH* getDh512() { return DHparams_dup(mDh512); }
|
||||
DH* getDh1024() { return DHparams_dup(mDh1024); }
|
||||
|
||||
#if 0
|
||||
NewcoinAddress addFamily(const std::string& passPhrase, bool lock);
|
||||
NewcoinAddress addFamily(const NewcoinAddress& familySeed, bool lock);
|
||||
NewcoinAddress addFamily(const NewcoinAddress& familyGenerator);
|
||||
@@ -70,10 +72,12 @@ public:
|
||||
void getFamilies(std::vector<NewcoinAddress>& familyIDs);
|
||||
|
||||
bool lock(const NewcoinAddress& familyName);
|
||||
#endif
|
||||
void lock();
|
||||
|
||||
void load();
|
||||
|
||||
#if 0
|
||||
// must be a known local account
|
||||
LocalAccount::pointer parseAccount(const std::string& accountSpecifier);
|
||||
|
||||
@@ -81,18 +85,19 @@ public:
|
||||
LocalAccount::pointer getLocalAccount(const NewcoinAddress& acctID);
|
||||
LocalAccount::pointer getNewLocalAccount(const NewcoinAddress& family);
|
||||
LocalAccount::pointer findAccountForTransaction(uint64 amount);
|
||||
|
||||
NewcoinAddress peekKey(const NewcoinAddress& family, int seq);
|
||||
|
||||
bool getFamilyInfo(const NewcoinAddress& family, std::string& comment);
|
||||
// bool getFullFamilyInfo(const NewcoinAddress& family, std::string& comment, std::string& pubGen, bool& isLocked);
|
||||
|
||||
Json::Value getFamilyJson(const NewcoinAddress& family);
|
||||
#endif
|
||||
bool getTxJson(const uint256& txid, Json::Value& value);
|
||||
bool getTxsJson(const NewcoinAddress& acctid, Json::Value& value);
|
||||
void addLocalTransactions(Json::Value&);
|
||||
|
||||
void syncToLedger(bool force, Ledger* ledger);
|
||||
void applyTransaction(Transaction::pointer);
|
||||
|
||||
static bool unitTest();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user