From ba5aef352cb4164902bf3e11be4dd64d3adf48b8 Mon Sep 17 00:00:00 2001 From: Arthur Britto Date: Fri, 1 Jun 2012 17:59:56 -0700 Subject: [PATCH] Add support to create WalletAdd transaction. --- src/Transaction.cpp | 39 +++++++++++++++++++++++++++++++++++++++ src/Transaction.h | 19 +++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/src/Transaction.cpp b/src/Transaction.cpp index aa9427bbf6..43e17f836f 100644 --- a/src/Transaction.cpp +++ b/src/Transaction.cpp @@ -305,6 +305,45 @@ Transaction::pointer Transaction::sharedTransitSet( return tResult->setTransitSet(naPrivateKey, uTransitRate, uTransitStart, uTransitExpire); } +// +// WalletAdd +// + +Transaction::pointer Transaction::setWalletAdd( + const NewcoinAddress& naPrivateKey, + const STAmount& saAmount, + const NewcoinAddress& naAuthKeyID, + const NewcoinAddress& naNewPubKey, + const std::vector& vucSignature) +{ + mTransaction->setITFieldAmount(sfAmount, saAmount); + mTransaction->setITFieldAccount(sfAuthorizedKey, naAuthKeyID); + mTransaction->setITFieldVL(sfPubKey, naNewPubKey.getAccountPublic()); + mTransaction->setITFieldVL(sfSignature, vucSignature); + + sign(naPrivateKey); + + return shared_from_this(); +} + +Transaction::pointer Transaction::sharedWalletAdd( + const NewcoinAddress& naPublicKey, const NewcoinAddress& naPrivateKey, + const NewcoinAddress& naSourceAccount, + uint32 uSeq, + const STAmount& saFee, + uint32 uSourceTag, + const STAmount& saAmount, + const NewcoinAddress& naAuthKeyID, + const NewcoinAddress& naNewPubKey, + const std::vector& vucSignature) +{ + pointer tResult = boost::make_shared(ttWALLET_ADD, + naPublicKey, naSourceAccount, + uSeq, saFee, uSourceTag); + + return tResult->setWalletAdd(naPrivateKey, saAmount, naAuthKeyID, naNewPubKey, vucSignature); +} + // // Misc. // diff --git a/src/Transaction.h b/src/Transaction.h index 5f5789b328..9a28f5b283 100644 --- a/src/Transaction.h +++ b/src/Transaction.h @@ -76,6 +76,13 @@ private: uint32 uTransitStart, uint32 uTransitExpire); + Transaction::pointer setWalletAdd( + const NewcoinAddress& naPrivateKey, + const STAmount& saAmount, + const NewcoinAddress& naAuthKeyID, + const NewcoinAddress& naNewPubKey, + const std::vector& vucSignature); + public: Transaction(const SerializedTransaction::pointer st, bool bValidate); @@ -142,6 +149,18 @@ public: uint32 uTransitStart, uint32 uTransitExpire); + // Add an account to a wallet. + static Transaction::pointer sharedWalletAdd( + const NewcoinAddress& naPublicKey, const NewcoinAddress& naPrivateKey, + const NewcoinAddress& naSourceAccount, + uint32 uSeq, + const STAmount& saFee, + uint32 uSourceTag, + const STAmount& saAmount, // Initial funds in XNC. + const NewcoinAddress& naAuthKeyID, // ID of regular public to auth. + const NewcoinAddress& naNewPubKey, // Public key of new account + const std::vector& vucSignature); // Proof know new account's private key. + bool sign(const NewcoinAddress& naAccountPrivate); bool checkSign() const; void updateID() { mTransactionID=mTransaction->getTransactionID(); }