Merge branch 'api2'

This commit is contained in:
jed
2012-11-12 15:48:04 -08:00
13 changed files with 102 additions and 806 deletions

View File

@@ -20,12 +20,14 @@
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
@@ -49,13 +51,13 @@
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>BOOST_TEST_ALTERNATIVE_INIT_API;BOOST_TEST_NO_MAIN;_CRT_SECURE_NO_WARNINGS;_WIN32_WINNT=0x0501;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>.\src;..\OpenSSL\include;..\boost_1_47_0;..\protobuf-2.4.1\src\</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>.\;..\OpenSSL\include;..\boost_1_52_0;..\protobuf\src</AdditionalIncludeDirectories>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>..\OpenSSL\lib\VC;..\boost_1_47_0\stage\lib;..\protobuf-2.4.1\vsprojects\Debug</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories>..\OpenSSL\lib\VC;..\boost_1_52_0\stage\lib;..\protobuf\vsprojects\Debug</AdditionalLibraryDirectories>
<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)</AdditionalDependencies>
</Link>
<PreBuildEvent>
@@ -137,9 +139,7 @@
<ClCompile Include="src\cpp\ripple\PubKeyCache.cpp" />
<ClCompile Include="src\cpp\ripple\RangeSet.cpp" />
<ClCompile Include="src\cpp\ripple\rfc1751.cpp" />
<ClCompile Include="src\cpp\ripple\ripple.pb.cc">
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\;..\OpenSSL\include;..\boost_1_47_0;..\protobuf-2.4.1\src\</AdditionalIncludeDirectories>
</ClCompile>
<ClCompile Include="src\cpp\ripple\ripple.pb.cc" />
<ClCompile Include="src\cpp\ripple\RippleAddress.cpp" />
<ClCompile Include="src\cpp\ripple\RippleCalc.cpp" />
<ClCompile Include="src\cpp\ripple\RippleLines.cpp" />
@@ -175,14 +175,16 @@
<ClCompile Include="src\cpp\ripple\Wallet.cpp" />
<ClCompile Include="src\cpp\ripple\WSConnection.cpp" />
<ClCompile Include="src\cpp\ripple\WSDoor.cpp" />
<ClCompile Include="websocketpp\src\base64\base64.cpp" />
<ClCompile Include="websocketpp\src\md5\md5.c" />
<ClCompile Include="websocketpp\src\messages\data.cpp" />
<ClCompile Include="websocketpp\src\network_utilities.cpp" />
<ClCompile Include="websocketpp\src\processors\hybi_header.cpp" />
<ClCompile Include="websocketpp\src\processors\hybi_util.cpp" />
<ClCompile Include="websocketpp\src\sha1\sha1.cpp" />
<ClCompile Include="websocketpp\src\uri.cpp" />
<ClCompile Include="src\cpp\websocketpp\src\base64\base64.cpp" />
<ClCompile Include="src\cpp\websocketpp\src\md5\md5.c" />
<ClCompile Include="src\cpp\websocketpp\src\messages\data.cpp" />
<ClCompile Include="src\cpp\websocketpp\src\network_utilities.cpp" />
<ClCompile Include="src\cpp\websocketpp\src\processors\hybi_header.cpp" />
<ClCompile Include="src\cpp\websocketpp\src\processors\hybi_util.cpp" />
<ClCompile Include="src\cpp\websocketpp\src\rng\blank_rng.cpp" />
<ClCompile Include="src\cpp\websocketpp\src\rng\boost_rng.cpp" />
<ClCompile Include="src\cpp\websocketpp\src\sha1\sha1.cpp" />
<ClCompile Include="src\cpp\websocketpp\src\uri.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="bitcoinUtil.h" />
@@ -287,7 +289,7 @@
<None Include="SConstruct" />
<CustomBuild Include="src\cpp\ripple\ripple.proto">
<FileType>Document</FileType>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">/code/protoc-2.4.1-win32/protoc -I=..\newcoin --cpp_out=\code\newcoin\ ..\newcoin/src/cpp/ripple/ripple.proto</Command>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">/code/protobuf/protoc -I=..\newcoin --cpp_out=\code\newcoin\ ..\newcoin/src/cpp/ripple/ripple.proto</Command>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\code\newcoin\src\ripple.pb.h</Outputs>
</CustomBuild>
<None Include="test\buster.js" />

View File

@@ -33,30 +33,6 @@
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="websocketpp\src\base64\base64.cpp">
<Filter>Source Files\websocketpp</Filter>
</ClCompile>
<ClCompile Include="websocketpp\src\md5\md5.c">
<Filter>Source Files\websocketpp</Filter>
</ClCompile>
<ClCompile Include="websocketpp\src\messages\data.cpp">
<Filter>Source Files\websocketpp</Filter>
</ClCompile>
<ClCompile Include="websocketpp\src\network_utilities.cpp">
<Filter>Source Files\websocketpp</Filter>
</ClCompile>
<ClCompile Include="websocketpp\src\processors\hybi_header.cpp">
<Filter>Source Files\websocketpp</Filter>
</ClCompile>
<ClCompile Include="websocketpp\src\processors\hybi_util.cpp">
<Filter>Source Files\websocketpp</Filter>
</ClCompile>
<ClCompile Include="websocketpp\src\uri.cpp">
<Filter>Source Files\websocketpp</Filter>
</ClCompile>
<ClCompile Include="websocketpp\src\sha1\sha1.cpp">
<Filter>Source Files\websocketpp</Filter>
</ClCompile>
<ClCompile Include="src\cpp\database\database.cpp">
<Filter>Source Files\database</Filter>
</ClCompile>
@@ -318,6 +294,36 @@
<ClCompile Include="src\cpp\database\sqlite3.c">
<Filter>Source Files\database</Filter>
</ClCompile>
<ClCompile Include="src\cpp\websocketpp\src\uri.cpp">
<Filter>Source Files\websocketpp</Filter>
</ClCompile>
<ClCompile Include="src\cpp\websocketpp\src\network_utilities.cpp">
<Filter>Source Files\websocketpp</Filter>
</ClCompile>
<ClCompile Include="src\cpp\websocketpp\src\base64\base64.cpp">
<Filter>Source Files\websocketpp</Filter>
</ClCompile>
<ClCompile Include="src\cpp\websocketpp\src\md5\md5.c">
<Filter>Source Files\websocketpp</Filter>
</ClCompile>
<ClCompile Include="src\cpp\websocketpp\src\messages\data.cpp">
<Filter>Source Files\websocketpp</Filter>
</ClCompile>
<ClCompile Include="src\cpp\websocketpp\src\processors\hybi_header.cpp">
<Filter>Source Files\websocketpp</Filter>
</ClCompile>
<ClCompile Include="src\cpp\websocketpp\src\processors\hybi_util.cpp">
<Filter>Source Files\websocketpp</Filter>
</ClCompile>
<ClCompile Include="src\cpp\websocketpp\src\rng\blank_rng.cpp">
<Filter>Source Files\websocketpp</Filter>
</ClCompile>
<ClCompile Include="src\cpp\websocketpp\src\rng\boost_rng.cpp">
<Filter>Source Files\websocketpp</Filter>
</ClCompile>
<ClCompile Include="src\cpp\websocketpp\src\sha1\sha1.cpp">
<Filter>Source Files\websocketpp</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="util\pugiconfig.hpp">

