-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbech32.1.in
More file actions
161 lines (161 loc) · 3.52 KB
/
bech32.1.in
File metadata and controls
161 lines (161 loc) · 3.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
.TH BECH32 1 2024-03-08 libbech32
.
.SH NAME
bech32 \- encode/decode data in
@@IF_BLECH32@@
Bech32/Bech32m/Blech32/Blech32m
@@ELSE_BLECH32@@
Bech32/Bech32m
@@ENDIF_BLECH32@@
format
.
.SH SYNOPSIS
.SY bech32
.OP \-h
@@IF_BLECH32@@
.OP \-l
@@ENDIF_BLECH32@@
.OP \-m
.I hrp
{
[\fIversion\fR]
|
.B \-d
[\fB\-v\fR|\fIversion\fR]
}
.SY bech32m
.OP \-h
.I hrp
{
[\fIversion\fR]
|
.B \-d
[\fB\-v\fR|\fIversion\fR]
}
@@IF_BLECH32@@
.SY blech32
.OP \-h
.I hrp
{
[\fIversion\fR]
|
.B \-d
[\fB\-v\fR|\fIversion\fR]
}
.SY blech32m
.OP \-h
.I hrp
{
[\fIversion\fR]
|
.B \-d
[\fB\-v\fR|\fIversion\fR]
}
@@ENDIF_BLECH32@@
.YS
.
.SH DESCRIPTION
.B bech32
reads data from \fBstdin\fR and writes its Bech32 encoding to \fBstdout\fR.
If \fIversion\fR is given, its least significant 5 bits are encoded as a SegWit version field.
.
.SH OPTIONS
.TP
.BR \-d ", " \-\-decode
Decode a Bech32 encoding from \fBstdin\fR and write the decoded data to \fBstdout\fR.
If \fIversion\fR is given, assert that it matches the version field in the data.
.TP
.BR \-h ", " \-\-hex
Use hexadecimal for data input/output.
If this option is not specified, the data are read/written in raw binary.
.TP
@@IF_BLECH32@@
.BR \-l ", " \-\-blech
Use Blech32/Blech32m instead of Bech32/Bech32m.
Implied if the command is invoked as
.BR blech32 " or " blech32m .
.TP
.BR \-m ", " \-\-modified
Use Bech32m/Blech32m instead of Bech32/Blech32.
Implied if the command is invoked as
.BR bech32m " or " blech32m .
@@ELSE_BLECH32@@
.BR \-m ", " \-\-modified
Use Bech32m instead of Bech32.
Implied if the command is invoked as
.BR bech32m .
@@ENDIF_BLECH32@@
.TP
.BR \-v ", " \-\-exit\-version
Extract a 5-bit SegWit version field and return it as the exit status.
.
.SH EXIT STATUS
.B bech32
returns 0 as its exit status if no errors were encountered.
If the \fB\-v\fR option is used, then the exit status is the 5-bit version field extracted from the encoding,
which will be between 0 and 31 (although note that only versions 0 through 16 are legal SegWit versions).
.PP
If an error occurs, then the exit status is one of the following values, as specified in
.BR sysexits.h (3):
.TP
.B 64
.B Usage error.
There was an error in the way the command was invoked.
.TP
.B 65
.B Data error.
There was an error in the data provided to the command,
or the data did not satisfy the specified constraints.
.TP
.B 70
.B Software error.
An internal error occurred.
This indicates a software bug or a hardware failure.
.TP
.B 74
.B I/O error.
An error occurred while reading from \fBstdin\fR or writing to \fBstdout\fR.
.
.SH EXAMPLES
Encode a 2-byte, version-16 witness program, given in hexadecimal:
.IP
.EX
$ \fBecho 751e | bech32m -h bc 16\fR
bc1sw50qgdz25j
.EE
.PP
Decode a Bech32m encoding to hexadecimal and return its witness version as the exit status:
.IP
.EX
$ \fBecho bc1sw50qgdz25j | bech32m -dhv bc ; echo $?\fR
751e
16
.EE
.PP
Encode a P2WPKH SegWit address, given its public key hash in hexadecimal:
.IP
.EX
$ \fBecho 751e76e8199196d454941c45d1b3a323f1433bd6 | bech32 -h bc 0\fR
bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4
.EE
.PP
Decode the public key hash from a P2WPKH SegWit address,
and assert that its human-readable prefix is \fBbc\fR and its witness version is 0:
.IP
.EX
$ \fBecho bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4 | bech32 -dh bc 0\fR
751e76e8199196d454941c45d1b3a323f1433bd6
.EE
.PP
Encode an empty string in Bech32 format with no version field:
.IP
.EX
$ \fBbech32 bc </dev/null\fR
bc1gmk9yu
.EE
.
.SH REPORTING BUGS
Please report any bugs at the
.UR https://github.com/whitslack/libbech32/issues
libbech32 project page on GitHub
.UE .