You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `flag` package provides utility functions for working with bitwise flags in XRPL.
6
+
7
+
- `Contains`: Checks whether a flag is fully set within a combined flag value. Useful for inspecting transaction or ledger object flags.
8
+
9
+
## Usage
10
+
11
+
To import the package, you can use the following code:
12
+
13
+
```go
14
+
import "github.com/Peersyst/xrpl-go/xrpl/flag"
15
+
```
16
+
17
+
## API
18
+
19
+
### Contains
20
+
21
+
```go
22
+
func Contains(currentFlag uint32, flag uint32) bool
23
+
```
24
+
25
+
Returns `true` if all bits of `flag` are set in `currentFlag` (`(currentFlag & flag) == flag`). Returns `false` if any bit of `flag` is missing in `currentFlag`, or if `flag` is `0`.
26
+
27
+
:::warning
28
+
29
+
The comparison is based on the flag value as a `uint32`. Different contexts may use the same numeric values (e.g. a transaction flag and a ledger-state flag), so a match only indicates the bit is set — not that it belongs to a specific context. Always pair `Contains` with the flag constant that matches the context you are checking.
30
+
31
+
:::
32
+
33
+
### Example
34
+
35
+
```go
36
+
package main
37
+
38
+
import (
39
+
"fmt"
40
+
41
+
"github.com/Peersyst/xrpl-go/xrpl/flag"
42
+
"github.com/Peersyst/xrpl-go/xrpl/transaction"
43
+
)
44
+
45
+
func main() {
46
+
offer := transaction.OfferCreate{
47
+
BaseTx: transaction.BaseTx{
48
+
Account: "rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe",
49
+
},
50
+
TakerGets: nil,
51
+
TakerPays: nil,
52
+
}
53
+
54
+
// Set the sell flag on the offer
55
+
offer.SetSellFlag()
56
+
57
+
// Check whether the sell flag is set
58
+
if flag.Contains(offer.Flags, transaction.TfSell) {
59
+
fmt.Println("Offer is a sell offer")
60
+
}
61
+
62
+
// Check whether the fill-or-kill flag is set (it is not)
63
+
if !flag.Contains(offer.Flags, transaction.TfFillOrKill) {
Copy file name to clipboardExpand all lines: xrpl/ledger-entry-types/account_root.go
+46-46Lines changed: 46 additions & 46 deletions
Original file line number
Diff line number
Diff line change
@@ -6,36 +6,36 @@ import (
6
6
)
7
7
8
8
const (
9
-
// Enable Clawback for this account. (Requires the Clawback amendment.)
10
-
lsfAllowTrustLineClawback uint32 = 0x80000000
11
-
// Allow IOUs to be used as escrow amounts for an issuer
12
-
lsfAllowTrustLineLocking uint32 = 0x40000000
13
-
// Enable rippling on this addresses's trust lines by default. Required for issuing addresses; discouraged for others.
14
-
lsfDefaultRipple uint32 = 0x00800000
15
-
// This account has DepositAuth enabled, meaning it can only receive funds from transactions it sends, and from preauthorized accounts. (Added by the DepositAuth amendment)
16
-
lsfDepositAuth uint32 = 0x01000000
17
-
// Disallows use of the master key to sign transactions for this account.
18
-
lsfDisableMaster uint32 = 0x00100000
19
-
// This account blocks incoming Checks. (Added by the DisallowIncoming amendment.)
20
-
lsfDisallowIncomingCheck uint32 = 0x08000000
21
-
// This account blocks incoming NFTokenOffers. (Added by the DisallowIncoming amendment.)
// This account blocks incoming Payment Channels. (Added by the DisallowIncoming amendment.)
24
-
lsfDisallowIncomingPayChan uint32 = 0x10000000
25
-
// This account blocks incoming trust lines. (Added by the DisallowIncoming amendment.)
26
-
lsfDisallowIncomingTrustline uint32 = 0x20000000
27
-
// Client applications should not send XRP to this account. (Advisory; not enforced by the protocol.)
28
-
lsfDisallowXRP uint32 = 0x00080000
29
-
// All assets issued by this account are frozen.
30
-
lsfGlobalFreeze uint32 = 0x00400000
31
-
// This account cannot freeze trust lines connected to it. Once enabled, cannot be disabled.
32
-
lsfNoFreeze uint32 = 0x00200000
33
-
// This account has used its free SetRegularKey transaction.
34
-
lsfPasswordSpent uint32 = 0x00010000
35
-
// This account must individually approve other users for those users to hold this account's tokens.
36
-
lsfRequireAuth uint32 = 0x00040000
37
-
// Requires incoming payments to specify a Destination Tag.
38
-
lsfRequireDestTag uint32 = 0x00020000
9
+
// LsfAllowTrustLineClawback enables Clawback for this account. (Requires the Clawback amendment.)
10
+
LsfAllowTrustLineClawback uint32 = 0x80000000
11
+
// LsfAllowTrustLineLocking allows IOUs to be used as escrow amounts for an issuer
12
+
LsfAllowTrustLineLocking uint32 = 0x40000000
13
+
// LsfDefaultRipple enables rippling on this addresses's trust lines by default. Required for issuing addresses; discouraged for others.
14
+
LsfDefaultRipple uint32 = 0x00800000
15
+
// LsfDepositAuth this account has DepositAuth enabled, meaning it can only receive funds from transactions it sends, and from preauthorized accounts. (Added by the DepositAuth amendment)
16
+
LsfDepositAuth uint32 = 0x01000000
17
+
// LsfDisableMaster disallows use of the master key to sign transactions for this account.
18
+
LsfDisableMaster uint32 = 0x00100000
19
+
// LsfDisallowIncomingCheck this account blocks incoming Checks. (Added by the DisallowIncoming amendment.)
20
+
LsfDisallowIncomingCheck uint32 = 0x08000000
21
+
// LsfDisallowIncomingNFTokenOffer this account blocks incoming NFTokenOffers. (Added by the DisallowIncoming amendment.)
0 commit comments