Appearance
slot_type
Summary. Return the field type of a slotted object, or (with a flag) whether a slotted amount is native XAH.
Signature.
c
int64_t slot_type(uint32_t slot_no, uint32_t flags);Parameters.
| Name | Type | Description |
|---|---|---|
slot_no | uint32_t | Slot to inspect. |
flags | uint32_t | 0 = return the field code; 1 = amount-native check (see below). |
Return value. Behaviour depends on flags:
flags == 0— returns the slot's field code,(type << 16) | index(thefieldCodeof the field'sSField).
flags == 1— the slot must hold anSTI_AMOUNT; returns1if the amount is native (XAH) and0if it is an IOU. If the slot is not an amount, returnsNOT_AN_AMOUNT(-32).
Errors for both modes: DOESNT_EXIST (-5) if the slot is empty; INTERNAL_ERROR (-2) if corrupt; INVALID_ARGUMENT (-7) if flags is neither 0 nor 1.
Common failure patterns.
- Using
flags == 1on a non-amount slot →NOT_AN_AMOUNT. - Passing a
flagsvalue other than 0 or 1 →INVALID_ARGUMENT.
Caveats / notes.
- The
flags == 0return is a field code, so you can compare it againstsf*constants to learn what a slotted field is before reading it. - Use
flags == 1to branch between XAH and IOU handling before callingslot_float.
Minimal example.
c
int64_t is_xrp = slot_type(amt_slot, 1); // 1 = XAH, 0 = IOURelated APIs. slot_float, slot_subfield.