From 75f1eb80a46cbd26d2c33c3bfae36ed9f637d1ca Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Mon, 28 Nov 2011 19:33:50 -0800 Subject: [PATCH] Make these pieces work together. --- Config.cpp | 1 - Makefile | 2 +- NewcoinAddress.cpp | 2 +- Transaction.cpp | 2 +- UniqueNodeList.h | 4 ++-- Wallet.cpp | 16 ++++++++++++---- Wallet.h | 8 ++++---- 7 files changed, 21 insertions(+), 14 deletions(-) diff --git a/Config.cpp b/Config.cpp index 517d2a20d..d33905b19 100644 --- a/Config.cpp +++ b/Config.cpp @@ -1,6 +1,5 @@ #include "Config.h" #include "util/pugixml.hpp" -#include "Application.h" #include diff --git a/Makefile b/Makefile index b10864b7f..b4403e06a 100644 --- a/Makefile +++ b/Makefile @@ -69,7 +69,7 @@ HEADERS = \ SRCS= \ test.cpp Hanko.cpp Transaction.cpp SHAMap.cpp SHAMapNodes.cpp Serializer.cpp Ledger.cpp \ - AccountState.cpp + AccountState.cpp Wallet.cpp NewcoinAddress.cpp Config.cpp util/pugixml.o # Application.cpp HttpReply.cpp main.cpp RPCCommands.cpp \ diff --git a/NewcoinAddress.cpp b/NewcoinAddress.cpp index 5efa25a32..1ce4af930 100644 --- a/NewcoinAddress.cpp +++ b/NewcoinAddress.cpp @@ -59,7 +59,7 @@ NewcoinAddress::NewcoinAddress(const char* pszAddress) SetString(pszAddress); } -uint160 NewcoinAddress::GetHash160() +uint160 NewcoinAddress::GetHash160() const { assert(vchData.size() == 20); uint160 hash160; diff --git a/Transaction.cpp b/Transaction.cpp index 0e5c8608c..effe080b3 100644 --- a/Transaction.cpp +++ b/Transaction.cpp @@ -48,7 +48,7 @@ bool Transaction::sign(LocalAccount& fromLocalAccount) { if( (mAmount==0) || (mSourceLedger==0) || (mAccountTo==0) ) return false; - if(mAccountFrom!=fromLocalAccount.mAddress) + if(mAccountFrom!=fromLocalAccount.mAddress.GetHash160()) return false; Serializer::pointer signBuf=getRaw(true); if(!signBuf->makeSignature(mSignature, fromLocalAccount.peekPrivKey())) diff --git a/UniqueNodeList.h b/UniqueNodeList.h index 0d9d334b5..dc7d311f0 100644 --- a/UniqueNodeList.h +++ b/UniqueNodeList.h @@ -6,7 +6,7 @@ class UniqueNodeList { // hanko to public key - //std::map mUNL; + //std::map mUNL; public: //void load(); //void save(); @@ -15,7 +15,7 @@ public: void removeNode(uint160& hanko); // 0- we don't care, 1- we care and is valid, 2-invalid signature - int checkValid(newcoin::Validation& valid); +// int checkValid(newcoin::Validation& valid); void dumpUNL(std::string& retStr); diff --git a/Wallet.cpp b/Wallet.cpp index d3a540dd1..ec42a9217 100644 --- a/Wallet.cpp +++ b/Wallet.cpp @@ -1,11 +1,16 @@ #include "Wallet.h" #include "NewcoinAddress.h" -#include "Conversion.h" -#include "Application.h" -#include "LedgerMaster.h" #include #include -using namespace std; + +LocalAccount::LocalAccount(bool) +{ + mPrivateKey.MakeNewKey(); + mPublicKey.SetPubKey(mPrivateKey.GetPubKey()); + mAddress.SetPubKey(mPublicKey.GetPubKey()); +} + +#if 0 Wallet::Wallet() { @@ -170,3 +175,6 @@ bool Wallet::commitTransaction(TransactionPtr trans) } return(false); } + +#endif + diff --git a/Wallet.h b/Wallet.h index a92cbecfb..ef5958bd4 100644 --- a/Wallet.h +++ b/Wallet.h @@ -2,9 +2,8 @@ #define __WALLET__ #include "keystore.h" -#include "newcoin.pb.h" -#include "Transaction.h" #include "Serializer.h" +#include "Transaction.h" #include #include @@ -18,18 +17,19 @@ class LocalAccount public: //CKey mKey; //std::string mHumanAddress; - uint160 mAddress; + NewcoinAddress mAddress; CKey mPublicKey, mPrivateKey; int64 mAmount; uint32 mSeqNum; + LocalAccount(bool); // create a new local acount bool signRaw(Serializer::pointer); bool signRaw(Serializer::pointer, std::vector& signature); bool checkSignRaw(Serializer::pointer, int signaturePosition=-1, int signedData=-1); CKey& peekPrivKey() { return mPrivateKey; } CKey& peekPubKey() { return mPublicKey; } - const uint160& getAddress(void) const { return mAddress; } + uint160 getAddress(void) const { return mAddress.GetHash160(); } }; class Wallet : public CBasicKeyStore