Skip to content

Commit 37f4133

Browse files
moving bech32 impl to contrib folder and updating tests after changing default algo in previous commit
1 parent b42f422 commit 37f4133

File tree

9 files changed

+48
-21
lines changed

9 files changed

+48
-21
lines changed

contrib/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ add_contrib (jwt-cpp-cmake jwt-cpp)
248248

249249
add_contrib (sha3iuf-cmake SHA3IUF)
250250

251+
add_contrib (bech32)
251252

252253
# Put all targets defined here and in subdirectories under "contrib/<immediate-subdir>" folders in GUI-based IDEs.
253254
# Some of third-party projects may override CMAKE_FOLDER or FOLDER property of their targets, so they would not appear

contrib/bech32/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
add_library(_bech32
2+
include/bech32.h
3+
src/bech32.cpp)
4+
5+
target_include_directories(_bech32 PUBLIC include)
6+
target_include_directories(_bech32 PRIVATE src)
7+
8+
add_library(ch_contrib::bech32 ALIAS _bech32)

contrib/bech32/LICENSE-MIT

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2017, 2021 Pieter Wuille
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in
11+
all copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
THE SOFTWARE.
File renamed without changes.
File renamed without changes.

src/Functions/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ list (APPEND PRIVATE_LIBS
6161
boost::filesystem
6262
divide_impl
6363
ch_contrib::xxHash
64+
ch_contrib::bech32
6465
)
6566

6667
if (TARGET OpenSSL::Crypto)

src/Functions/FunctionsBech32Representation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include <Functions/FunctionFactory.h>
77
#include <Functions/IFunction.h>
88

9-
#include "bech32.h"
9+
#include <bech32.h>
1010