View File

@@ -181,9 +181,9 @@ bool TransactionAcquire::takeNodes(const std::list<SHAMapNode>& nodeIDs,
}
void LCTransaction::setVote(const uint160& peer, bool votesYes)
{ // Tracke a peer's yes/no vote on a particular disputed transaction
std::pair<boost::unordered_map<uint160, bool>::iterator, bool> res =
mVotes.insert(std::make_pair<uint160, bool>(peer, votesYes));
{ // Track a peer's yes/no vote on a particular disputed transaction
std::pair<boost::unordered_map<const uint160, bool>::iterator, bool> res =
mVotes.insert(std::pair<const uint160, bool>(peer, votesYes));
if (res.second)
{ // new vote

View File

@@ -1,3 +1,6 @@
#ifndef __RPC_h__
#define __RPC_h__
#include <string>
#include <map>
@@ -37,3 +40,5 @@ extern std::string HTTPReply(int nStatus, const std::string& strMsg);
extern std::string JSONRPCReply(const Json::Value& result, const Json::Value& error, const Json::Value& id);
extern Json::Value JSONRPCError(int code, const std::string& message);
#endif

View File

@@ -541,6 +541,7 @@ Json::Value RPCHandler::doPeers(const Json::Value& params)
// Prior to running allow each to have a credit line of what they will be getting from the other account.
Json::Value RPCHandler::doProfile(const Json::Value &params)
{
/* need to fix now that sharedOfferCreate is gone
int iArgs = params.size();
RippleAddress naSeedA;
RippleAddress naAccountA;
@@ -620,7 +621,8 @@ Json::Value RPCHandler::doProfile(const Json::Value &params)
obj["end"] = boost::posix_time::to_simple_string(ptEnd);
obj["interval"] = boost::posix_time::to_simple_string(tdInterval);
obj["rate_per_second"] = fRate;
*/
Json::Value obj(Json::objectValue);
return obj;
}

View File

@@ -106,441 +106,9 @@ bool Transaction::sign(const RippleAddress& naAccountPrivate)
return bResult;
}
//
// AccountSet
//
Transaction::pointer Transaction::setAccountSet(
const RippleAddress& naPrivateKey,
bool bEmailHash,
const uint128& uEmailHash,
bool bWalletLocator,
const uint256& uWalletLocator,
const uint32 uWalletSize,
const RippleAddress& naMessagePublic,
bool bDomain,
const std::vector<unsigned char>& vucDomain,
bool bTransferRate,
const uint32 uTransferRate)
{
if (!bEmailHash)
mTransaction->setFieldH128(sfEmailHash, uEmailHash);
if (!bWalletLocator)
{
mTransaction->setFieldH256(sfWalletLocator, uWalletLocator);
mTransaction->setFieldU32(sfWalletSize, uWalletSize);
}
if (naMessagePublic.isValid())
mTransaction->setFieldVL(sfMessageKey, naMessagePublic.getAccountPublic());
if (bDomain)
mTransaction->setFieldVL(sfDomain, vucDomain);
if (bTransferRate)
mTransaction->setFieldU32(sfTransferRate, uTransferRate);
sign(naPrivateKey);
return shared_from_this();
}
Transaction::pointer Transaction::sharedAccountSet(
const RippleAddress& naPublicKey, const RippleAddress& naPrivateKey,
const RippleAddress& naSourceAccount,
uint32 uSeq,
const STAmount& saFee,
uint32 uSourceTag,
bool bEmailHash,
const uint128& uEmailHash,
bool bWalletLocator,
const uint256& uWalletLocator,
const uint32 uWalletSize,
const RippleAddress& naMessagePublic,
bool bDomain,
const std::vector<unsigned char>& vucDomain,
bool bTransferRate,
const uint32 uTransferRate)
{
pointer tResult = boost::make_shared<Transaction>(ttACCOUNT_SET, naPublicKey, naSourceAccount, uSeq, saFee, uSourceTag);
return tResult->setAccountSet(naPrivateKey, bEmailHash, uEmailHash,
bWalletLocator, uWalletLocator, uWalletSize,
naMessagePublic,
bDomain, vucDomain, bTransferRate, uTransferRate);
}
//
// Claim
//
Transaction::pointer Transaction::setClaim(
const RippleAddress& naPrivateKey,
const std::vector<unsigned char>& vucGenerator,
const std::vector<unsigned char>& vucPubKey,
const std::vector<unsigned char>& vucSignature)
{
mTransaction->setFieldVL(sfGenerator, vucGenerator);
mTransaction->setFieldVL(sfPublicKey, vucPubKey);
mTransaction->setFieldVL(sfSignature, vucSignature);
sign(naPrivateKey);
return shared_from_this();
}
Transaction::pointer Transaction::sharedClaim(
const RippleAddress& naPublicKey, const RippleAddress& naPrivateKey,
uint32 uSourceTag,
const std::vector<unsigned char>& vucGenerator,
const std::vector<unsigned char>& vucPubKey,
const std::vector<unsigned char>& vucSignature)
{
pointer tResult = boost::make_shared<Transaction>(ttCLAIM,
naPublicKey, naPublicKey,
0, // Sequence of 0.
0, // Free.
uSourceTag);
return tResult->setClaim(naPrivateKey, vucGenerator, vucPubKey, vucSignature);
}
//
// Create
//
Transaction::pointer Transaction::setCreate(
const RippleAddress& naPrivateKey,
const RippleAddress& naCreateAccountID,
const STAmount& saFund)
{
mTransaction->setFieldU32(sfFlags, tfCreateAccount);
mTransaction->setFieldAccount(sfDestination, naCreateAccountID);
mTransaction->setFieldAmount(sfAmount, saFund);
sign(naPrivateKey);
return shared_from_this();
}
Transaction::pointer Transaction::sharedCreate(
const RippleAddress& naPublicKey, const RippleAddress& naPrivateKey,
const RippleAddress& naSourceAccount,
uint32 uSeq,
const STAmount& saFee,
uint32 uSourceTag,
const RippleAddress& naCreateAccountID,
const STAmount& saFund)
{
pointer tResult = boost::make_shared<Transaction>(ttPAYMENT, naPublicKey, naSourceAccount, uSeq, saFee, uSourceTag);
return tResult->setCreate(naPrivateKey, naCreateAccountID, saFund);
}
//
// CreditSet
//
Transaction::pointer Transaction::setCreditSet(
const RippleAddress& naPrivateKey,
const STAmount& saLimitAmount,
bool bQualityIn,
uint32 uQualityIn,
bool bQualityOut,
uint32 uQualityOut)
{
mTransaction->setFieldAmount(sfLimitAmount, saLimitAmount);
if (bQualityIn)
mTransaction->setFieldU32(sfQualityIn, uQualityIn);
if (bQualityOut)
mTransaction->setFieldU32(sfQualityOut, uQualityOut);
sign(naPrivateKey);
return shared_from_this();
}
Transaction::pointer Transaction::sharedCreditSet(
const RippleAddress& naPublicKey, const RippleAddress& naPrivateKey,
const RippleAddress& naSourceAccount,
uint32 uSeq,
const STAmount& saFee,
uint32 uSourceTag,
const STAmount& saLimitAmount,
bool bQualityIn,
uint32 uQualityIn,
bool bQualityOut,
uint32 uQualityOut)
{
pointer tResult = boost::make_shared<Transaction>(ttCREDIT_SET, naPublicKey, naSourceAccount, uSeq, saFee, uSourceTag);
return tResult->setCreditSet(naPrivateKey,
saLimitAmount,
bQualityIn, uQualityIn,
bQualityOut, uQualityOut);
}
//
// NicknameSet
//
Transaction::pointer Transaction::setNicknameSet(
const RippleAddress& naPrivateKey,
const uint256& uNickname,
bool bSetOffer,
const STAmount& saMinimumOffer)
{
mTransaction->setFieldH256(sfNickname, uNickname);
// XXX Make sure field is present even for 0!
if (bSetOffer)
mTransaction->setFieldAmount(sfMinimumOffer, saMinimumOffer);
sign(naPrivateKey);
return shared_from_this();
}
// --> bSetOffer: true, change offer
// --> saMinimumOffer: 0 to remove.
Transaction::pointer Transaction::sharedNicknameSet(
const RippleAddress& naPublicKey, const RippleAddress& naPrivateKey,
const RippleAddress& naSourceAccount,
uint32 uSeq,
const STAmount& saFee,
uint32 uSourceTag,
const uint256& uNickname,
bool bSetOffer,
const STAmount& saMinimumOffer)
{
pointer tResult = boost::make_shared<Transaction>(ttNICKNAME_SET, naPublicKey, naSourceAccount, uSeq, saFee, uSourceTag);
return tResult->setNicknameSet(naPrivateKey, uNickname, bSetOffer, saMinimumOffer);
}
//
// OfferCreate
//
Transaction::pointer Transaction::setOfferCreate(
const RippleAddress& naPrivateKey,
bool bPassive,
const STAmount& saTakerPays,
const STAmount& saTakerGets,
uint32 uExpiration)
{
if (bPassive)
mTransaction->setFieldU32(sfFlags, tfPassive);
mTransaction->setFieldAmount(sfTakerPays, saTakerPays);
mTransaction->setFieldAmount(sfTakerGets, saTakerGets);
if (uExpiration)
mTransaction->setFieldU32(sfExpiration, uExpiration);
sign(naPrivateKey);
return shared_from_this();
}
Transaction::pointer Transaction::sharedOfferCreate(
const RippleAddress& naPublicKey, const RippleAddress& naPrivateKey,
const RippleAddress& naSourceAccount,
uint32 uSeq,
const STAmount& saFee,
uint32 uSourceTag,
bool bPassive,
const STAmount& saTakerPays,
const STAmount& saTakerGets,
uint32 uExpiration)
{
pointer tResult = boost::make_shared<Transaction>(ttOFFER_CREATE, naPublicKey, naSourceAccount, uSeq, saFee, uSourceTag);
return tResult->setOfferCreate(naPrivateKey, bPassive, saTakerPays, saTakerGets, uExpiration);
}
//
// OfferCancel
//
Transaction::pointer Transaction::setOfferCancel(
const RippleAddress& naPrivateKey,
uint32 uSequence)
{
mTransaction->setFieldU32(sfOfferSequence, uSequence);
sign(naPrivateKey);
return shared_from_this();
}
Transaction::pointer Transaction::sharedOfferCancel(
const RippleAddress& naPublicKey, const RippleAddress& naPrivateKey,
const RippleAddress& naSourceAccount,
uint32 uSeq,
const STAmount& saFee,
uint32 uSourceTag,
uint32 uSequence)
{
pointer tResult = boost::make_shared<Transaction>(ttOFFER_CANCEL, naPublicKey, naSourceAccount, uSeq, saFee, uSourceTag);
return tResult->setOfferCancel(naPrivateKey, uSequence);
}
//
// PasswordFund
//
Transaction::pointer Transaction::setPasswordFund(
const RippleAddress& naPrivateKey,
const RippleAddress& naDstAccountID)
{
mTransaction->setFieldAccount(sfDestination, naDstAccountID);
sign(naPrivateKey);
return shared_from_this();
}
Transaction::pointer Transaction::sharedPasswordFund(
const RippleAddress& naPublicKey, const RippleAddress& naPrivateKey,
const RippleAddress& naSourceAccount,
uint32 uSeq,
const STAmount& saFee,
uint32 uSourceTag,
const RippleAddress& naDstAccountID)
{
pointer tResult = boost::make_shared<Transaction>(ttPASSWORD_FUND, naPublicKey, naSourceAccount, uSeq, saFee, uSourceTag);
return tResult->setPasswordFund(naPrivateKey, naDstAccountID);
}
//
// PasswordSet
//
Transaction::pointer Transaction::setPasswordSet(
const RippleAddress& naPrivateKey,
const RippleAddress& naAuthKeyID,
const std::vector<unsigned char>& vucGenerator,
const std::vector<unsigned char>& vucPubKey,
const std::vector<unsigned char>& vucSignature)
{
mTransaction->setFieldAccount(sfAuthorizedKey, naAuthKeyID);
mTransaction->setFieldVL(sfGenerator, vucGenerator);
mTransaction->setFieldVL(sfPublicKey, vucPubKey);
mTransaction->setFieldVL(sfSignature, vucSignature);
sign(naPrivateKey);
return shared_from_this();
}
Transaction::pointer Transaction::sharedPasswordSet(
const RippleAddress& naPublicKey, const RippleAddress& naPrivateKey,
uint32 uSourceTag,
const RippleAddress& naAuthKeyID,
const std::vector<unsigned char>& vucGenerator,
const std::vector<unsigned char>& vucPubKey,
const std::vector<unsigned char>& vucSignature)
{
pointer tResult = boost::make_shared<Transaction>(ttPASSWORD_SET,
naPublicKey, naPublicKey,
0, // Sequence of 0.
0, // Free.
uSourceTag);
return tResult->setPasswordSet(naPrivateKey, naAuthKeyID, vucGenerator, vucPubKey, vucSignature);
}
//
// Payment
//
Transaction::pointer Transaction::setPayment(
const RippleAddress& naPrivateKey,
const RippleAddress& naDstAccountID,
const STAmount& saAmount,
const STAmount& saSendMax,
const STPathSet& spsPaths,
const bool bPartial,
const bool bLimit)
{
mTransaction->setFieldAccount(sfDestination, naDstAccountID);
mTransaction->setFieldAmount(sfAmount, saAmount);
if (saAmount != saSendMax || saAmount.getCurrency() != saSendMax.getCurrency())
{
mTransaction->setFieldAmount(sfSendMax, saSendMax);
}
if (spsPaths.getPathCount())
{
mTransaction->setFieldPathSet(sfPaths, spsPaths);
}
sign(naPrivateKey);
return shared_from_this();
}
Transaction::pointer Transaction::sharedPayment(
const RippleAddress& naPublicKey, const RippleAddress& naPrivateKey,
const RippleAddress& naSourceAccount,
uint32 uSeq,
const STAmount& saFee,
uint32 uSourceTag,
const RippleAddress& naDstAccountID,
const STAmount& saAmount,
const STAmount& saSendMax,
const STPathSet& spsPaths,
const bool bPartial,
const bool bLimit)
{
pointer tResult = boost::make_shared<Transaction>(ttPAYMENT, naPublicKey, naSourceAccount, uSeq, saFee, uSourceTag);
return tResult->setPayment(naPrivateKey, naDstAccountID, saAmount, saSendMax, spsPaths, bPartial, bLimit);
}
//
// WalletAdd
//
Transaction::pointer Transaction::setWalletAdd(
const RippleAddress& naPrivateKey,
const STAmount& saAmount,
const RippleAddress& naAuthKeyID,
const RippleAddress& naNewPubKey,
const std::vector<unsigned char>& vucSignature)
{
mTransaction->setFieldAmount(sfAmount, saAmount);
mTransaction->setFieldAccount(sfAuthorizedKey, naAuthKeyID);
mTransaction->setFieldVL(sfPublicKey, naNewPubKey.getAccountPublic());
mTransaction->setFieldVL(sfSignature, vucSignature);
sign(naPrivateKey);
return shared_from_this();
}
Transaction::pointer Transaction::sharedWalletAdd(
const RippleAddress& naPublicKey, const RippleAddress& naPrivateKey,
const RippleAddress& naSourceAccount,
uint32 uSeq,
const STAmount& saFee,
uint32 uSourceTag,
const STAmount& saAmount,
const RippleAddress& naAuthKeyID,
const RippleAddress& naNewPubKey,
const std::vector<unsigned char>& vucSignature)
{
pointer tResult = boost::make_shared<Transaction>(ttWALLET_ADD, naPublicKey, naSourceAccount, uSeq, saFee, uSourceTag);
return tResult->setWalletAdd(naPrivateKey, saAmount, naAuthKeyID, naNewPubKey, vucSignature);
}
//
// Misc.

View File

@@ -58,82 +58,6 @@ private:
SerializedTransaction::pointer mTransaction;
Transaction::pointer setAccountSet(
const RippleAddress& naPrivateKey,
bool bEmailHash,
const uint128& uEmailHash,
bool bWalletLocator,
const uint256& uWalletLocator,
const uint32 uWalletSize,
const RippleAddress& naMessagePublic,
bool bDomain,
const std::vector<unsigned char>& vucDomain,
bool bTransferRate,
const uint32 uTransferRate);
Transaction::pointer setClaim(
const RippleAddress& naPrivateKey,
const std::vector<unsigned char>& vucGenerator,
const std::vector<unsigned char>& vucPubKey,
const std::vector<unsigned char>& vucSignature);
Transaction::pointer setCreate(
const RippleAddress& naPrivateKey,
const RippleAddress& naCreateAccountID,
const STAmount& saFund);
Transaction::pointer setCreditSet(
const RippleAddress& naPrivateKey,
const STAmount& saLimitAmount,
bool bQualityIn,
uint32 uQualityIn,
bool bQualityOut,
uint32 uQualityOut);
Transaction::pointer setNicknameSet(
const RippleAddress& naPrivateKey,
const uint256& uNickname,
bool bSetOffer,
const STAmount& saMinimumOffer);
Transaction::pointer setOfferCreate(
const RippleAddress& naPrivateKey,
bool bPassive,
const STAmount& saTakerPays,
const STAmount& saTakerGets,
uint32 uExpiration);
Transaction::pointer setOfferCancel(
const RippleAddress& naPrivateKey,
uint32 uSequence);
Transaction::pointer setPasswordFund(
const RippleAddress& naPrivateKey,
const RippleAddress& naDstAccountID);
Transaction::pointer setPasswordSet(
const RippleAddress& naPrivateKey,
const RippleAddress& naAuthKeyID,
const std::vector<unsigned char>& vucGenerator,
const std::vector<unsigned char>& vucPubKey,
const std::vector<unsigned char>& vucSignature);
Transaction::pointer setPayment(
const RippleAddress& naPrivateKey,
const RippleAddress& naDstAccountID,
const STAmount& saAmount,
const STAmount& saSendMax,
const STPathSet& spsPaths,
const bool bPartial,
const bool bLimit);
Transaction::pointer setWalletAdd(
const RippleAddress& naPrivateKey,
const STAmount& saAmount,
const RippleAddress& naAuthKeyID,
const RippleAddress& naNewPubKey,
const std::vector<unsigned char>& vucSignature);
public:
Transaction(SerializedTransaction::ref st, bool bValidate);
@@ -148,130 +72,6 @@ public:
const STAmount& saFee, // Transaction fee.
uint32 uSourceTag); // User call back value.
// Change account settings.
static Transaction::pointer sharedAccountSet(
const RippleAddress& naPublicKey, const RippleAddress& naPrivateKey,
const RippleAddress& naSourceAccount,
uint32 uSeq,
const STAmount& saFee,
uint32 uSourceTag,
bool bEmailHash,
const uint128& uEmailHash,
bool bWalletLocator,
const uint256& uWalletLocator,
const uint32 uWalletSize,
const RippleAddress& naMessagePublic,
bool bDomain,
const std::vector<unsigned char>& vucDomain,
bool bTransferRate,
const uint32 uTransferRate);
// Claim a wallet.
static Transaction::pointer sharedClaim(
const RippleAddress& naPublicKey, const RippleAddress& naPrivateKey,
uint32 uSourceTag,
const std::vector<unsigned char>& vucGenerator,
const std::vector<unsigned char>& vucPubKey,
const std::vector<unsigned char>& vucSignature);
// Create an account.
static Transaction::pointer sharedCreate(
const RippleAddress& naPublicKey, const RippleAddress& naPrivateKey,
const RippleAddress& naSourceAccount,
uint32 uSeq,
const STAmount& saFee,
uint32 uSourceTag,
const RippleAddress& naCreateAccountID, // Account to create.
const STAmount& saFund); // Initial funds in XNC.
// Set credit limit and borrow fees.
static Transaction::pointer sharedCreditSet(
const RippleAddress& naPublicKey, const RippleAddress& naPrivateKey,
const RippleAddress& naSourceAccount,
uint32 uSeq,
const STAmount& saFee,
uint32 uSourceTag,
const STAmount& saLimitAmount,
bool bQualityIn,
uint32 uQualityIn,
bool bQualityOut,
uint32 uQualityOut);
// Set Nickname
static Transaction::pointer sharedNicknameSet(
const RippleAddress& naPublicKey, const RippleAddress& naPrivateKey,
const RippleAddress& naSourceAccount,
uint32 uSeq,
const STAmount& saFee,
uint32 uSourceTag,
const uint256& uNickname,
bool bSetOffer,
const STAmount& saMinimumOffer);
// Pre-fund password change.
static Transaction::pointer sharedPasswordFund(
const RippleAddress& naPublicKey, const RippleAddress& naPrivateKey,
const RippleAddress& naSourceAccount,
uint32 uSeq,
const STAmount& saFee,
uint32 uSourceTag,
const RippleAddress& naDstAccountID);
// Change a password.
static Transaction::pointer sharedPasswordSet(
const RippleAddress& naPublicKey, const RippleAddress& naPrivateKey,
uint32 uSourceTag,
const RippleAddress& naAuthKeyID, // ID of regular public to auth.
const std::vector<unsigned char>& vucGenerator,
const std::vector<unsigned char>& vucPubKey,
const std::vector<unsigned char>& vucSignature);
// Make a payment.
static Transaction::pointer sharedPayment(
const RippleAddress& naPublicKey, const RippleAddress& naPrivateKey,
const RippleAddress& naSourceAccount,
uint32 uSeq,
const STAmount& saFee,
uint32 uSourceTag,
const RippleAddress& naDstAccountID,
const STAmount& saAmount,
const STAmount& saSendMax,
const STPathSet& spsPaths,
const bool bPartial = false,
const bool bLimit = false);
// Place an offer.
static Transaction::pointer sharedOfferCreate(
const RippleAddress& naPublicKey, const RippleAddress& naPrivateKey,
const RippleAddress& naSourceAccount,
uint32 uSeq,
const STAmount& saFee,
uint32 uSourceTag,
bool bPassive,
const STAmount& saTakerPays,
const STAmount& saTakerGets,
uint32 uExpiration);
// Cancel an offer
static Transaction::pointer sharedOfferCancel(
const RippleAddress& naPublicKey, const RippleAddress& naPrivateKey,
const RippleAddress& naSourceAccount,
uint32 uSeq,
const STAmount& saFee,
uint32 uSourceTag,
uint32 uSequence);
// Add an account to a wallet.
static Transaction::pointer sharedWalletAdd(
const RippleAddress& naPublicKey, const RippleAddress& naPrivateKey,
const RippleAddress& naSourceAccount,
uint32 uSeq,
const STAmount& saFee,
uint32 uSourceTag,
const STAmount& saAmount, // Initial funds in XNC.
const RippleAddress& naAuthKeyID, // ID of regular public to auth.
const RippleAddress& naNewPubKey, // Public key of new account
const std::vector<unsigned char>& vucSignature); // Proof know new account's private key.
bool sign(const RippleAddress& naAccountPrivate);
bool checkSign() const;

View File

@@ -28,7 +28,7 @@ TER TransactionEngine::setAuthorized(const SerializedTransaction& txn, bool bMus
// Verify that submitter knows the private key for the generator.
// Otherwise, people could deny access to generators.
//
/* JED: taking out generator stuff until we have a better idea of how people will use this
std::vector<unsigned char> vucCipher = txn.getFieldVL(sfGenerator);
std::vector<unsigned char> vucPubKey = txn.getFieldVL(sfPublicKey);
std::vector<unsigned char> vucSignature = txn.getFieldVL(sfSignature);
@@ -42,6 +42,7 @@ TER TransactionEngine::setAuthorized(const SerializedTransaction& txn, bool bMus
return tefBAD_GEN_AUTH;
}
// Create generator.
uint160 hGeneratorID = naAccountPublic.getAccountID();
@@ -69,6 +70,8 @@ TER TransactionEngine::setAuthorized(const SerializedTransaction& txn, bool bMus
? hGeneratorID // Claim
: txn.getFieldAccount160(sfAuthorizedKey); // PasswordSet
*/
uint160 uAuthKeyID=txn.getFieldAccount160(sfAuthorizedKey);
mTxnAccount->setFieldAccount(sfAuthorizedKey, uAuthKeyID);
return tesSUCCESS;
@@ -196,17 +199,18 @@ TER TransactionEngine::doClaim(const SerializedTransaction& txn)
{
Log(lsINFO) << "doClaim>";
TER terResult = setAuthorized(txn, true);
//TER terResult = setAuthorized(txn, true);
TER terResult=tefEXCEPTION;
Log(lsINFO) << "doClaim<";
return terResult;
}
TER TransactionEngine::doCreditSet(const SerializedTransaction& txn)
TER TransactionEngine::doTrustSet(const SerializedTransaction& txn)
{
TER terResult = tesSUCCESS;
Log(lsINFO) << "doCreditSet>";
Log(lsINFO) << "doTrustSet>";
const STAmount saLimitAmount = txn.getFieldAmount(sfLimitAmount);
const bool bQualityIn = txn.isFieldPresent(sfQualityIn);
@@ -222,19 +226,19 @@ TER TransactionEngine::doCreditSet(const SerializedTransaction& txn)
if (saLimitAmount.isNegative())
{
Log(lsINFO) << "doCreditSet: Malformed transaction: Negatived credit limit.";
Log(lsINFO) << "doTrustSet: Malformed transaction: Negatived credit limit.";
return temBAD_AMOUNT;
}
else if (!uDstAccountID)
{
Log(lsINFO) << "doCreditSet: Malformed transaction: Destination account not specifed.";
Log(lsINFO) << "doTrustSet: Malformed transaction: Destination account not specified.";
return temDST_NEEDED;
}
else if (mTxnAccountID == uDstAccountID)
{
Log(lsINFO) << "doCreditSet: Malformed transaction: Can not extend credit to self.";
Log(lsINFO) << "doTrustSet: Malformed transaction: Can not extend credit to self.";
return temDST_IS_SRC;
}
@@ -242,7 +246,7 @@ TER TransactionEngine::doCreditSet(const SerializedTransaction& txn)
SLE::pointer sleDst = entryCache(ltACCOUNT_ROOT, Ledger::getAccountRootIndex(uDstAccountID));
if (!sleDst)
{
Log(lsINFO) << "doCreditSet: Delay transaction: Destination account does not exist.";
Log(lsINFO) << "doTrustSet: Delay transaction: Destination account does not exist.";
return terNO_DST;
}
@@ -311,12 +315,12 @@ TER TransactionEngine::doCreditSet(const SerializedTransaction& txn)
entryModify(sleRippleState);
}
Log(lsINFO) << "doCreditSet: Modifying ripple line: bDelIndex=" << bDelIndex;
Log(lsINFO) << "doTrustSet: Modifying ripple line: bDelIndex=" << bDelIndex;
}
// Line does not exist.
else if (!saLimitAmount)
{
Log(lsINFO) << "doCreditSet: Redundant: Setting non-existant ripple line to 0.";
Log(lsINFO) << "doTrustSet: Redundant: Setting non-existent ripple line to 0.";
return terNO_LINE_NO_ZERO;
}
@@ -325,7 +329,7 @@ TER TransactionEngine::doCreditSet(const SerializedTransaction& txn)
// Create a new ripple line.
sleRippleState = entryCreate(ltRIPPLE_STATE, Ledger::getRippleStateIndex(mTxnAccountID, uDstAccountID, uCurrencyID));
Log(lsINFO) << "doCreditSet: Creating ripple line: " << sleRippleState->getIndex().ToString();
Log(lsINFO) << "doTrustSet: Creating ripple line: " << sleRippleState->getIndex().ToString();
sleRippleState->setFieldAmount(sfBalance, STAmount(uCurrencyID, ACCOUNT_ONE)); // Zero balance in currency.
sleRippleState->setFieldAmount(bFlipped ? sfHighLimit : sfLowLimit, saLimitAllow);
@@ -344,57 +348,13 @@ TER TransactionEngine::doCreditSet(const SerializedTransaction& txn)
terResult = mNodes.dirAdd(uSrcRef, Ledger::getOwnerDirIndex(uDstAccountID), sleRippleState->getIndex());
}
Log(lsINFO) << "doCreditSet<";
Log(lsINFO) << "doTrustSet<";
return terResult;
}
TER TransactionEngine::doNicknameSet(const SerializedTransaction& txn)
{
std::cerr << "doNicknameSet>" << std::endl;
const uint256 uNickname = txn.getFieldH256(sfNickname);
const bool bMinOffer = txn.isFieldPresent(sfMinimumOffer);
const STAmount saMinOffer = bMinOffer ? txn.getFieldAmount(sfAmount) : STAmount();
SLE::pointer sleNickname = entryCache(ltNICKNAME, uNickname);
if (sleNickname)
{
// Edit old entry.
sleNickname->setFieldAccount(sfAccount, mTxnAccountID);
if (bMinOffer && saMinOffer)
{
sleNickname->setFieldAmount(sfMinimumOffer, saMinOffer);
}
else
{
sleNickname->makeFieldAbsent(sfMinimumOffer);
}
entryModify(sleNickname);
}
else
{
// Make a new entry.
// XXX Need to include authorization limiting for first year.
sleNickname = entryCreate(ltNICKNAME, Ledger::getNicknameIndex(uNickname));
std::cerr << "doNicknameSet: Creating nickname node: " << sleNickname->getIndex().ToString() << std::endl;
sleNickname->setFieldAccount(sfAccount, mTxnAccountID);
if (bMinOffer && saMinOffer)
sleNickname->setFieldAmount(sfMinimumOffer, saMinOffer);
}
std::cerr << "doNicknameSet<" << std::endl;
return tesSUCCESS;
}
/*
TER TransactionEngine::doPasswordFund(const SerializedTransaction& txn)
{
std::cerr << "doPasswordFund>" << std::endl;
@@ -428,14 +388,16 @@ TER TransactionEngine::doPasswordFund(const SerializedTransaction& txn)
return tesSUCCESS;
}
*/
TER TransactionEngine::doPasswordSet(const SerializedTransaction& txn)
// TODO: change to take a fee if there is one there
TER TransactionEngine::doRegularKeySet(const SerializedTransaction& txn)
{
std::cerr << "doPasswordSet>" << std::endl;
std::cerr << "doRegularKeySet>" << std::endl;
if (mTxnAccount->getFlags() & lsfPasswordSpent)
{
std::cerr << "doPasswordSet: Delay transaction: Funds already spent." << std::endl;
std::cerr << "doRegularKeySet: Delay transaction: Funds already spent." << std::endl;
return terFUNDS_SPENT;
}
@@ -444,7 +406,7 @@ TER TransactionEngine::doPasswordSet(const SerializedTransaction& txn)
TER terResult = setAuthorized(txn, false);
std::cerr << "doPasswordSet<" << std::endl;
std::cerr << "doRegularKeySet<" << std::endl;
return terResult;
}
@@ -477,7 +439,7 @@ TER TransactionEngine::doPayment(const SerializedTransaction& txn, const Transac
if (!uDstAccountID)
{
Log(lsINFO) << "doPayment: Invalid transaction: Payment destination account not specifed.";
Log(lsINFO) << "doPayment: Invalid transaction: Payment destination account not specified.";
return temDST_NEEDED;
}
@@ -495,7 +457,7 @@ TER TransactionEngine::doPayment(const SerializedTransaction& txn, const Transac
}
else if (mTxnAccountID == uDstAccountID && uSrcCurrency == uDstCurrency && !bPaths)
{
Log(lsINFO) << boost::str(boost::format("doPayment: Invalid transaction: Redunant transaction: src=%s, dst=%s, src_cur=%s, dst_cur=%s")
Log(lsINFO) << boost::str(boost::format("doPayment: Invalid transaction: Redundant transaction: src=%s, dst=%s, src_cur=%s, dst_cur=%s")
% mTxnAccountID.ToString()
% uDstAccountID.ToString()
% uSrcCurrency.ToString()
@@ -577,7 +539,7 @@ TER TransactionEngine::doPayment(const SerializedTransaction& txn, const Transac
if (saSrcXRPBalance < saDstAmount)
{
// Transaction might succeed, if applied in a different order.
Log(lsINFO) << "doPayment: Delay transaction: Insufficent funds.";
Log(lsINFO) << "doPayment: Delay transaction: Insufficient funds.";
terResult = terUNFUNDED;
}
@@ -638,7 +600,7 @@ TER TransactionEngine::doWalletAdd(const SerializedTransaction& txn)
if (saSrcBalance < saAmount)
{
std::cerr
<< boost::str(boost::format("WalletAdd: Delay transaction: insufficent balance: balance=%s amount=%s")
<< boost::str(boost::format("WalletAdd: Delay transaction: insufficient balance: balance=%s amount=%s")
% saSrcBalance.getText()
% saAmount.getText())
<< std::endl;
@@ -662,10 +624,6 @@ TER TransactionEngine::doWalletAdd(const SerializedTransaction& txn)
return tesSUCCESS;
}
TER TransactionEngine::doInvoice(const SerializedTransaction& txn)
{
return temUNKNOWN;
}
// Take as much as possible. Adjusts account balances. Charges fees on top to taker.
// --> uBookBase: The order book to take against.

View File

@@ -127,7 +127,7 @@ TER TransactionEngine::applyTransaction(const SerializedTransaction& txn, Transa
switch (txn.getTxnType())
{
case ttCLAIM:
case ttPASSWORD_SET:
case ttREGULAR_KEY_SET:
saCost = 0;
break;
@@ -148,7 +148,7 @@ TER TransactionEngine::applyTransaction(const SerializedTransaction& txn, Transa
break;
case ttACCOUNT_SET:
case ttCREDIT_SET:
case ttTRUST_SET:
case ttOFFER_CREATE:
case ttOFFER_CANCEL:
case ttPASSWORD_FUND:
@@ -268,7 +268,7 @@ TER TransactionEngine::applyTransaction(const SerializedTransaction& txn, Transa
}
break;
case ttPASSWORD_SET:
case ttREGULAR_KEY_SET:
// Transaction's signing public key must be for the source account.
// To prove the master private key made this transaction.
if (naSigningPubKey.getAccountID() != mTxnAccountID)
@@ -388,8 +388,8 @@ TER TransactionEngine::applyTransaction(const SerializedTransaction& txn, Transa
terResult = doClaim(txn);
break;
case ttCREDIT_SET:
terResult = doCreditSet(txn);
case ttTRUST_SET:
terResult = doTrustSet(txn);
break;
case ttINVALID:
@@ -409,16 +409,8 @@ TER TransactionEngine::applyTransaction(const SerializedTransaction& txn, Transa
terResult = doOfferCancel(txn);
break;
case ttNICKNAME_SET:
terResult = doNicknameSet(txn);
break;
case ttPASSWORD_FUND:
terResult = doPasswordFund(txn);
break;
case ttPASSWORD_SET:
terResult = doPasswordSet(txn);
case ttREGULAR_KEY_SET:
terResult = doRegularKeySet(txn);
break;
case ttPAYMENT:

View File

@@ -64,13 +64,10 @@ protected:
TER doAccountSet(const SerializedTransaction& txn);
TER doClaim(const SerializedTransaction& txn);
TER doCreditSet(const SerializedTransaction& txn);
TER doInvoice(const SerializedTransaction& txn);
TER doTrustSet(const SerializedTransaction& txn);
TER doOfferCreate(const SerializedTransaction& txn);
TER doOfferCancel(const SerializedTransaction& txn);
TER doNicknameSet(const SerializedTransaction& txn);
TER doPasswordFund(const SerializedTransaction& txn);
TER doPasswordSet(const SerializedTransaction& txn);
TER doRegularKeySet(const SerializedTransaction& txn);
TER doPayment(const SerializedTransaction& txn, const TransactionEngineParams params);
TER doWalletAdd(const SerializedTransaction& txn);
TER doContractAdd(const SerializedTransaction& txn);

View File

@@ -28,34 +28,12 @@ static bool TFInit()
<< SOElement(sfTransferRate, SOE_OPTIONAL)
;
DECLARE_TF(Claim, ttCLAIM)
<< SOElement(sfGenerator, SOE_REQUIRED)
<< SOElement(sfPublicKey, SOE_REQUIRED)
<< SOElement(sfSignature, SOE_REQUIRED)
;
DECLARE_TF(CreditSet, ttCREDIT_SET)
DECLARE_TF(TrustSet, ttTRUST_SET)
<< SOElement(sfLimitAmount, SOE_OPTIONAL)
<< SOElement(sfQualityIn, SOE_OPTIONAL)
<< SOElement(sfQualityOut, SOE_OPTIONAL)
;
/*
DECLARE_TF(Invoice, ttINVOICE)
<< SOElement(sfTarget, SOE_REQUIRED)
<< SOElement(sfAmount, SOE_REQUIRED)
<< SOElement(sfDestination, SOE_OPTIONAL)
<< SOElement(sfIdentifier, SOE_OPTIONAL)
;
)
*/
DECLARE_TF(NicknameSet, ttNICKNAME_SET)
<< SOElement(sfNickname, SOE_REQUIRED)
<< SOElement(sfMinimumOffer, SOE_OPTIONAL)
;
DECLARE_TF(OfferCreate, ttOFFER_CREATE)
<< SOElement(sfTakerPays, SOE_REQUIRED)
<< SOElement(sfTakerGets, SOE_REQUIRED)
@@ -66,14 +44,8 @@ static bool TFInit()
<< SOElement(sfOfferSequence, SOE_REQUIRED)
;
DECLARE_TF(PasswordFund, ttPASSWORD_FUND)
<< SOElement(sfDestination, SOE_REQUIRED)
;
DECLARE_TF(PasswordSet, ttPASSWORD_SET)
DECLARE_TF(SetRegularKey, ttREGULAR_KEY_SET)
<< SOElement(sfAuthorizedKey, SOE_REQUIRED)
<< SOElement(sfGenerator, SOE_REQUIRED)
<< SOElement(sfPublicKey, SOE_REQUIRED)
;
DECLARE_TF(Payment, ttPAYMENT)
@@ -84,12 +56,6 @@ static bool TFInit()
<< SOElement(sfInvoiceID, SOE_OPTIONAL)
;
DECLARE_TF(WalletAdd, ttWALLET_ADD)
<< SOElement(sfAmount, SOE_REQUIRED)
<< SOElement(sfAuthorizedKey, SOE_REQUIRED)
<< SOElement(sfPublicKey, SOE_REQUIRED)
;
DECLARE_TF(Contract, ttCONTRACT)
<< SOElement(sfExpiration, SOE_REQUIRED)
<< SOElement(sfBondAmount, SOE_REQUIRED)

View File

@@ -7,18 +7,18 @@ enum TransactionType
{
ttINVALID = -1,
ttPAYMENT = 0,
ttCLAIM = 1,
ttCLAIM = 1, // open
ttWALLET_ADD = 2,
ttACCOUNT_SET = 3,
ttPASSWORD_FUND = 4,
ttPASSWORD_SET = 5,
ttNICKNAME_SET = 6,
ttPASSWORD_FUND = 4, // open
ttREGULAR_KEY_SET = 5,
ttNICKNAME_SET = 6, // open
ttOFFER_CREATE = 7,
ttOFFER_CANCEL = 8,
ttCONTRACT = 9,
ttCONTRACT_REMOVE = 10, // can we use the same msg as offer cancel
ttCREDIT_SET = 20,
ttTRUST_SET = 20,
};
class TransactionFormat