Skip to content

Commit

Permalink
Add Bech32 decodeNpub, decodeNsec, decodeNote, decodeNprofile
Browse files Browse the repository at this point in the history
…, `decodeNevent` and `decodeNrelay` methods (#23)
  • Loading branch information
lontivero authored Jan 2, 2024
1 parent c304dd8 commit 60b6b9d
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion Nostra/Bech32.fs
Original file line number Diff line number Diff line change
Expand Up @@ -236,4 +236,40 @@ module Shareable =
Some (NRelay(Encoding.ASCII.GetString (List.toArray relayUrl)))
| _ -> None
| _ -> None
)
)

let decodeNpub str =
decode str
|> Option.bind (function
| NPub pk -> Some (XOnlyPubKey pk)
| _ -> None)

let decodeNsec str =
decode str
|> Option.bind (function
| NSec sk -> Some sk
| _ -> None)

let decodeNote str =
decode str
|> Option.bind (function
| Note eventId -> Some eventId
| _ -> None)

let decodeNprofile str =
decode str
|> Option.bind (function
| NProfile (pk, relays) -> Some (pk, relays)
| _ -> None)

let decodeNevent str =
decode str
|> Option.bind (function
| NEvent (eventId, relays, author, kind) -> Some (eventId, relays, author, kind)
| _ -> None)

let decodeNrelay str =
decode str
|> Option.bind (function
| NRelay relays -> Some relays
| _ -> None)

0 comments on commit 60b6b9d

Please sign in to comment.