|
| 1 | +--- |
| 2 | +title: 'Bitcoin Optech Newsletter #40' |
| 3 | +permalink: /en/newsletters/2019/04/02/ |
| 4 | +name: 2019-04-02-newsletter |
| 5 | +type: newsletter |
| 6 | +layout: newsletter |
| 7 | +lang: en |
| 8 | +--- |
| 9 | +This week's newsletter notes a spike in estimated transaction fees, |
| 10 | +describes LN trampoline payments, and publicizes Bitcoin Core's intent |
| 11 | +to default its built-in wallet to bech32 receiving addresses in version |
| 12 | +0.20 or earlier. Also included are regular sections about bech32 |
| 13 | +sending support and notable code changes in popular Bitcoin |
| 14 | +infrastructure projects. |
| 15 | + |
| 16 | +## Action items |
| 17 | + |
| 18 | +- **Help test Bitcoin Core 0.18.0 RC2:** The second Release Candidate |
| 19 | + (RC) for the next major version of Bitcoin Core has been [released][0.18.0]. |
| 20 | + Testing is still needed by organizations and experienced users who |
| 21 | + plan to run the new version of Bitcoin Core in production. Use [this |
| 22 | + issue][Bitcoin Core #15555] for reporting feedback. |
| 23 | + |
| 24 | +## Network status |
| 25 | + |
| 26 | +- **Fee increases for fast confirmation:** after over a year of most |
| 27 | + Bitcoin transactions confirming rather quickly as long as they paid a |
| 28 | + feerate above the default minimum relay fee (except during [a brief |
| 29 | + exceptional period][Newsletter #22]), a modest backlog has developed |
| 30 | + over the previous week and raised the feerates for people who need |
| 31 | + their transactions to confirm within the next several blocks. |
| 32 | + Spenders willing to wait a bit longer can still receive a good deal. |
| 33 | + For example, as of this writing, Bitcoin Core's fee estimator suggests |
| 34 | + a fee per 1,000 vbytes of 533 µBTC for confirmation within 2 blocks |
| 35 | + but only 25 µBTC for confirmation within 50 blocks---a 95% savings for |
| 36 | + waiting up to an extra 8 hours. For more information, we recommend |
| 37 | + [Johoe's mempool statistics][] and [P2SH.info's fee estimate |
| 38 | + tracker][]. |
| 39 | + |
| 40 | +## News |
| 41 | + |
| 42 | +- **Trampoline payments for LN:** Pierre-Marie Padiou started a |
| 43 | + [thread][trampoline thread] on the Lightning-Dev mailing list |
| 44 | + suggesting that Alice could send a payment to Zed even if she didn't |
| 45 | + know a path to his node by first sending a payment to an intermediate |
| 46 | + node (Dan) and asking Dan to figure out the route the rest of the way |
| 47 | + to Zed. This would especially benefit Alice if she ran a lightweight |
| 48 | + LN node that didn't attempt to keep track of the entire network. For |
| 49 | + increased privacy, Alice could use several intermediate nodes in |
| 50 | + succession rather than just one (each one receiving it's own |
| 51 | + instructions encrypted by Alice). A downside described in the email |
| 52 | + is that Alice could only make a rough guess about the required fees as |
| 53 | + she wouldn't know the actual path, so she'd probably end up paying |
| 54 | + more in fees than if she chose the route herself. |
| 55 | + |
| 56 | +- **Bitcoin Core schedules switch to default bech32 receiving |
| 57 | + addresses:** since [version 0.16.0][0.16.0 segwit], Bitcoin Core's |
| 58 | + built-in wallet has defaulted to generating P2SH-wrapped segwit |
| 59 | + addresses when users want to receive payments. These addresses are |
| 60 | + backwards compatible with all widely-used software. As |
| 61 | + discussed in an [issue][Bitcoin Core #15560] and [the project's weekly |
| 62 | + meeting][core meeting segwit], starting with Bitcoin Core 0.20 |
| 63 | + (expected about a year from now), Bitcoin Core will default to native |
| 64 | + segwit addresses (bech32) that provide additional fee savings and |
| 65 | + other benefits. Currently, many wallets and services [already support |
| 66 | + bech32 addresses][bech32 adoption], and if the Bitcoin Core project |
| 67 | + sees enough additional adoption in the next six months to warrant an |
| 68 | + earlier switch, it will instead default to bech32 receiving addresses |
| 69 | + in Bitcoin Core 0.19. Legacy address will continue to be provided |
| 70 | + if the user requests them in the GUI or by RPC, and anyone who doesn't |
| 71 | + want the update will be able to configure their default address type. |
| 72 | + (Similarly, pioneering users who want to change their default now may |
| 73 | + set the `addresstype=bech32` configuration option in any Bitcoin Core |
| 74 | + release from 0.16.0 up.) |
| 75 | + |
| 76 | +## Bech32 sending support |
| 77 | + |
| 78 | +*Week 3 of 24. From now until the second anniversary of the segwit soft |
| 79 | +fork lock-in on 24 August 2019, the Optech Newsletter will contain this |
| 80 | +weekly section that provides information to help developers and |
| 81 | +organizations implement bech32 sending support---the ability to pay |
| 82 | +native segwit addresses. This [doesn't require implementing |
| 83 | +segwit][bech32 easy] yourself, but it does allow the people you pay to |
| 84 | +access all of segwit's multiple benefits.* |
| 85 | + |
| 86 | +In a [previous week][bech32 easy], we discussed how small the |
| 87 | +differences are between creating the output for a legacy address versus |
| 88 | +a native segwit address. In that section we simply pointed you towards |
| 89 | +the [bech32 reference libraries][] and told you that you'd get two |
| 90 | +values back. In this week, we walkthrough the exact steps of using the |
| 91 | +Python reference library so you can see how little work this is. We |
| 92 | +start by importing the library: |
| 93 | + |
| 94 | +```python3 |
| 95 | +import segwit_addr |
| 96 | +``` |
| 97 | + |
| 98 | +Bech32 addresses have a Human-Readable Part (HRP) that indicates what |
| 99 | +network the address is for. These are the first few characters of the |
| 100 | +address and are separated from the data part of the address by the |
| 101 | +delimiter `1`. For example, Bitcoin testnet uses `tb` and an example |
| 102 | +testnet address is tb1q3w[...]g7a. We'll set the Bitcoin mainnet HRP of |
| 103 | +`bc` in our code so that we can later ensure that the addresses we parse |
| 104 | +are for the network we expect. |
| 105 | + |
| 106 | +```python3 |
| 107 | +HRP='bc' |
| 108 | +``` |
| 109 | + |
| 110 | +Finally, we have a few addresses we want to check---one that should work |
| 111 | +and two that should fail. (See [BIP173][] for a complete set of |
| 112 | +reference test vectors.) |
| 113 | + |
| 114 | +```python3 |
| 115 | +good_address='bc1qd6h6vp99qwstk3z668md42q0zc44vpwkk824zh' |
| 116 | +typo_address='bc1qd6h6vp99qwstk3z669md42q0zc44vpwkk824zh' |
| 117 | +wrong_network_address='tb1q3wrc5yq9c300jxlfeg7ae76tk9gsx044ucyg7a' |
| 118 | +``` |
| 119 | + |
| 120 | +Now we can simply attempt to decode each of these addresses |
| 121 | + |
| 122 | +```python3 |
| 123 | +>>> segwit_addr.decode(HRP, good_address) |
| 124 | +(0, [110, 175, 166, 4, 165, 3, 160, 187, 68, 90, 209, |
| 125 | + 246, 218, 168, 15, 22, 43, 86, 5, 214]) |
| 126 | + |
| 127 | +In [16]: segwit_addr.decode(HRP, typo_address) |
| 128 | +Out[16]: (None, None) |
| 129 | + |
| 130 | +In [17]: segwit_addr.decode(HRP, wrong_network_address) |
| 131 | +Out[17]: (None, None) |
| 132 | +``` |
| 133 | + |
| 134 | +If we get back a None for the first value (the witness version), the |
| 135 | +address is invalid on our chosen network, so you want to throw an |
| 136 | +exception up the stack so that whatever process is interfacing with the |
| 137 | +user can get them to provide you with a correct address. If you |
| 138 | +actually get a number and an array, the decode succeeded, the checksum |
| 139 | +was valid, and the length was within the allowed range. |
| 140 | + |
| 141 | +The witness version must be a number between 0 and 16, so you'll want to |
| 142 | +check that (e.g. `0 <= x <= 16`) and then convert it into the |
| 143 | +corresponding opcodes `OP_0` through `OP_16`. For `OP_0`, this is 0x00; |
| 144 | +for `OP_1` through `OP_16`, this is 0x51 through 0x60. You then need to |
| 145 | +add a push byte for the data depending on its length (0x02 through 0x28 |
| 146 | +for 2 to 40 bytes), and then append the data as a series of bytes. |
| 147 | +Pieter Wuille's [code][segwit addr to bytes] does this quite succinctly: |
| 148 | + |
| 149 | +```python3 |
| 150 | +>>> witver, witprog = segwit_addr.decode(HRP, good_address) |
| 151 | +>>> bytes([witver + 0x50 if witver else 0, len(witprog)] + witprog).hex() |
| 152 | +'00146eafa604a503a0bb445ad1f6daa80f162b5605d6' |
| 153 | +``` |
| 154 | + |
| 155 | +That's your entire scriptPubKey. You can use that in the output of a |
| 156 | +transaction and send it. Note that bech32 scriptPubKeys can vary in |
| 157 | +size from 4 to 42 vbytes, so you need to consider that in your |
| 158 | +fee estimation code. (With current segwit P2WPKH and P2WSH, the |
| 159 | +scriptPubKey sizes are 22 and 34 vbytes, respectively.) |
| 160 | + |
| 161 | +Your code doesn't need to be written in Python. Reference libraries |
| 162 | +are also provided for c, c++, go, haskell, javascript, ruby, and rust. |
| 163 | +Further, [BIP173][] describes bech32 well enough that any decent |
| 164 | +programmer should be able to implement it from scratch in their preferred |
| 165 | +language without requiring anything beyond what most programming |
| 166 | +languages provide in their builtins and standard library. |
| 167 | + |
| 168 | +**Other bech32 sending support updates:** BitGo [announced][bitgo |
| 169 | +segwit] that their API now supports sending to bech32 addresses; see |
| 170 | +their announcement for additional details about bech32 receiving support. |
| 171 | +The Gemini exchange also [apparently][gemini reddit] added bech32 |
| 172 | +sending support this week, and users report that Gemini will accept |
| 173 | +deposits to bech32 addresses as well. |
| 174 | + |
| 175 | +## Notable code and documentation changes |
| 176 | + |
| 177 | +*Notable changes this week in [Bitcoin Core][bitcoin core repo], |
| 178 | +[LND][lnd repo], [C-Lightning][c-lightning repo], [Eclair][eclair repo], |
| 179 | +[libsecp256k1][libsecp256k1 repo], and [Bitcoin Improvement Proposals |
| 180 | +(BIPs)][bips repo]. Note: all merges described for Bitcoin Core are to |
| 181 | +its master development branch; some may also be backported to the |
| 182 | +0.18 branch for the pending 0.18.0 release.* |
| 183 | + |
| 184 | +- [Bitcoin Core #15620][] stops the `maxtxfee` configuration |
| 185 | + parameter from affecting the `sendrawtransaction` and |
| 186 | + `testmempoolaccept` RPCs. Previously those RPCs would default to |
| 187 | + rejecting a transaction paying a fee higher than the configured max. |
| 188 | + Now a hardcoded default of 0.1 BTC is used as the acceptable ceiling. |
| 189 | + The `maxtxfee` configuration parameter is still used by Bitcoin Core's |
| 190 | + built-in wallet; it has just been separated from node-specific RPCs. |
| 191 | + This change is part of a general [cleanup of wallet configuration |
| 192 | + options][Bitcoin Core #13044] as well as part of separating the node |
| 193 | + and wallet (which both used this setting before this change). |
| 194 | + |
| 195 | +- [Bitcoin Core #15643][] changes the Python script Bitcoin Core |
| 196 | + developers use to merge commits so that the git merge message includes |
| 197 | + a list of which developers approved (ACKed) the version of a PR that |
| 198 | + was merged. (This internal project change is perhaps not notable by |
| 199 | + itself, but one of the tool's other features---copying the full PR |
| 200 | + description into the merge message---makes it much easier for the |
| 201 | + author of this section to write these merge summaries, so he |
| 202 | + encourages other Bitcoin projects to investigate the advantages of |
| 203 | + using this tool for automatically creating better git-based |
| 204 | + documentation, as well as improving their security and auditability.) |
| 205 | + |
| 206 | +- [Bitcoin Core #15519][] adds a [Poly1305][] implementation to Bitcoin |
| 207 | + Core but does not use it. This is expected to be used later for an |
| 208 | + implementation of [P2P protocol encryption][]. |
| 209 | + |
| 210 | +- [Bitcoin Core #15637][] modifies the mempool-related RPCs (such as |
| 211 | + `getrawmempool`) to rename the `size` field to `vsize`. The previous |
| 212 | + value was also the vsize, so the calculation has not changed. This |
| 213 | + merged PR simply makes it clear that this is a vsize and not a |
| 214 | + stripped size. For backwards compatibility, you can start Bitcoin |
| 215 | + Core with the `deprecatedrpc=size` parameter to continue using the old |
| 216 | + field name, although this will be removed in a future release. |
| 217 | + |
| 218 | +- [LND #2759][] lowers the default [CLTV delta][bolt2 delta] from 144 |
| 219 | + blocks (about 24.0 hours) to 40 blocks (about 6.7 hours). When Alice |
| 220 | + wants to pay Zed through a series of routing nodes, she starts by |
| 221 | + giving money to Bob under the terms that either Alice can take it back |
| 222 | + after (say) 400 blocks or Bob can claim the money before then if he |
| 223 | + can provide the preimage for a particular hash (the key that opens a |
| 224 | + hashlock). The 400 block delay is enforced onchain if necessary |
| 225 | + using `OP_CHECKLOCKTIMEVERIFY` (CLTV). Bob then sends the money |
| 226 | + (minus his routing fee) to Charlie with similar terms except that he |
| 227 | + subtracts the value of Charlie's CLTV delta from Alice's original 400 |
| 228 | + blocks, reducing the value to 360 blocks and ensuring that nobody else |
| 229 | + can cheat Charlie out of having at least 40 blocks to claim his money |
| 230 | + onchain if Bob becomes uncooperative despite the payment succeeding. |
| 231 | + Subsequent routers each successively subtract their delta from the |
| 232 | + value of the terms they give until the final receiver (Zed) might only |
| 233 | + have a few blocks in which to either claim the payment or lose his |
| 234 | + chance to receive the money (causing the whole series of uncompleted |
| 235 | + payments to unwind). According to the git commit messages, this |
| 236 | + change is being made because "the initial value was purposefully very |
| 237 | + high. [...] Such a high value discourages path finding algorithms |
| 238 | + from taking LND paths due to the negative impact of CLTV value in |
| 239 | + widely deployed heuristics." |
| 240 | + |
| 241 | +- [Eclair #894][] replaces the JSON-RPC interface with an HTTP |
| 242 | + POST interface. Instead of RPC commands, HTTP endpoints are used |
| 243 | + (e.g. the `channelstats` RPC is now `POST |
| 244 | + http://localhost:8080/channelstats`). Parameters are provided to the |
| 245 | + endpoint using named form parameters with the same JSON syntax as |
| 246 | + used with RPC parameters. Returned results are identical to before |
| 247 | + the change. The old interface is still available using the |
| 248 | + configuration parameter `eclair.api.use-old-api=true`, but it is |
| 249 | + expected to be removed in a subsequent release. See the [updated API |
| 250 | + documentation][eclair api docs] for details. |
| 251 | + |
| 252 | +{% include references.md %} |
| 253 | +{% include linkers/issues.md issues="15555,15560,15620,15643,15519,15637,2759,894,13044" %} |
| 254 | +[0.18.0]: https://bitcoincore.org/bin/bitcoin-core-0.18.0/ |
| 255 | +[bech32 easy]: {{news38}}#bech32-sending-support |
| 256 | +[poly1305]: https://en.wikipedia.org/wiki/Poly1305 |
| 257 | +[0.16.0 segwit]: https://bitcoincore.org/en/releases/0.16.0/#segwit-wallet |
| 258 | +[eclair api docs]: https://acinq.github.io/eclair/#introduction |
| 259 | +[johoe's mempool statistics]: https://jochen-hoenicke.de/queue/#0,1w |
| 260 | +[p2sh.info's fee estimate tracker]: https://p2sh.info/dashboard/db/fee-estimation?orgId=1 |
| 261 | +[trampoline thread]: https://lists.linuxfoundation.org/pipermail/lightning-dev/2019-March/001939.html |
| 262 | +[core meeting segwit]: http://www.erisian.com.au/meetbot/bitcoin-core-dev/2019/bitcoin-core-dev.2019-03-28-19.01.log.html#l-83 |
| 263 | +[bech32 adoption]: https://en.bitcoin.it/wiki/Bech32_adoption |
| 264 | +[bech32 reference libraries]: https://github.com/sipa/bech32/tree/master/ref |
| 265 | +[segwit addr to bytes]: https://github.com/sipa/bech32/blob/master/ref/python/tests.py#L30 |
| 266 | +[bitgo segwit]: https://blog.bitgo.com/native-segwit-addresses-via-bitgos-api-4946f2007be9 |
| 267 | +[gemini reddit]: https://old.reddit.com/r/Bitcoin/comments/b66n0v/psa_gemini_is_full_on_with_native_segwit_and_uses/ |
| 268 | +[bolt2 delta]: https://github.com/lightningnetwork/lightning-rfc/blob/master/02-peer-protocol.md#cltv_expiry_delta-selection |
| 269 | +[p2p protocol encryption]: https://gist.github.com/jonasschnelli/c530ea8421b8d0e80c51486325587c52 |
0 commit comments