Skip to content

Commit f635565

Browse files
authored
Merge pull request #127 from harding/2019-04-02-newsletter
Newsletters: add #40 (2019-04-02)
2 parents e0283b1 + 401b317 commit f635565

File tree

1 file changed

+269
-0
lines changed

1 file changed

+269
-0
lines changed
Lines changed: 269 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,269 @@
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 save money.
33+
For example, as of this writing, Bitcoin Core's fee estimator suggests
34+
a fee of 0.00059060 BTC per 1,000 vbytes confirmation within 2 blocks
35+
but only 0.00002120 for confirmation within 50 blocks---saving over 95% 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
50+
rather than just one (each one receiving its 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+
sending to 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. P2SH-wrapped segwit addresses 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. 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][bip173 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. If that happens, 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 the actual size of the
158+
scriptPubKey in your fee estimation code.
159+
160+
Your code doesn't need to be written in Python. Reference libraries
161+
are also provided for C, C++, Go, Haskell, JavaScript, Ruby, and Rust.
162+
Further, [BIP173][] describes bech32 well enough that any decent
163+
programmer should be able to implement it from scratch in their preferred
164+
language without requiring anything beyond what most programming
165+
languages provide in their builtins and standard library.
166+
167+
**Other bech32 sending support updates:** BitGo [announced][bitgo
168+
segwit] that their API now supports sending to bech32 addresses; see
169+
their announcement for additional details about bech32 receiving support.
170+
The Gemini exchange also [apparently][gemini reddit] added bech32
171+
sending support this week, and users report that Gemini defaults to accepting
172+
deposits to bech32 addresses as well.
173+
174+
## Notable code and documentation changes
175+
176+
*Notable changes this week in [Bitcoin Core][bitcoin core repo],
177+
[LND][lnd repo], [C-Lightning][c-lightning repo], [Eclair][eclair repo],
178+
[libsecp256k1][libsecp256k1 repo], and [Bitcoin Improvement Proposals
179+
(BIPs)][bips repo]. Note: all merges described for Bitcoin Core are to
180+
its master development branch; some may also be backported to the
181+
0.18 branch for the pending 0.18.0 release.*
182+
183+
- [Bitcoin Core #15620][] stops the `maxtxfee` configuration
184+
parameter from affecting the `sendrawtransaction` and
185+
`testmempoolaccept` RPCs. Previously those RPCs would default to
186+
rejecting a transaction paying a fee higher than the configured max.
187+
Now a hardcoded default of 0.1 BTC is used as the acceptable ceiling.
188+
The `maxtxfee` configuration parameter is still used by Bitcoin Core's
189+
built-in wallet; it has just been separated from node-specific RPCs.
190+
This change is part of a general [cleanup of wallet configuration
191+
options][Bitcoin Core #13044] as well as part of separating the node
192+
and wallet (which both used this setting before this change).
193+
194+
- [Bitcoin Core #15643][] changes the Python script Bitcoin Core
195+
developers use to merge commits so that the git merge message includes
196+
a list of which developers approved (ACKed) the version of a PR that
197+
was merged. (This internal project change is perhaps not notable by
198+
itself, but one of the tool's other features---copying the full PR
199+
description into the merge message---makes it much easier for the
200+
author of this section to write these merge summaries, so he
201+
encourages other Bitcoin projects to investigate the advantages of
202+
using this tool for automatically creating better git-based
203+
documentation, as well as improving their security and auditability.)
204+
205+
- [Bitcoin Core #15519][] adds a [Poly1305][] implementation to Bitcoin
206+
Core but does not use it. This is expected to be used later for an
207+
implementation of [P2P protocol encryption][].
208+
209+
- [Bitcoin Core #15637][] modifies the mempool-related RPCs (such as
210+
`getrawmempool`) to rename the `size` field to `vsize`. The previous
211+
value was also the vsize, so the calculation has not changed. This
212+
merged PR simply makes it clear that this is a vsize and not a
213+
stripped size. For backwards compatibility, you can start Bitcoin
214+
Core with the `deprecatedrpc=size` parameter to continue using the old
215+
field name, although this will be removed in a future release.
216+
217+
- [LND #2759][] lowers the default [CLTV delta][bolt2 delta] for all channels from 144
218+
blocks (about 24.0 hours) to 40 blocks (about 6.7 hours). When Alice
219+
wants to pay Zed through a series of routing nodes, she starts by
220+
giving money to Bob under the terms that either Alice can take it back
221+
after (say) 400 blocks or Bob can claim the money before then if he
222+
can provide the preimage for a particular hash (the key that opens a
223+
hashlock). The 400 block delay is enforced onchain if necessary
224+
using `OP_CHECKLOCKTIMEVERIFY` (CLTV). Bob then sends the money
225+
(minus his routing fee) to Charlie with similar terms except that the
226+
CLTV value is reduced from Alice's original 400 blocks by the CLTV delta of his channel with Charlie,
227+
reducing the value to 360 blocks. This ensures that if Charlie
228+
waits the maximum time to fulfil his HTLC to Bob and claim his payment
229+
(360 blocks), Bob still has 40 blocks to claim _his_ payment from Alice by
230+
fulfilling the original HTLC. If Bob's HTLC expiry time with Charlie wasn't reduced at all and
231+
used a 400 block delay, Bob would be at risk of losing money. Charlie could
232+
delay fulfilling his HTLC until 400 blocks, and Alice could then cancel her
233+
HTLC with Bob before Bob had time to fulfil the HTLC.
234+
235+
Subsequent routers each successively subtract their delta from the value of
236+
the terms they give to the next node in the route. Using a high CLTV delta
237+
therefore reduces the possible number of hops that can be used in a route, and
238+
makes a channel less attractive for use when routing payments.
239+
240+
- [Eclair #894][] replaces the JSON-RPC interface with an HTTP
241+
POST interface. Instead of RPC commands, HTTP endpoints are used
242+
(e.g. the `channelstats` RPC is now `POST
243+
http://localhost:8080/channelstats`). Parameters are provided to the
244+
endpoint using named form parameters with the same JSON syntax as
245+
used with RPC parameters. Returned results are identical to before
246+
the change. The old interface is still available using the
247+
configuration parameter `eclair.api.use-old-api=true`, but it is
248+
expected to be removed in a subsequent release. See the [updated API
249+
documentation][eclair api docs] for details.
250+
251+
{% include references.md %}
252+
{% include linkers/issues.md issues="15555,15560,15620,15643,15519,15637,2759,894,13044" %}
253+
[0.18.0]: https://bitcoincore.org/bin/bitcoin-core-0.18.0/
254+
[bech32 easy]: {{news38}}#bech32-sending-support
255+
[poly1305]: https://en.wikipedia.org/wiki/Poly1305
256+
[0.16.0 segwit]: https://bitcoincore.org/en/releases/0.16.0/#segwit-wallet
257+
[eclair api docs]: https://acinq.github.io/eclair/#introduction
258+
[johoe's mempool statistics]: https://jochen-hoenicke.de/queue/#0,1w
259+
[p2sh.info's fee estimate tracker]: https://p2sh.info/dashboard/db/fee-estimation?orgId=1
260+
[trampoline thread]: https://lists.linuxfoundation.org/pipermail/lightning-dev/2019-March/001939.html
261+
[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
262+
[bech32 adoption]: https://en.bitcoin.it/wiki/Bech32_adoption
263+
[bech32 reference libraries]: https://github.com/sipa/bech32/tree/master/ref
264+
[segwit addr to bytes]: https://github.com/sipa/bech32/blob/master/ref/python/tests.py#L30
265+
[bitgo segwit]: https://blog.bitgo.com/native-segwit-addresses-via-bitgos-api-4946f2007be9
266+
[gemini reddit]: https://www.reddit.com/r/Bitcoin/comments/b66n0v/psa_gemini_is_full_on_with_native_segwit_and_uses/
267+
[bolt2 delta]: https://github.com/lightningnetwork/lightning-rfc/blob/master/02-peer-protocol.md#cltv_expiry_delta-selection
268+
[p2p protocol encryption]: https://gist.github.com/jonasschnelli/c530ea8421b8d0e80c51486325587c52
269+
[bip173 test vectors]: https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki#Test_vectors

0 commit comments

Comments
 (0)