mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Fix mishandling of signing account.
Fix failure to set transaction type.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
|
||||
#include "SerializedTransaction.h"
|
||||
|
||||
SerializedTransaction::SerializedTransaction(TransactionType type)
|
||||
SerializedTransaction::SerializedTransaction(TransactionType type) : mType(type)
|
||||
{
|
||||
mFormat = getTxnFormat(type);
|
||||
if (mFormat == NULL) throw std::runtime_error("invalid transaction type");
|
||||
@@ -31,13 +31,21 @@ SerializedTransaction::SerializedTransaction(SerializerIterator& sit, int length
|
||||
mMiddleTxn.giveObject(new STVariableLength("SigningAccount", sit.getVL()));
|
||||
mMiddleTxn.giveObject(new STUInt32("Sequence", sit.get32()));
|
||||
|
||||
int type = sit.get32();
|
||||
mMiddleTxn.giveObject(new STUInt32("Type", type));
|
||||
mFormat = getTxnFormat(static_cast<TransactionType>(type));
|
||||
mType = static_cast<TransactionType>(sit.get32());
|
||||
mMiddleTxn.giveObject(new STUInt32("Type", static_cast<uint32>(mType)));
|
||||
mFormat = getTxnFormat(mType);
|
||||
if (!mFormat) throw std::runtime_error("Transaction has invalid type");
|
||||
mMiddleTxn.giveObject(new STUInt64("Fee", sit.get64()));
|
||||
|
||||
mInnerTxn = STObject(mFormat->elements, sit, "InnerTransaction");
|
||||
updateSigningAccount();
|
||||
}
|
||||
|
||||
void SerializedTransaction::updateSigningAccount()
|
||||
{
|
||||
NewcoinAddress a;
|
||||
a.setAccountPublic(peekRawSigningAccount());
|
||||
mSigningAccount = a.getAccountID();
|
||||
}
|
||||
|
||||
int SerializedTransaction::getLength() const
|
||||
@@ -81,7 +89,7 @@ bool SerializedTransaction::isEquivalent(const SerializedType& t) const
|
||||
{ // Signatures are not compared
|
||||
const SerializedTransaction* v = dynamic_cast<const SerializedTransaction*>(&t);
|
||||
if (!v) return false;
|
||||
if (type != v->type) return false;
|
||||
if (mType != v->mType) return false;
|
||||
if (mMiddleTxn != v->mMiddleTxn) return false;
|
||||
if (mInnerTxn != v->mInnerTxn) return false;
|
||||
return true;
|
||||
@@ -171,7 +179,7 @@ void SerializedTransaction::setSequence(uint32 seq)
|
||||
v->setValue(seq);
|
||||
}
|
||||
|
||||
std::vector<unsigned char> SerializedTransaction::getSigningAccount() const
|
||||
std::vector<unsigned char> SerializedTransaction::getRawSigningAccount() const
|
||||
{
|
||||
const STVariableLength* v =
|
||||
dynamic_cast<const STVariableLength*>(mMiddleTxn.peekAtPIndex(TransactionISigningAccount));
|
||||
@@ -179,7 +187,7 @@ std::vector<unsigned char> SerializedTransaction::getSigningAccount() const
|
||||
return v->getValue();
|
||||
}
|
||||
|
||||
const std::vector<unsigned char>& SerializedTransaction::peekSigningAccount() const
|
||||
const std::vector<unsigned char>& SerializedTransaction::peekRawSigningAccount() const
|
||||
{
|
||||
const STVariableLength* v=
|
||||
dynamic_cast<const STVariableLength*>(mMiddleTxn.peekAtPIndex(TransactionISigningAccount));
|
||||
@@ -187,7 +195,7 @@ const std::vector<unsigned char>& SerializedTransaction::peekSigningAccount() co
|
||||
return v->peekValue();
|
||||
}
|
||||
|
||||
std::vector<unsigned char>& SerializedTransaction::peekSigningAccount()
|
||||
std::vector<unsigned char>& SerializedTransaction::peekRawSigningAccount()
|
||||
{
|
||||
STVariableLength* v = dynamic_cast<STVariableLength*>(mMiddleTxn.getPIndex(TransactionISigningAccount));
|
||||
if (!v) throw std::runtime_error("corrupt transaction");
|
||||
@@ -199,6 +207,7 @@ void SerializedTransaction::setSigningAccount(const std::vector<unsigned char>&
|
||||
STVariableLength* v = dynamic_cast<STVariableLength*>(mMiddleTxn.getPIndex(TransactionISigningAccount));
|
||||
if (!v) throw std::runtime_error("corrupt transaction");
|
||||
v->setValue(s);
|
||||
updateSigningAccount();
|
||||
}
|
||||
|
||||
int SerializedTransaction::getITFieldIndex(SOE_Field field) const
|
||||
|
||||
@@ -15,11 +15,14 @@ public:
|
||||
typedef boost::shared_ptr<SerializedTransaction> pointer;
|
||||
|
||||
protected:
|
||||
TransactionType type;
|
||||
uint160 mSigningAccount;
|
||||
TransactionType mType;
|
||||
STVariableLength mSignature;
|
||||
STObject mMiddleTxn, mInnerTxn;
|
||||
TransactionFormat* mFormat;
|
||||
|
||||
void updateSigningAccount();
|
||||
|
||||
public:
|
||||
SerializedTransaction(SerializerIterator& sit, int length); // -1=all remaining, 0=get from sit
|
||||
SerializedTransaction(TransactionType type);
|
||||
@@ -42,12 +45,13 @@ public:
|
||||
// middle transaction functions
|
||||
uint32 getVersion() const;
|
||||
void setVersion(uint32);
|
||||
TransactionType getTxnType() const { return type; }
|
||||
TransactionType getTxnType() const { return mType; }
|
||||
uint64 getTransactionFee() const;
|
||||
void setTransactionFee(uint64);
|
||||
std::vector<unsigned char> getSigningAccount() const;
|
||||
const std::vector<unsigned char>& peekSigningAccount() const;
|
||||
std::vector<unsigned char>& peekSigningAccount();
|
||||
uint160 getSigningAccount() const;
|
||||
std::vector<unsigned char> getRawSigningAccount() const;
|
||||
const std::vector<unsigned char>& peekRawSigningAccount() const;
|
||||
std::vector<unsigned char>& peekRawSigningAccount();
|
||||
void setSigningAccount(const std::vector<unsigned char>& s);
|
||||
std::string getTransactionType() const { return mFormat->t_name; }
|
||||
|
||||
|
||||
@@ -52,14 +52,13 @@ Transaction::Transaction(LocalAccount::pointer fromLocalAccount, const NewcoinAd
|
||||
|
||||
Transaction::Transaction(SerializedTransaction::pointer sit, bool validate) : mStatus(INVALID), mTransaction(sit)
|
||||
{
|
||||
uint160 toAccountID;
|
||||
uint160 fromAccountID;
|
||||
uint160 toAccountID, fromAccountID;
|
||||
std::vector<unsigned char> pubKey;
|
||||
|
||||
try
|
||||
{
|
||||
toAccountID = mTransaction->getITFieldH160(sfDestination);
|
||||
pubKey=mTransaction->getSigningAccount();
|
||||
pubKey = mTransaction->getRawSigningAccount();
|
||||
mTransactionID = mTransaction->getTransactionID();
|
||||
}
|
||||
catch(...)
|
||||
|
||||
Reference in New Issue
Block a user