From 192cfbbacdb13782077b2a5e56a724ccad67f1c1 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Wed, 2 Aug 2017 14:57:48 -0700 Subject: [PATCH 1/3] Add more reference implementations --- bip-0173.mediawiki | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bip-0173.mediawiki b/bip-0173.mediawiki index af2516d..4d3646e 100644 --- a/bip-0173.mediawiki +++ b/bip-0173.mediawiki @@ -242,8 +242,10 @@ P2PKH addresses can be used. * Reference encoder and decoder: ** [https://github.com/sipa/bech32/tree/master/ref/c For C] ** [https://github.com/sipa/bech32/tree/master/ref/javascript For JavaScript] +** [https://github.com/sipa/bech32/tree/master/ref/go For Go] ** [https://github.com/sipa/bech32/tree/master/ref/python For Python] ** [https://github.com/sipa/bech32/tree/master/ref/haskell For Haskell] +** [https://github.com/sipa/bech32/tree/master/ref/ruby For Ruby] ** [https://github.com/sipa/bech32/tree/master/ref/rust For Rust] * Fancy decoder that localizes errors: From 9b1e7dc8f5cba6937b95bd19c55c8b1af2fd05c5 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Wed, 2 Aug 2017 14:58:47 -0700 Subject: [PATCH 2/3] Fix incorrect tests for OP_n in v1+ witnesses --- bip-0173.mediawiki | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bip-0173.mediawiki b/bip-0173.mediawiki index 4d3646e..d9b3a03 100644 --- a/bip-0173.mediawiki +++ b/bip-0173.mediawiki @@ -266,9 +266,9 @@ The following list gives valid segwit addresses and the scriptPubKey that they translate to in hex. * BC1QW508D6QEJXTDG4Y5R3ZARVARY0C5XW7KV8F3T4: 0014751e76e8199196d454941c45d1b3a323f1433bd6 * tb1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3q0sl5k7: 00201863143c14c5166804bd19203356da136c985678cd4d27a1b8c6329604903262 -* bc1pw508d6qejxtdg4y5r3zarvary0c5xw7kw508d6qejxtdg4y5r3zarvary0c5xw7k7grplx: 8128751e76e8199196d454941c45d1b3a323f1433bd6751e76e8199196d454941c45d1b3a323f1433bd6 -* BC1SW50QA3JX3S: 9002751e -* bc1zw508d6qejxtdg4y5r3zarvaryvg6kdaj: 8210751e76e8199196d454941c45d1b3a323 +* bc1pw508d6qejxtdg4y5r3zarvary0c5xw7kw508d6qejxtdg4y5r3zarvary0c5xw7k7grplx: 5128751e76e8199196d454941c45d1b3a323f1433bd6751e76e8199196d454941c45d1b3a323f1433bd6 +* BC1SW50QA3JX3S: 6002751e +* bc1zw508d6qejxtdg4y5r3zarvaryvg6kdaj: 5210751e76e8199196d454941c45d1b3a323 * tb1qqqqqp399et2xygdj5xreqhjjvcmzhxw4aywxecjdzew6hylgvsesrxh6hy: 0020000000c4a5cad46221b2a187905e5266362b99d5e91c6ce24d165dab93e86433 The following list gives invalid segwit addresses and the reason for From 59391f1862873a66af0a15fe776cc335412cc875 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Thu, 3 Aug 2017 12:14:43 -0700 Subject: [PATCH 3/3] Elaborate on the encoding of witness versions --- bip-0173.mediawiki | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bip-0173.mediawiki b/bip-0173.mediawiki index d9b3a03..0c911b4 100644 --- a/bip-0173.mediawiki +++ b/bip-0173.mediawiki @@ -227,6 +227,12 @@ program is neither 20 nor 32 bytes, the script must fail.'' As a result of the previous rules, addresses are always between 14 and 74 characters long, and their length modulo 8 cannot be 0, 3, or 5. Version 0 witness addresses are always 42 or 62 characters, but implementations MUST allow the use of any version. +Implementations should take special care when converting the address to a +scriptPubkey, where witness version ''n'' is stored as ''OP_n''. OP_0 is +encoded as 0x00, but OP_1 through OP_16 are encoded as 0x51 though 0x60 +(81 to 96 in decimal). If a bech32 address is converted to an incorrect +scriptPubKey the result will likely be either unspendable or insecure. + ===Compatibility=== Only new software will be able to use these addresses, and only for