Nip19 class
Main NIP-19 class providing encoding, decoding, and validation This is a facade that delegates to specialized encoder/decoder classes
Constructors
- Nip19()
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- nip19regex ↔ RegExp
-
getter/setter pair
Static Methods
-
convertBits(
List< int> data, int from, int to, bool pad) → List<int> - Convert bits from one size to another Used for bech32 encoding/decoding
-
decode(
String nip19String) → String - Decode a NIP-19 encoded string (npub, note, nevent, nprofile, naddr) Returns the decoded hex string
-
decodeNaddr(
String naddrStr) → Naddr - Decode naddr and return Naddr object
-
decodeNevent(
String neventStr) → Nevent - Decode nevent and return Nevent object
-
decodeNprofile(
String nprofileStr) → Nprofile - Decode nprofile and return Nprofile object
-
encodeNaddr(
{required String identifier, required String pubkey, required int kind, List< String> ? relays}) → String -
Encode naddr (addressable event coordinate)
identifier- the "d" tag value (empty string for normal replaceable events)pubkey- 32-byte hex public key of the event author (required)kind- event kind number (required)relays- optional list of relay URLs where the event may be found -
encodeNevent(
{required String eventId, List< String> ? relays, String? author, int? kind}) → String -
Encode nevent (event reference)
eventId- 32-byte hex event ID (required)relays- optional list of relay URLs where the event may be foundauthor- optional 32-byte hex public key of the event authorkind- optional event kind number -
encodeNoteId(
String id) → String - Encode a note ID as note1
-
encodeNprofile(
{required String pubkey, List< String> ? relays}) → String -
Encode nprofile (profile reference)
pubkey- 32-byte hex public key (required)relays- optional list of relay URLs where the profile may be found -
encodePrivateKey(
String privateKey) → String - Encode a private key as nsec
-
encodePubKey(
String pubkey) → String - Encode a public key as npub
-
encodeSimplePubKey(
String pubKey) → String - Encode a public key in simplified format (first10:last10)
-
isKey(
String hrp, String str) → bool - Check if a string starts with a specific HRP (Human Readable Part)
-
isNip19(
String str) → bool - Check if a string matches NIP-19 format
-
isNoteId(
String str) → bool - Check if a string is a note ID (note1)
-
isPrivateKey(
String str) → bool - Check if a string is a private key (nsec)
-
isPubkey(
String str) → bool - Check if a string is a public key (npub)
Constants
- kNoteIdLength → const int
- kNpubLength → const int