std::shared_ptr<STTx const> TransactionMaster::fetch (std::shared_ptr<SHAMapItem> const& item, SHAMapTreeNode::TNType type, bool checkDisk, std::uint32_t uCommitLedger) { std::shared_ptr<STTx const> txn; auto iTx = fetch (item->key(), false); if (!iTx) { if (type == SHAMapTreeNode::tnTRANSACTION_NM) { SerialIter sit (item->slice()); txn = std::make_shared<STTx const> (std::ref (sit)); } else if (type == SHAMapTreeNode::tnTRANSACTION_MD) { auto blob = SerialIter{item->data(), item->size()}.getVL(); txn = std::make_shared<STTx const>(SerialIter{blob.data(), blob.size()}); } } else { if (uCommitLedger) iTx->setStatus (COMMITTED, uCommitLedger); txn = iTx->getSTransaction (); } return txn; }
Transaction::pointer Transaction::transactionFromSQLValidated( boost::optional<std::uint64_t> const& ledgerSeq, boost::optional<std::string> const& status, Blob const& rawTxn, Application& app) { auto ret = transactionFromSQL(ledgerSeq, status, rawTxn, app); if (checkValidity(app.getHashRouter(), *ret->getSTransaction(), app. getLedgerMaster().getValidatedRules(), app.config()).first != Validity::Valid) return {}; return ret; }
bool Transaction::sign(const RippleAddress& naAccountPrivate) { bool bResult = true; if (!naAccountPrivate.isValid()) { Log(lsWARNING) << "No private key for signing"; bResult = false; } getSTransaction()->sign(naAccountPrivate); if (bResult) { updateID(); } else { mStatus = INCOMPLETE; } return bResult; }
// { // tx_json: <object>, // secret: <secret> // } Json::Value doSubmit (RPC::Context& context) { context.loadType = Resource::feeMediumBurdenRPC; if (!context.params.isMember (jss::tx_blob)) { auto const failType = getFailHard (context); if (context.role != Role::ADMIN && !context.app.config().canSign()) return RPC::make_error (rpcNOT_SUPPORTED, "Signing is not supported by this server."); auto ret = RPC::transactionSubmit ( context.params, failType, context.role, context.ledgerMaster.getValidatedLedgerAge(), context.app, RPC::getProcessTxnFn (context.netOps)); ret[jss::deprecated] = "Signing support in the 'submit' command has been " "deprecated and will be removed in a future version " "of the server. Please migrate to a standalone " "signing tool."; return ret; } Json::Value jvResult; std::pair<Blob, bool> ret(strUnHex (context.params[jss::tx_blob].asString ())); if (!ret.second || !ret.first.size ()) return rpcError (rpcINVALID_PARAMS); SerialIter sitTrans (makeSlice(ret.first)); std::shared_ptr<STTx const> stpTrans; try { stpTrans = std::make_shared<STTx const> (std::ref (sitTrans)); } catch (std::exception& e) { jvResult[jss::error] = "invalidTransaction"; jvResult[jss::error_exception] = e.what (); return jvResult; } { if (!context.app.checkSigs()) forceValidity(context.app.getHashRouter(), stpTrans->getTransactionID(), Validity::SigGoodOnly); auto validity = checkValidity(context.app.getHashRouter(), *stpTrans, context.ledgerMaster.getCurrentLedger()->rules(), context.app.config()); if (validity.first != Validity::Valid) { jvResult[jss::error] = "invalidTransaction"; jvResult[jss::error_exception] = "fails local checks: " + validity.second; return jvResult; } } std::string reason; auto tpTrans = std::make_shared<Transaction> ( stpTrans, reason, context.app); if (tpTrans->getStatus() != NEW) { jvResult[jss::error] = "invalidTransaction"; jvResult[jss::error_exception] = "fails local checks: " + reason; return jvResult; } try { auto const failType = getFailHard (context); context.netOps.processTransaction ( tpTrans, isUnlimited (context.role), true, failType); } catch (std::exception& e) { jvResult[jss::error] = "internalSubmit"; jvResult[jss::error_exception] = e.what (); return jvResult; } try { jvResult[jss::tx_json] = tpTrans->getJson (0); jvResult[jss::tx_blob] = strHex ( tpTrans->getSTransaction ()->getSerializer ().peekData ()); if (temUNCERTAIN != tpTrans->getResult ()) { std::string sToken; std::string sHuman; transResultInfo (tpTrans->getResult (), sToken, sHuman); jvResult[jss::engine_result] = sToken; jvResult[jss::engine_result_code] = tpTrans->getResult (); jvResult[jss::engine_result_message] = sHuman; } return jvResult; } catch (std::exception& e) { jvResult[jss::error] = "internalJson"; jvResult[jss::error_exception] = e.what (); return jvResult; } }