nscript: load script view

This allows you to open and run scripts for testing purposes, but only
from external links such as nostr:nscript...
This commit is contained in:
William Casarin
2023-07-04 11:42:16 -07:00
parent 640fbf23ea
commit a04a401292
10 changed files with 261 additions and 25 deletions

View File

@@ -12,6 +12,7 @@ enum Bech32Object {
case nsec(String)
case npub(String)
case note(String)
case nscript([UInt8])
static func parse(_ str: String) -> Bech32Object? {
guard let decoded = try? bech32_decode(str) else {
@@ -24,6 +25,8 @@ enum Bech32Object {
return .nsec(hex_encode(decoded.data))
} else if decoded.hrp == "note" {
return .note(hex_encode(decoded.data))
} else if decoded.hrp == "nscript" {
return .nscript(decoded.data.bytes)
}
return nil