20 #include <ripple/app/tx/impl/SetSignerList.h>
22 #include <ripple/app/ledger/Ledger.h>
23 #include <ripple/basics/Log.h>
24 #include <ripple/ledger/ApplyView.h>
25 #include <ripple/protocol/Feature.h>
26 #include <ripple/protocol/Indexes.h>
27 #include <ripple/protocol/STArray.h>
28 #include <ripple/protocol/STObject.h>
29 #include <ripple/protocol/STTx.h>
57 if (quorum && hasSignerEntries)
64 std::sort(signers->begin(), signers->end());
67 sign = std::move(*signers);
70 else if ((quorum == 0) && !hasSignerEntries)
87 return std::get<0>(result);
89 if (std::get<3>(result) ==
unknown)
93 <<
"Malformed transaction: Invalid signer set list format.";
97 if (std::get<3>(result) ==
set)
141 assert(std::get<3>(result) !=
unknown);
145 do_ = std::get<3>(result);
176 return 2 +
static_cast<int>(entryCount);
183 Keylet const& accountKeylet,
184 Keylet const& ownerDirKeylet,
185 Keylet const& signerListKeylet,
199 int removeFromOwnerCount = -1;
203 removeFromOwnerCount =
211 if (!view.
dirRemove(ownerDirKeylet, hint, signerListKeylet.
key,
false))
213 JLOG(j.
fatal()) <<
"Unable to delete SignerList from owner.";
219 view.
peek(accountKeylet),
220 removeFromOwnerCount,
240 app,
view, accountKeylet, ownerDirKeylet, signerListKeylet, j);
257 JLOG(j.
trace()) <<
"Too many or too few signers in signer list.";
266 JLOG(j.
trace()) <<
"Duplicate signers in signer list";
276 for (
auto const& signer : signers)
281 JLOG(j.
trace()) <<
"Every signer must have a positive weight.";
285 allSignersWeight += signer.weight;
287 if (signer.account == account)
289 JLOG(j.
trace()) <<
"A signer may not self reference account.";
293 if (signer.tag && !expandedSignerList)
295 JLOG(j.
trace()) <<
"Malformed transaction: sfWalletLocator "
296 "specified in SignerEntry "
297 <<
"but featureExpandedSignerList is not enabled.";
304 if ((quorum <= 0) || (allSignersWeight < quorum))
306 JLOG(j.
trace()) <<
"Quorum is unreachable";
331 auto const sle =
view().
peek(accountKeylet);
339 int addedOwnerCount{1};
358 auto signerList = std::make_shared<SLE>(signerListKeylet);
368 <<
": " << (page ?
"success" :
"failure");
398 ctx_.
app,
view(), accountKeylet, ownerDirKeylet, signerListKeylet,
j_);
410 ledgerEntry->setFieldU32(
sfFlags, flags);
412 bool const expandedSignerList =
427 if (expandedSignerList && entry.tag)
static NotTEC validateQuorumAndSignerEntries(std::uint32_t quorum, std::vector< SignerEntries::SignerEntry > const &signers, AccountID const &account, beast::Journal j, Rules const &)
const SF_UINT32 sfSignerListID
Keylet ownerDir(AccountID const &id) noexcept
The root page of an account's directory.
const SF_UINT32 sfOwnerCount
void setAccountID(SField const &field, AccountID const &)
const SF_UINT16 sfSignerWeight
NotTEC preflight2(PreflightContext const &ctx)
Checks whether the signature appears valid.
A pair of SHAMap key and LedgerEntryType.
bool enabled(uint256 const &feature) const
Returns true if a feature is enabled.
const SF_UINT64 sfOwnerNode
void setFieldU16(SField const &field, std::uint16_t)
Stream trace() const
Severity stream access functions.
virtual std::shared_ptr< SLE > peek(Keylet const &k)=0
Prepare to modify the SLE associated with key.
std::function< void(SLE::ref)> describeOwnerDir(AccountID const &account)
static Expected< std::vector< SignerEntry >, NotTEC > deserialize(STObject const &obj, beast::Journal journal, std::string const &annotation)
const SF_ACCOUNT sfRegularKey
virtual void erase(std::shared_ptr< SLE > const &sle)=0
Remove a peeked SLE.
virtual Fees const & fees() const =0
Returns the fees for the base ledger.
std::string toBase58(AccountID const &v)
Convert AccountID to base58 checked string.
const uint256 featureMultiSignReserve
static const std::uint32_t defaultSignerListID_
NotTEC preflight1(PreflightContext const &ctx)
Performs early sanity checks on the account and fee fields.
Writeable view to a ledger, for applying a transaction.
const SF_UINT32 sfSignerQuorum
bool dirRemove(Keylet const &directory, std::uint64_t page, uint256 const &key, bool keepRoot)
Remove an entry from a directory.
void adjustOwnerCount(ApplyView &view, std::shared_ptr< SLE > const &sle, std::int32_t amount, beast::Journal j)
Adjust the owner count up or down.
const uint256 featureExpandedSignerList
Keylet account(AccountID const &id) noexcept
AccountID root.
AccountID getAccountID(SField const &field) const
void setFieldH256(SField const &field, uint256 const &)
TERSubset< CanCvtToTER > TER
static int signerCountBasedOwnerCountDelta(std::size_t entryCount, Rules const &rules)
static TER removeFromLedger(Application &app, ApplyView &view, AccountID const &account, beast::Journal j)
A generic endpoint for log messages.
static std::size_t maxMultiSigners(Rules const *rules=0)
void reserve(std::size_t n)
static std::tuple< NotTEC, std::uint32_t, std::vector< SignerEntries::SignerEntry >, Operation > determineOperation(STTx const &tx, ApplyFlags flags, beast::Journal j)
const SField sfSignerEntry
const SField sfSignerEntries
virtual void insert(std::shared_ptr< SLE > const &sle)=0
Insert a new state SLE.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
virtual beast::Journal journal(std::string const &name)=0
const SF_UINT256 sfWalletLocator
std::vector< SignerEntries::SignerEntry > signers_
Buffer sign(PublicKey const &pk, SecretKey const &sk, Slice const &m)
Generate a signature for a message.
void emplace_back(Args &&... args)
XRPAmount accountReserve(std::size_t ownerCount) const
Returns the account reserve given the owner count, in drops.
virtual Rules const & rules() const =0
Returns the tx processing rules.
bool isFieldPresent(SField const &field) const
void preCompute() override
T adjacent_find(T... args)
@ tecINSUFFICIENT_RESERVE
Rules controlling protocol behavior.
static const std::size_t minMultiSigners
static TER removeSignersFromLedger(Application &app, ApplyView &view, Keylet const &accountKeylet, Keylet const &ownerDirKeylet, Keylet const &signerListKeylet, beast::Journal j)
const SF_ACCOUNT sfAccount
State information when preflighting a tx.
static Keylet signers(AccountID const &account, std::uint32_t page) noexcept
std::optional< std::uint64_t > dirInsert(Keylet const &directory, uint256 const &key, std::function< void(std::shared_ptr< SLE > const &)> const &describe)
Insert an entry to a directory.
void writeSignersToSLE(SLE::pointer const &ledgerEntry, std::uint32_t flags) const
virtual void preCompute()
static NotTEC preflight(PreflightContext const &ctx)
TERSubset< CanCvtToNotTEC > NotTEC