From f6e32912bb05774fb44893fa71a39caf08bc5c6c Mon Sep 17 00:00:00 2001 From: Arthur Britto Date: Tue, 5 Jun 2012 13:06:20 -0700 Subject: [PATCH] Implement transaction creation for nickname_set. --- src/Transaction.cpp | 38 ++++++++++++++++++++++++++++++++++++++ src/Transaction.h | 17 +++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/src/Transaction.cpp b/src/Transaction.cpp index 72930ef29..c2ac06c86 100644 --- a/src/Transaction.cpp +++ b/src/Transaction.cpp @@ -259,6 +259,44 @@ Transaction::pointer Transaction::sharedCreditSet( return tResult->setCreditSet(naPrivateKey, naDstAccountID, saLimitAmount, uAcceptRate); } +// +// NicknameSet +// + +Transaction::pointer Transaction::setNicknameSet( + const NewcoinAddress& naPrivateKey, + const uint256& uNickname, + bool bSetOffer, + const STAmount& saMinimumOffer) +{ + mTransaction->setITFieldH256(sfNickname, uNickname); + + // XXX Make sure field is present even for 0! + if (bSetOffer) + mTransaction->setITFieldAmount(sfMinimumOffer, saMinimumOffer); + + sign(naPrivateKey); + + return shared_from_this(); +} + +// --> bSetOffer: true, change offer +// --> saMinimumOffer: 0 to remove. +Transaction::pointer Transaction::sharedNicknameSet( + const NewcoinAddress& naPublicKey, const NewcoinAddress& naPrivateKey, + const NewcoinAddress& naSourceAccount, + uint32 uSeq, + const STAmount& saFee, + uint32 uSourceTag, + const uint256& uNickname, + bool bSetOffer, + const STAmount& saMinimumOffer) +{ + pointer tResult = boost::make_shared(ttNICKNAME_SET, naPublicKey, naSourceAccount, uSeq, saFee, uSourceTag); + + return tResult->setNicknameSet(naPrivateKey, uNickname, bSetOffer, saMinimumOffer); +} + // // PasswordFund // diff --git a/src/Transaction.h b/src/Transaction.h index 90cb1b934..bd1c1136e 100644 --- a/src/Transaction.h +++ b/src/Transaction.h @@ -71,6 +71,12 @@ private: const STAmount& saLimitAmount, uint32 uAcceptRate); + Transaction::pointer setNicknameSet( + const NewcoinAddress& naPrivateKey, + const uint256& uNickname, + bool bSetOffer, + const STAmount& saMinimumOffer); + Transaction::pointer setPasswordFund( const NewcoinAddress& naPrivateKey, const NewcoinAddress& naDstAccountID); @@ -157,6 +163,17 @@ public: const STAmount& saLimitAmount, uint32 uAcceptRate); + // Set Nickname + static Transaction::pointer sharedNicknameSet( + const NewcoinAddress& naPublicKey, const NewcoinAddress& naPrivateKey, + const NewcoinAddress& 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 NewcoinAddress& naPublicKey, const NewcoinAddress& naPrivateKey,