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
+
funcContains(currentFlaguint32, flaguint32) 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
-
lsfAllowTrustLineClawbackuint32=0x80000000
11
-
// Allow IOUs to be used as escrow amounts for an issuer
12
-
lsfAllowTrustLineLockinguint32=0x40000000
13
-
// Enable rippling on this addresses's trust lines by default. Required for issuing addresses; discouraged for others.
14
-
lsfDefaultRippleuint32=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
-
lsfDepositAuthuint32=0x01000000
17
-
// Disallows use of the master key to sign transactions for this account.
18
-
lsfDisableMasteruint32=0x00100000
19
-
// This account blocks incoming Checks. (Added by the DisallowIncoming amendment.)
20
-
lsfDisallowIncomingCheckuint32=0x08000000
21
-
// This account blocks incoming NFTokenOffers. (Added by the DisallowIncoming amendment.)
22
-
lsfDisallowIncomingNFTokenOfferuint32=0x04000000
23
-
// This account blocks incoming Payment Channels. (Added by the DisallowIncoming amendment.)
24
-
lsfDisallowIncomingPayChanuint32=0x10000000
25
-
// This account blocks incoming trust lines. (Added by the DisallowIncoming amendment.)
26
-
lsfDisallowIncomingTrustlineuint32=0x20000000
27
-
// Client applications should not send XRP to this account. (Advisory; not enforced by the protocol.)
28
-
lsfDisallowXRPuint32=0x00080000
29
-
// All assets issued by this account are frozen.
30
-
lsfGlobalFreezeuint32=0x00400000
31
-
// This account cannot freeze trust lines connected to it. Once enabled, cannot be disabled.
32
-
lsfNoFreezeuint32=0x00200000
33
-
// This account has used its free SetRegularKey transaction.
34
-
lsfPasswordSpentuint32=0x00010000
35
-
// This account must individually approve other users for those users to hold this account's tokens.
36
-
lsfRequireAuthuint32=0x00040000
37
-
// Requires incoming payments to specify a Destination Tag.
38
-
lsfRequireDestTaguint32=0x00020000
9
+
// LsfAllowTrustLineClawback enables Clawback for this account. (Requires the Clawback amendment.)
10
+
LsfAllowTrustLineClawbackuint32=0x80000000
11
+
// LsfAllowTrustLineLocking allows IOUs to be used as escrow amounts for an issuer
12
+
LsfAllowTrustLineLockinguint32=0x40000000
13
+
// LsfDefaultRipple enables rippling on this addresses's trust lines by default. Required for issuing addresses; discouraged for others.
14
+
LsfDefaultRippleuint32=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
+
LsfDepositAuthuint32=0x01000000
17
+
// LsfDisableMaster disallows use of the master key to sign transactions for this account.
18
+
LsfDisableMasteruint32=0x00100000
19
+
// LsfDisallowIncomingCheck this account blocks incoming Checks. (Added by the DisallowIncoming amendment.)
20
+
LsfDisallowIncomingCheckuint32=0x08000000
21
+
// LsfDisallowIncomingNFTokenOffer this account blocks incoming NFTokenOffers. (Added by the DisallowIncoming amendment.)
22
+
LsfDisallowIncomingNFTokenOfferuint32=0x04000000
23
+
// LsfDisallowIncomingPayChan this account blocks incoming Payment Channels. (Added by the DisallowIncoming amendment.)
24
+
LsfDisallowIncomingPayChanuint32=0x10000000
25
+
// LsfDisallowIncomingTrustline this account blocks incoming trust lines. (Added by the DisallowIncoming amendment.)
26
+
LsfDisallowIncomingTrustlineuint32=0x20000000
27
+
// LsfDisallowXRP client applications should not send XRP to this account. (Advisory; not enforced by the protocol.)
28
+
LsfDisallowXRPuint32=0x00080000
29
+
// LsfGlobalFreeze all assets issued by this account are frozen.
30
+
LsfGlobalFreezeuint32=0x00400000
31
+
// LsfNoFreeze this account cannot freeze trust lines connected to it. Once enabled, cannot be disabled.
32
+
LsfNoFreezeuint32=0x00200000
33
+
// LsfPasswordSpent this account has used its free SetRegularKey transaction.
34
+
LsfPasswordSpentuint32=0x00010000
35
+
// LsfRequireAuth this account must individually approve other users for those users to hold this account's tokens.
36
+
LsfRequireAuthuint32=0x00040000
37
+
// LsfRequireDestTag requires incoming payments to specify a Destination Tag.
38
+
LsfRequireDestTaguint32=0x00020000
39
39
)
40
40
41
41
// AccountRoot ledger entry type describes a single account, its settings, and XRP balance.
@@ -73,7 +73,7 @@ type AccountRoot struct {
73
73
Account types.Address
74
74
// The identifying hash of the transaction most recently sent by this account.
75
75
// This field must be enabled to use the AccountTxnID transaction field.
76
-
// To enable it, send an AccountSet transaction with the asfAccountTxnID flag enabled.
76
+
// To enable it, send an AccountSet transaction with the AsfAccountTxnID flag enabled.
77
77
AccountTxnID types.Hash256`json:",omitempty"`
78
78
// (Added by the AMM amendment) The ledger entry ID of the corresponding AMM ledger entry.
79
79
// Set during account creation; cannot be modified. If present, indicates that this is a
0 commit comments