Create transactions offer_create & offer_cancel.

This commit is contained in:
Arthur Britto
2012-07-13 15:32:03 -07:00
parent 3982a67dbe
commit 81def6601f
3 changed files with 101 additions and 1 deletions

View File

@@ -360,7 +360,6 @@ bool NetworkOPs::checkLastClosedLedger(const std::vector<Peer::pointer>& peerLis
++ourVC.nodesUsing;
ourVC.highNode = theApp->getWallet().getNodePublic();
}
for (std::vector<Peer::pointer>::const_iterator it = peerList.begin(), end = peerList.end(); it != end; ++it)
{

View File

@@ -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<Transaction>(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<Transaction>(ttOFFER_CANCEL, naPublicKey, naSourceAccount, uSeq, saFee, uSourceTag);
return tResult->setOfferCancel(naPrivateKey, uSequence);
}
//
// PasswordFund
//

View File

@@ -78,6 +78,17 @@ private:
const STAmount& saMinimumOffer,
const std::vector<unsigned char>& 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,