diff --git a/src/NetworkOPs.cpp b/src/NetworkOPs.cpp index c3769027d3..f523274ba3 100644 --- a/src/NetworkOPs.cpp +++ b/src/NetworkOPs.cpp @@ -360,7 +360,6 @@ bool NetworkOPs::checkLastClosedLedger(const std::vector& peerLis ++ourVC.nodesUsing; ourVC.highNode = theApp->getWallet().getNodePublic(); } - for (std::vector::const_iterator it = peerList.begin(), end = peerList.end(); it != end; ++it) { diff --git a/src/Transaction.cpp b/src/Transaction.cpp index 483cc61043..5184bec5d1 100644 --- a/src/Transaction.cpp +++ b/src/Transaction.cpp @@ -302,6 +302,75 @@ Transaction::pointer Transaction::sharedNicknameSet( return tResult->setNicknameSet(naPrivateKey, uNickname, bSetOffer, saMinimumOffer, vucSignature); } +// +// OfferCreate +// + +Transaction::pointer Transaction::setOfferCreate( + const NewcoinAddress& naPrivateKey, + bool bPassive, + const STAmount& saTakerPays, + const STAmount& saTakerGets, + uint32 uExpiration) +{ + if (bPassive) + mTransaction->setITFieldU32(sfFlags, tfPassive); + + mTransaction->setITFieldAmount(sfTakerPays, saTakerPays); + mTransaction->setITFieldAmount(sfTakerGets, saTakerGets); + mTransaction->setITFieldAccount(sfPaysIssuer, saTakerPays.getIssuer()); + mTransaction->setITFieldAccount(sfGetsIssuer, saTakerGets.getIssuer()); + mTransaction->setITFieldU32(sfExpiration, uExpiration); + + sign(naPrivateKey); + + return shared_from_this(); +} + +Transaction::pointer Transaction::sharedOfferCreate( + const NewcoinAddress& naPublicKey, const NewcoinAddress& naPrivateKey, + const NewcoinAddress& naSourceAccount, + uint32 uSeq, + const STAmount& saFee, + uint32 uSourceTag, + bool bPassive, + const STAmount& saTakerPays, + const STAmount& saTakerGets, + uint32 uExpiration) +{ + pointer tResult = boost::make_shared(ttOFFER_CREATE, naPublicKey, naSourceAccount, uSeq, saFee, uSourceTag); + + return tResult->setOfferCreate(naPrivateKey, bPassive, saTakerPays, saTakerGets, uExpiration); +} + +// +// OfferCancel +// + +Transaction::pointer Transaction::setOfferCancel( + const NewcoinAddress& naPrivateKey, + uint32 uSequence) +{ + mTransaction->setITFieldU32(sfSequence, uSequence); + + sign(naPrivateKey); + + return shared_from_this(); +} + +Transaction::pointer Transaction::sharedOfferCancel( + const NewcoinAddress& naPublicKey, const NewcoinAddress& naPrivateKey, + const NewcoinAddress& naSourceAccount, + uint32 uSeq, + const STAmount& saFee, + uint32 uSourceTag, + uint32 uSequence) +{ + pointer tResult = boost::make_shared(ttOFFER_CANCEL, naPublicKey, naSourceAccount, uSeq, saFee, uSourceTag); + + return tResult->setOfferCancel(naPrivateKey, uSequence); +} + // // PasswordFund // diff --git a/src/Transaction.h b/src/Transaction.h index 02f2562819..f867ffd260 100644 --- a/src/Transaction.h +++ b/src/Transaction.h @@ -78,6 +78,17 @@ private: const STAmount& saMinimumOffer, const std::vector& vucSignature); + Transaction::pointer setOfferCreate( + const NewcoinAddress& naPrivateKey, + bool bPassive, + const STAmount& saTakerPays, + const STAmount& saTakerGets, + uint32 uExpiration); + + Transaction::pointer setOfferCancel( + const NewcoinAddress& naPrivateKey, + uint32 uSequence); + Transaction::pointer setPasswordFund( const NewcoinAddress& naPrivateKey, const NewcoinAddress& naDstAccountID); @@ -200,6 +211,27 @@ public: const STAmount& saSendMax, const STPathSet& saPaths); + // Place an offer. + static Transaction::pointer sharedOfferCreate( + const NewcoinAddress& naPublicKey, const NewcoinAddress& naPrivateKey, + const NewcoinAddress& 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 NewcoinAddress& naPublicKey, const NewcoinAddress& naPrivateKey, + const NewcoinAddress& naSourceAccount, + uint32 uSeq, + const STAmount& saFee, + uint32 uSourceTag, + uint32 uSequence); + // Add an account to a wallet. static Transaction::pointer sharedWalletAdd( const NewcoinAddress& naPublicKey, const NewcoinAddress& naPrivateKey,