diff --git a/database/win/windatabase.cpp b/database/win/windatabase.cpp
index 8ba8db795..8f69c4a37 100644
--- a/database/win/windatabase.cpp
+++ b/database/win/windatabase.cpp
@@ -1,6 +1,8 @@
#include "windatabase.h"
#include "dbutility.h"
+using namespace std;
+
Database* Database::newMysqlDatabase(const char* host,const char* user,const char* pass)
{
return(new WinDatabase(host,user,pass));
@@ -71,7 +73,7 @@ int WinDatabase::getNumRowsAffected()
}
// returns true if the query went ok
-bool WinDatabase::executeSQL(const char* sql)
+bool WinDatabase::executeSQL(const char* sql, bool fail_okay)
{
SQLRETURN rc = SQLExecDirect(hstmt,(unsigned char*) sql,SQL_NTS);
if(rc==SQL_ERROR)
@@ -120,8 +122,7 @@ bool WinDatabase::startIterRows()
if(mNumCol)
{
- delete[](mColNameTable);
- mColNameTable=new i4_str[mNumCol];
+ mColNameTable.resize(mNumCol);
// fill out the column name table
for(int n = 1; n <= mNumCol; n++)
@@ -149,14 +150,14 @@ bool WinDatabase::getNextRow()
char* WinDatabase::getStr(int colIndex,string& retStr)
{
colIndex++;
- (*retStr)="";
+ retStr="";
char buf[1000];
// SQLINTEGER len;
buf[0]=0;
while(SQLGetData(hstmt, colIndex, SQL_C_CHAR, &buf, 1000,NULL)!= SQL_NO_DATA)
{
- (*retStr) += buf;
+ retStr += buf;
// theUI->statusMsg("Win: %s",buf);
}
@@ -166,7 +167,7 @@ char* WinDatabase::getStr(int colIndex,string& retStr)
//theUI->statusMsg("Win: %s",buf);
- return(*retStr);
+ return((char*)retStr.c_str());
}
int32 WinDatabase::getInt(int colIndex)
@@ -210,3 +211,29 @@ void WinDatabase::endIterRows()
rc = SQLFreeStmt(hstmt, SQL_CLOSE);
mystmt(hstmt,rc);
}
+
+// TODO
+void WinDatabase::escape(const unsigned char* start,int size,std::string& retStr)
+{
+ retStr=(char*)start;
+}
+
+// TODO
+int WinDatabase::getLastInsertID()
+{
+ return(0);
+}
+
+uint64 WinDatabase::getBigInt(int colIndex)
+{
+ colIndex++;
+ uint64 ret=0;
+ SQLRETURN rc = SQLGetData(hstmt,colIndex,SQL_INTEGER,&ret,sizeof(uint64),NULL);
+ mystmt(hstmt,rc);
+ return(ret);
+}
+// TODO:
+int WinDatabase::getBinary(int colIndex,unsigned char* buf,int maxSize)
+{
+ return(0);
+}
\ No newline at end of file
diff --git a/database/win/windatabase.h b/database/win/windatabase.h
index 4d2497be3..ddbfaa98b 100644
--- a/database/win/windatabase.h
+++ b/database/win/windatabase.h
@@ -30,7 +30,7 @@ public:
//char* getPass(){ return((char*)mDBPass.c_str()); }
// returns true if the query went ok
- bool executeSQL(const char* sql);
+ bool executeSQL(const char* sql, bool fail_okay=false);
int getNumRowsAffected();
int getLastInsertID();
@@ -49,9 +49,10 @@ public:
float getFloat(int colIndex);
bool getBool(int colIndex);
uint64 getBigInt(int colIndex);
- bool getBinary(int colIndex,unsigned char* buf,int maxSize);
+ int getBinary(int colIndex,unsigned char* buf,int maxSize);
+ bool getNull(int colIndex){ return(true); }
- void escape(unsigned char* start,int size,std::string& retStr);
+ void escape(const unsigned char* start,int size,std::string& retStr);
};
diff --git a/newcoin.vcxproj b/newcoin.vcxproj
index b33684e27..da9d0d013 100644
--- a/newcoin.vcxproj
+++ b/newcoin.vcxproj
@@ -19,13 +19,13 @@
Application
true
- Unicode
+ MultiByte
Application
false
true
- Unicode
+ MultiByte
@@ -48,14 +48,14 @@
NotUsing
Level3
Disabled
- _CRT_SECURE_NO_WARNINGS;_WIN32_WINNT=0x0501;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ BOOST_TEST_NO_MAIN;_CRT_SECURE_NO_WARNINGS;_WIN32_WINNT=0x0501;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
..\OpenSSL\include;..\boost_1_47_0;..\protobuf-2.4.1\src\
Console
true
..\OpenSSL\lib\VC;..\boost_1_47_0\stage\lib;..\protobuf-2.4.1\vsprojects\Debug
- libeay32MTd.lib;libprotobuf.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+ ssleay32MDd.lib;libeay32MTd.lib;libprotobuf.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
@@ -72,62 +72,84 @@
MaxSpeed
true
true
- _CRT_SECURE_NO_WARNINGS;_WIN32_WINNT=0x0501;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
- C:\code\boost_1_47_0;C:\code\protobuf-2.4.1\src\google
+ BOOST_TEST_NO_MAIN;_CRT_SECURE_NO_WARNINGS;_WIN32_WINNT=0x0501;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ ..\OpenSSL\include;..\boost_1_47_0;..\protobuf-2.4.1\src
Console
true
true
true
- C:\code\OpenSSL\lib\VC;C:\code\boost_1_47_0\stage\lib;
+ ..\OpenSSL\lib\VC;..\boost_1_47_0\stage\lib;..\protobuf-2.4.1\vsprojects\Release
+ libprotobuf.lib;ssleay32MD.lib;libeay32MD.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -161,8 +183,8 @@
-
+
@@ -189,11 +211,6 @@
-
- Document
- ..\protoc-2.4.1-win32\protoc -I=..\newcoin --cpp_out=..\newcoin ..\newcoin\newcoin.proto
- newcoin.pb.h
-
Designer
@@ -201,7 +218,15 @@
-
+
+ Document
+ ..\protoc-2.4.1-win32\protoc -I=..\newcoin\src --cpp_out=..\newcoin\obj\src ..\newcoin\src\newcoin.proto
+ obj\src\newcoin.pb.h
+
+
+
+ Designer
+
diff --git a/newcoin.vcxproj.filters b/newcoin.vcxproj.filters
index adcd59cbc..c9ffce30c 100644
--- a/newcoin.vcxproj.filters
+++ b/newcoin.vcxproj.filters
@@ -37,110 +37,20 @@
{b27b04b8-1c6e-4b20-9364-f18d4682dc00}
+
+ {60c3631e-8855-4a61-bdd3-9892d96242d5}
+
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Header Files\util
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Header Files\util
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
Source Files\cryptopp
Source Files\cryptopp
-
- Header Files\util
-
-
- Header Files\util
-
Header Files\util
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
Source Files\json
@@ -150,25 +60,181 @@
Source Files\json
-
+
Source Files
-
+
Source Files
-
+
Source Files
-
+
Source Files
-
+
Source Files
-
+
Source Files
-
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files\database
+
+
+ Source Files\database
+
+
+ Source Files\database
+
+
Source Files
@@ -242,9 +308,6 @@
Header Files
-
- Header Files
-
Header Files
@@ -341,6 +404,9 @@
Header Files
+
+ Header Files
+
@@ -357,8 +423,9 @@
tests\client2
+
-
+
\ No newline at end of file
diff --git a/src/Currency.cpp b/src/Currency.cpp
index df3183427..9c8d4c236 100644
--- a/src/Currency.cpp
+++ b/src/Currency.cpp
@@ -54,6 +54,6 @@ double Amount::getDisplayQuantity() const
{
if(!mCurrency.isNational()) throw std::runtime_error("Can only scale national currencies");
int scale=mCurrency.getScale();
- return static_cast(mQuantity) * pow(10, 128-scale);
+ return static_cast(mQuantity) * pow((double)10, 128-scale);
}
diff --git a/src/Ledger.h b/src/Ledger.h
index 4d9b5fb61..4d330c964 100644
--- a/src/Ledger.h
+++ b/src/Ledger.h
@@ -18,17 +18,17 @@
enum LedgerStateParms
{
- lepNONE = 0, // no special flags
+ lepNONE = 0, // no special flags
// input flags
- lepCREATE, // Create if not present
+ lepCREATE = 1, // Create if not present
// output flags
- lepOKAY, // success
- lepMISSING, // No node in that slot
- lepWRONGTYPE, // Node of different type there
- lepCREATED, // Node was created
- lepERROR, // error
+ lepOKAY = 2, // success
+ lepMISSING = 4, // No node in that slot
+ lepWRONGTYPE = 8, // Node of different type there
+ lepCREATED = 16, // Node was created
+ lepERROR = 32, // error
};
class Ledger : public boost::enable_shared_from_this
diff --git a/src/LedgerFormats.cpp b/src/LedgerFormats.cpp
index 57eea8e2f..919d73ea5 100644
--- a/src/LedgerFormats.cpp
+++ b/src/LedgerFormats.cpp
@@ -55,11 +55,11 @@ LedgerEntryFormat LedgerFormats[]=
LedgerEntryFormat* getLgrFormat(LedgerEntryType t)
{
- LedgerEntryFormat* f=LedgerFormats;
- while(f->t_name!=NULL)
+ LedgerEntryFormat* f = LedgerFormats;
+ while(f->t_name != NULL)
{
- if(f->t_type==t) return f;
- f++;
+ if(f->t_type == t) return f;
+ ++f;
}
return NULL;
}
diff --git a/src/PlatRand.cpp b/src/PlatRand.cpp
index 0500877a0..6db620311 100644
--- a/src/PlatRand.cpp
+++ b/src/PlatRand.cpp
@@ -8,6 +8,9 @@
bool AddSystemEntropy()
{ // Get entropy from the Windows crypto provider
+ RAND_screen(); // this isn't really that safe since it only works for end users not servers
+
+/* TODO: you need the cryptoAPI installed I think for the below to work. I suppose we should require people to install this to build the windows version
char name[512], rand[128];
DWORD count = 500;
HCRYPTOPROV cryptoHandle;
@@ -39,6 +42,8 @@ bool AddSystemEntropy()
CryptReleaseContext(cryptoHandle, 0);
RAND_seed(rand, 128);
+
+*/
return true;
}
diff --git a/src/SHAMap.cpp b/src/SHAMap.cpp
index ad7f42be4..4dbff7f95 100644
--- a/src/SHAMap.cpp
+++ b/src/SHAMap.cpp
@@ -4,6 +4,7 @@
#include
#include
#include
+#include
#include "Serializer.h"
#include "BitcoinUtil.h"
diff --git a/src/SHAMapNodes.cpp b/src/SHAMapNodes.cpp
index ff894c148..25f7133d5 100644
--- a/src/SHAMapNodes.cpp
+++ b/src/SHAMapNodes.cpp
@@ -6,7 +6,7 @@
#include
#include
-
+#include
#include "Serializer.h"
#include "BitcoinUtil.h"
#include "SHAMap.h"
diff --git a/src/SHAMapSync.cpp b/src/SHAMapSync.cpp
index 3138e8939..640512f72 100644
--- a/src/SHAMapSync.cpp
+++ b/src/SHAMapSync.cpp
@@ -4,7 +4,7 @@
#include
#include
-
+#include
#include "SHAMap.h"
void SHAMap::getMissingNodes(std::vector& nodeIDs, std::vector& hashes, int max)
diff --git a/src/SerializedObject.cpp b/src/SerializedObject.cpp
index 7d1ed4680..aef0f9cf7 100644
--- a/src/SerializedObject.cpp
+++ b/src/SerializedObject.cpp
@@ -117,7 +117,7 @@ STObject::STObject(SOElement* elem, SerializerIterator& sit, const char *name) :
if ((flags&elem->e_flags) == 0)
{
done = true;
- giveObject(makeDefaultObject(elem->e_id, elem->e_name));
+ giveObject(makeDefaultObject(STI_NOTPRESENT, elem->e_name));
}
}
else if (elem->e_type == SOE_IFNFLAG)
@@ -126,7 +126,7 @@ STObject::STObject(SOElement* elem, SerializerIterator& sit, const char *name) :
if ((flags&elem->e_flags) != 0)
{
done = true;
- giveObject(makeDefaultObject(STI_NOTPRESENT, elem->e_name));
+ giveObject(makeDefaultObject(elem->e_id, elem->e_name));
}
}
else if (elem->e_type == SOE_FLAGS)
diff --git a/src/TransactionEngine.cpp b/src/TransactionEngine.cpp
index 54154ea04..5651f004d 100644
--- a/src/TransactionEngine.cpp
+++ b/src/TransactionEngine.cpp
@@ -191,12 +191,13 @@ TransactionEngineResult TransactionEngine::applyTransaction(const SerializedTran
// WRITEME: Special case code for changing transaction key
for (std::vector::iterator it=accounts.begin(), end=accounts.end();
it != end; ++it)
- { if (it->first == taaCREATE)
+ {
+ if (it->first == taaCREATE)
{
if (mLedger->writeBack(lepCREATE, it->second) & lepERROR)
assert(false);
}
- else if (it->first==taaMODIFY)
+ else if (it->first == taaMODIFY)
{
if (mLedger->writeBack(lepNONE, it->second) & lepERROR)
assert(false);
@@ -235,7 +236,7 @@ TransactionEngineResult TransactionEngine::doClaim(const SerializedTransaction&
}
LedgerStateParms qry = lepNONE;
- SerializedLedgerEntry::pointer dest = mLedger->getAccountRoot(qry, sourceAccountID);
+ SerializedLedgerEntry::pointer dest = accounts[0].second;
if (!dest)
{
@@ -271,8 +272,6 @@ TransactionEngineResult TransactionEngine::doClaim(const SerializedTransaction&
// Set the public key needed to use the account.
dest->setIFieldH160(sfAuthorizedKey, hGeneratorID);
- accounts.push_back(std::make_pair(taaMODIFY, dest));
-
// Construct a generator map entry.
gen = boost::make_shared(ltGENERATOR_MAP);
@@ -295,6 +294,8 @@ TransactionEngineResult TransactionEngine::doPayment(const SerializedTransaction
// Does the destination account exist?
if (!destAccount) return tenINVALID;
LedgerStateParms qry = lepNONE;
+
+ // FIXME: If this transfer is to the same account, bad things will happen
SerializedLedgerEntry::pointer dest = mLedger->getAccountRoot(qry, destAccount);
if (!dest)
{ // can this transaction create an account
diff --git a/src/TransactionFormats.cpp b/src/TransactionFormats.cpp
index 568d076eb..7f0aa1518 100644
--- a/src/TransactionFormats.cpp
+++ b/src/TransactionFormats.cpp
@@ -55,11 +55,11 @@ TransactionFormat InnerTxnFormats[]=
TransactionFormat* getTxnFormat(TransactionType t)
{
- TransactionFormat* f=InnerTxnFormats;
- while(f->t_name!=NULL)
+ TransactionFormat* f = InnerTxnFormats;
+ while(f->t_name != NULL)
{
- if(f->t_type==t) return f;
- f++;
+ if(f->t_type == t) return f;
+ ++f;
}
return NULL;
}
diff --git a/src/main.cpp b/src/main.cpp
index 153f539a3..489e0b733 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -124,7 +124,7 @@ int main(int argc, char* argv[])
pvCmd.push_back(const_cast(param.c_str()));
}
- iResult = unit_test_main(init_unit_test, iCmd, &pvCmd[0]);
+// iResult = unit_test_main(init_unit_test, iCmd, &pvCmd[0]);
}
else if (!vm.count("parameters"))
{
diff --git a/tests/setup.bat b/tests/setup.bat
index 20d538e20..61304847b 100644
--- a/tests/setup.bat
+++ b/tests/setup.bat
@@ -4,4 +4,3 @@ REM copy C:\code\newcoin\Release\newcoin.exe C:\code\newcoin\tests\client2
copy d:\code\newcoin\Debug\newcoin.exe d:\code\newcoin\tests\client1
copy d:\code\newcoin\Debug\newcoin.exe d:\code\newcoin\tests\client2
-pause
\ No newline at end of file