1111
namespace
1212
{

tests/queries/0_stateless/03512_bech32_enc_dec.reference

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
1-
bc1w508d6qejxtdg4y5r3zarvary0c5xw7kj7gz7z
2-
tb1w508d6qejxtdg4y5r3zarvary0c5xw7kzp034v
3-
bc1w508d6qejxtdg4y5r3zarvary0c5xw7kw508d6qejxtdg4y5r3zarvary0c5xw7kw508d6qejxtdg4y5hkya85
4-
bcrt17capp7
5-
bcrt1w508d6qejxtdg4y5r3zarvary0c5xw7kkedzxp
6-
tltc1w508d6qejxtdg4y5r3zarvary0c5xw7kkzve4x
7-
tltssdfsdvjnasdfnjkbhksdfasnbdfkljhaksdjfnakjsdhasdfnasdkfasdfasdfasdf1w50qsz2tg5
1+
bc1w508d6qejxtdg4y5r3zarvary0c5xw7k8zcwmq
2+
tb1w508d6qejxtdg4y5r3zarvary0c5xw7khalasw
3+
bc1w508d6qejxtdg4y5r3zarvary0c5xw7kw508d6qejxtdg4y5r3zarvary0c5xw7kw508d6qejxtdg4y5z253zk
4+
bcrt1tyddyu
5+
bcrt1w508d6qejxtdg4y5r3zarvary0c5xw7kr9awrr
6+
tltc1w508d6qejxtdg4y5r3zarvary0c5xw7kr7u4sy
7+
tltssdfsdvjnasdfnjkbhksdfasnbdfkljhaksdjfnakjsdhasdfnasdkfasdfasdfasdf1w50q9768dk
88

99

10-
bc1w508d6qejxtdg4y5r3zarvary0c5xw7kj7gz7z
10+
bc1w508d6qejxtdg4y5r3zarvary0c5xw7k8zcwmq
1111

1212
1
13-
bc1w508d6qejxtdg4y5r3zarvary0c5xw7k8zcwmq
14-
tb1w508d6qejxtdg4y5r3zarvary0c5xw7khalasw
13+
bc1w508d6qejxtdg4y5r3zarvary0c5xw7kj7gz7z
1514
1
1615
bc 751E76E8199196D454941C45D1B3A323F1433BD6
17-
bc1v6r3z2nw4k6d3rffc7j9mftwluxz8v8pfe6h6sywtwyntp bc1v6r3z2nw4k6d3rffc7j9mftwluxz8v8pfe6h6sywtwyntp 1 1 1
18-
tb137xd6smyhd7u5ywyjapa5tzt2srzlgpc3wleysrcm8ghua tb137xd6smyhd7u5ywyjapa5tzt2srzlgpc3wleysrcwmcmel 1 1 1
19-
bc12zuq63wvya0nd66lktpz4ylk5n5rh2fcpe2uvlm2d3sc77 bc12zuq63wvya0nd66lktpz4ylk5n5rh2fcpe2uvlm2cdq5mu 1 1 1
20-
tb1kyp6rymudchmnhns0f97qt2a883p0d9u5l8re8qjv988g7 tb1kyp6rymudchmnhns0f97qt2a883p0d9u5l8re8qjv988g7 1 1 1
21-
bcrt1jh4nxnlc9mu26as4rs5sjj4a4ekfazacy3zj8c68mq5ghf bcrt1jh4nxnlc9mu26as4rs5sjj4a4ekfazacy3zj8c68wuyyjt 1 1 1
16+
bc1v6r3z2nw4k6d3rffc7j9mftwluxz8v8pfe6h6syw7j5lwr bc1v6r3z2nw4k6d3rffc7j9mftwluxz8v8pfe6h6sywtwyntp 1 1 1
17+
tb137xd6smyhd7u5ywyjapa5tzt2srzlgpc3wleysrcwmcmel tb137xd6smyhd7u5ywyjapa5tzt2srzlgpc3wleysrcwmcmel 1 1 1
18+
bc12zuq63wvya0nd66lktpz4ylk5n5rh2fcpe2uvlm2cdq5mu bc12zuq63wvya0nd66lktpz4ylk5n5rh2fcpe2uvlm2cdq5mu 1 1 1
19+
tb1kyp6rymudchmnhns0f97qt2a883p0d9u5l8re8qjeehtdu tb1kyp6rymudchmnhns0f97qt2a883p0d9u5l8re8qjv988g7 1 1 1
20+
bcrt1jh4nxnlc9mu26as4rs5sjj4a4ekfazacy3zj8c68wuyyjt bcrt1jh4nxnlc9mu26as4rs5sjj4a4ekfazacy3zj8c68wuyyjt 1 1 1
2221
bc 6687112a6eadb4d88d29c7a45da56eff0c23b0e14e757d408e 1 1
2322
tb 8f8cdd4364bb7dca11c49743da2c4b54062fa0388bbf924078 1 1
2423
bc 50b80d45cc275f36eb5fb2c22a93f6a4e83ba9380e55c67f6a 1 1

tests/queries/0_stateless/03512_bech32_enc_dec.sql

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,12 @@ select bech32Encode('bc', unhex('751E76E8199196D454941C45D1B3A323F1433BD6'));
2121
-- 51 chars should return nothing
2222
select bech32Encode('', unhex('751e76e8199196d454941c45d1b3a323f1433bd6751e76e8199196d454941c45d1b3a323f1433bd6751e76e8199196d45494a'));
2323

24-
-- test with explicit witver = 0, should be same as default
25-
select bech32Encode('bc', unhex('751e76e8199196d454941c45d1b3a323f1433bd6'), 0) ==
24+
-- test with explicit witver = 1, should be same as default
25+
select bech32Encode('bc', unhex('751e76e8199196d454941c45d1b3a323f1433bd6'), 1) ==
2626
bech32Encode('bc', unhex('751e76e8199196d454941c45d1b3a323f1433bd6'));
2727

28-
-- testing bech32m algo
29-
select bech32Encode('bc', unhex('751e76e8199196d454941c45d1b3a323f1433bd6'), 1);
30-
select bech32Encode('tb', unhex('751e76e8199196d454941c45d1b3a323f1433bd6'), 2);
28+
-- testing old bech32 algo
29+
select bech32Encode('bc', unhex('751e76e8199196d454941c45d1b3a323f1433bd6'), 0);
3130

3231
-- witversions >=1 should all be the same
3332
select bech32Encode('bc', unhex('751e76e8199196d454941c45d1b3a323f1433bd6'), 1) ==

0 commit comments

Comments
 (0)