Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmake/scripts/codegen/generate_tx_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def create_transaction_parser():
"delegable": "Delegation::NotDelegable",
"amendment": "uint256{}",
"privileges": "Privilege::NoPriv",
"firewall": "FirewallAction::Allow",
}


Expand Down
17 changes: 17 additions & 0 deletions include/xrpl/protocol/Firewall.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#pragma once

#include <xrpl/protocol/TxFormats.h>
#include <xrpl/protocol/TxSettings.h>

namespace xrpl {

/**
* How an account's firewall treats a transaction of the given type.
*
* The classification is declared per transaction in transactions.macro. A type
* the switch does not name, which means a deprecated one, is allowed.
*/
[[nodiscard]] FirewallAction
firewallAction(TxType txType) noexcept;

} // namespace xrpl
27 changes: 27 additions & 0 deletions include/xrpl/protocol/Indexes.h
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,33 @@ vault(uint256 const& vaultKey)
Keylet
loanBroker(AccountID const& owner, SeqProxy const& seq) noexcept;

/**
* A firewall, keyed by the account it protects.
*/
Keylet
firewall(AccountID const& account) noexcept;

inline Keylet
firewall(uint256 const& firewallID)
{
return {ltFIREWALL, firewallID};
}

/**
* A withdraw preauthorization, keyed by owner, authorized account and tag.
*/
Keylet
withdrawPreauth(
AccountID const& owner,
AccountID const& preauthorized,
std::uint32_t dtag) noexcept;

inline Keylet
withdrawPreauth(uint256 const& key)
{
return {ltWITHDRAW_PREAUTH, key};
}

inline Keylet
loanBroker(uint256 const& key)
{
Expand Down
1 change: 1 addition & 0 deletions include/xrpl/protocol/TER.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ enum TEFcodes : TERUnderlyingType {
tefBAD_PATH_COUNT,
tefNO_BYTECODE,
tefBYTECODE_NOT_INCLUDED,
tefFIREWALL_BLOCK,
};

//------------------------------------------------------------------------------
Expand Down
26 changes: 26 additions & 0 deletions include/xrpl/protocol/TxSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,27 @@ namespace xrpl {

enum class Delegation { Delegable, NotDelegable };

/**
* How an account's firewall treats a transaction the account submits.
*
* The classification is per transaction type and is read through
* firewallAction() in <xrpl/protocol/Firewall.h>.
*/
enum class FirewallAction {
/**
* The firewall inspects the transaction's destination before applying it.
*/
Check,
/**
* The firewall lets the transaction through without inspecting it.
*/
Allow,
/**
* The firewall rejects the transaction while a firewall is set.
*/
Block
};

/**
* Operations a transaction is permitted to perform, as a bitfield.
*
Expand Down Expand Up @@ -91,6 +112,11 @@ struct TxSettings
* Operations this transaction is permitted to perform.
*/
Privilege privileges{Privilege::NoPriv};

/**
* How an account's firewall treats this transaction.
*/
FirewallAction firewall{FirewallAction::Allow};
};

} // namespace xrpl
1 change: 1 addition & 0 deletions include/xrpl/protocol/detail/features.macro
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// Add new amendments to the top of this list.
// Keep it sorted in reverse chronological order.

XRPL_FEATURE(Firewall, Supported::No, VoteBehavior::DefaultNo)
XRPL_FEATURE(SmartEscrow, Supported::No, VoteBehavior::DefaultNo)
XRPL_FEATURE(LendingProtocolV1_2, Supported::No, VoteBehavior::DefaultNo)
XRPL_FIX (Cleanup3_5_0, Supported::Yes, VoteBehavior::DefaultNo)
Expand Down
25 changes: 25 additions & 0 deletions include/xrpl/protocol/detail/ledger_entries.macro
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,31 @@ LEDGER_ENTRY(ltVAULT, 0x0084, Vault, vault, ({
// no PermissionedDomainID ever (use MPTIssuance.sfDomainID)
}))

/** A ledger object which blocks an account's outgoing value until a
counterparty co-signs, or the destination is preauthorized.
\sa keylet::firewall
*/
LEDGER_ENTRY(ltFIREWALL, 0x0085, Firewall, firewall, ({
{sfOwner, SoeRequired},
{sfCounterparty, SoeRequired},
{sfMaxFee, SoeOptional},
{sfOwnerNode, SoeRequired},
{sfPreviousTxnID, SoeRequired},
{sfPreviousTxnLgrSeq, SoeRequired},
}))

/** A ledger object which preauthorizes one destination of a firewalled account.
\sa keylet::withdrawPreauth
*/
LEDGER_ENTRY_DUPLICATE(ltWITHDRAW_PREAUTH, 0x0086, WithdrawPreauth, withdraw_preauth, ({
{sfAccount, SoeRequired},
{sfAuthorize, SoeRequired},
{sfDestinationTag, SoeOptional},
{sfOwnerNode, SoeRequired},
{sfPreviousTxnID, SoeRequired},
{sfPreviousTxnLgrSeq, SoeRequired},
}))

/** Reserve 0x0084-0x0087 for future Vault-related objects. */

/** A ledger object representing a loan broker
Expand Down
2 changes: 2 additions & 0 deletions include/xrpl/protocol/detail/sfields.macro
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ TYPED_SFIELD(sfLoanID, UINT256, 38)
TYPED_SFIELD(sfReferenceHolding, UINT256, 39)
TYPED_SFIELD(sfBlindingFactor, UINT256, 40)
TYPED_SFIELD(sfObjectID, UINT256, 41)
TYPED_SFIELD(sfFirewallID, UINT256, 42)

// number (common)
TYPED_SFIELD(sfNumber, NUMBER, 1)
Expand Down Expand Up @@ -360,6 +361,7 @@ TYPED_SFIELD(sfHighSponsor, ACCOUNT, 28)
TYPED_SFIELD(sfLowSponsor, ACCOUNT, 29)
TYPED_SFIELD(sfCounterpartySponsor, ACCOUNT, 30)
TYPED_SFIELD(sfSponsee, ACCOUNT, 31)
TYPED_SFIELD(sfBackup, ACCOUNT, 32)

// vector of 256-bit
TYPED_SFIELD(sfIndexes, VECTOR256, 1, SField::kSmdNever)
Expand Down
Loading