bech32-decode ( bech32 checksum -- hrp data )


Vocabulary
bech32.private

Inputs
bech32an object
checksuman object


Outputs
hrpan object
dataan object


Definition


: bech32-decode ( bech32 checksum -- hrp data )
over {
[ [ 33 126 between? not ] any? ]
[ [ dup >lower = ] [ dup >upper = ] bi or not ]
} 1||
[ 2drop f f ] [
swap >lower 49 over last-index {
[ dup not ]
[ dup 1 83 between? not ]
[ 2dup [ length ] [ 7 + ] bi* < ]
} 0||
[ 3drop f f ] [
cut rest [
{
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
15
f
10
17
21
20
26
30
7
5
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
29
f
~24 more~
} nth 255 or
] B{ } map-as dup [ 255 = ] any?
[ 3drop f f ] [
rot [ 2dup ] dip bech32-checksum?
[ 6 head* ] [ 2drop f f ] if
] if
] if
] if ;