mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-20 11:05:54 +00:00
Cleanups and two small bugfixes. (Wrong SQL, wrong sequence in signature)
This commit is contained in:
@@ -22,7 +22,8 @@ Transaction::Transaction(LocalAccount::pointer fromLocalAccount, const uint160&
|
|||||||
{
|
{
|
||||||
mAccountFrom=fromLocalAccount->getAddress();
|
mAccountFrom=fromLocalAccount->getAddress();
|
||||||
mFromPubKey=fromLocalAccount->getPublicKey();
|
mFromPubKey=fromLocalAccount->getPublicKey();
|
||||||
mFromAccountSeq=fromLocalAccount->getAcctSeq();
|
assert(mFromPubKey);
|
||||||
|
mFromAccountSeq=fromLocalAccount->getTxnSeq();
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
std::cerr << "Construct local Txn" << std::endl;
|
std::cerr << "Construct local Txn" << std::endl;
|
||||||
@@ -99,9 +100,7 @@ bool Transaction::sign(LocalAccount::pointer fromLocalAccount)
|
|||||||
assert(false);
|
assert(false);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Serializer::pointer signBuf=getRaw(true);
|
if(!getRaw(true)->makeSignature(mSignature, *privateKey))
|
||||||
assert(signBuf->getLength()==73+4);
|
|
||||||
if(!signBuf->makeSignature(mSignature, *privateKey))
|
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
std::cerr << "Failed to make signature" << std::endl;
|
std::cerr << "Failed to make signature" << std::endl;
|
||||||
@@ -122,7 +121,8 @@ void Transaction::updateFee()
|
|||||||
bool Transaction::checkSign() const
|
bool Transaction::checkSign() const
|
||||||
{
|
{
|
||||||
assert(mFromPubKey);
|
assert(mFromPubKey);
|
||||||
return mFromPubKey->Verify(getRaw(true)->getSHA512Half(), mSignature);
|
Serializer::pointer signBuf=getRaw(true);
|
||||||
|
return getRaw(true)->checkSignature(mSignature, *mFromPubKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
Serializer::pointer Transaction::getRaw(bool prefix) const
|
Serializer::pointer Transaction::getRaw(bool prefix) const
|
||||||
@@ -133,7 +133,7 @@ Serializer::pointer Transaction::getRaw(bool prefix) const
|
|||||||
ret->addRaw(mFromPubKey->GetPubKey());
|
ret->addRaw(mFromPubKey->GetPubKey());
|
||||||
ret->add64(mAmount);
|
ret->add64(mAmount);
|
||||||
ret->add32(mFromAccountSeq);
|
ret->add32(mFromAccountSeq);
|
||||||
ret->add32(mInLedger);
|
ret->add32(mSourceLedger);
|
||||||
ret->add32(mIdent);
|
ret->add32(mIdent);
|
||||||
assert( (prefix&&(ret->getLength()==77)) || (!prefix&&(ret->getLength()==73)) );
|
assert( (prefix&&(ret->getLength()==77)) || (!prefix&&(ret->getLength()==73)) );
|
||||||
return ret;
|
return ret;
|
||||||
@@ -212,7 +212,7 @@ Transaction::pointer Transaction::transactionFromSQL(const std::string& sql)
|
|||||||
ScopedLock sl(theApp->getTxnDB()->getDBLock());
|
ScopedLock sl(theApp->getTxnDB()->getDBLock());
|
||||||
Database* db=theApp->getTxnDB()->getDB();
|
Database* db=theApp->getTxnDB()->getDB();
|
||||||
|
|
||||||
if(!db->executeSQL(sql.c_str()) || !db->startIterRows() || !db->getNextRow())
|
if(!db->executeSQL(sql.c_str(), true) || !db->startIterRows() || !db->getNextRow())
|
||||||
return Transaction::pointer();
|
return Transaction::pointer();
|
||||||
|
|
||||||
db->getStr("TransID", transID);
|
db->getStr("TransID", transID);
|
||||||
@@ -256,7 +256,7 @@ Transaction::pointer Transaction::transactionFromSQL(const std::string& sql)
|
|||||||
|
|
||||||
Transaction::pointer Transaction::load(const uint256& id)
|
Transaction::pointer Transaction::load(const uint256& id)
|
||||||
{
|
{
|
||||||
std::string sql="SELECT * FROM Transactions WHERE Hash='";
|
std::string sql="SELECT * FROM Transactions WHERE TransID='";
|
||||||
sql.append(id.GetHex());
|
sql.append(id.GetHex());
|
||||||
sql.append("';");
|
sql.append("';");
|
||||||
return transactionFromSQL(sql);
|
return transactionFromSQL(sql);
|
||||||
|
|||||||
Reference in New Issue
Block a user