Open LimpidCrypto opened 2 years ago
This is an example of this done in xrpl.js specifically for AccountRoot
flags which may be a helpful reference: https://github.com/XRPLF/xrpl.js/pull/1699/files
(xrpl.org is the best source for what the flags do)
This is an example of this done in xrpl.js specifically for
AccountRoot
flags which may be a helpful reference: https://github.com/XRPLF/xrpl.js/pull/1699/files(xrpl.org is the best source for what the flags do)
Yeah, I also already posted an example for python on Discord once:
ACCOUNT_ROOT_LEDGER_FLAGS: Dict[str, int] = {
"lsfPasswordSpent": 0x00010000,
"lsfRequireDestTag": 0x00020000,
"lsfRequireAuth": 0x00040000,
"lsfRequireAuth": 0x00040000,
"lsfDisableMaster": 0x00100000,
"lsfNoFreeze": 0x00200000,
"lsfGlobalFreeze": 0x00400000,
"lsfDefaultRipple": 0x00800000,
"lsfDepositAuth": 0x01000000,
}
def parse_account_root_flags(flags: int) -> List[str]:
flags_enabled = []
for flag in ACCOUNT_ROOT_LEDGER_FLAGS:
check_flag = ACCOUNT_ROOT_LEDGER_FLAGS[flag]
if check_flag & flags == check_flag:
flags_enabled.append(flag)
return flags_enabled
print(parse_account_root_flags(4194304))
When receiving a transactions data, the
Flags
field contains all flags set expressed as integer. Example:In this example the
Flags
set are2148139008
. Since it's not immediately obvious which flags are set for that transaction, there should be a utility function that derives the flag names from this integer. The function should take the transaction type and the flags expressed as integer (in this example 2148139008). For the example it should return something like['tf_immediate_or_cancel', 'tf_sell', 'tf_fully_canonical_sig']
.