Browse Source

doc: correct weight numbers for fundpsbt

pyln
niftynei 4 years ago
committed by Rusty Russell
parent
commit
53ba34fe3a
  1. 12
      doc/lightning-fundpsbt.7
  2. 10
      doc/lightning-fundpsbt.7.md
  3. 2
      tests/plugins/df_accepter.py

12
doc/lightning-fundpsbt.7

@ -50,10 +50,10 @@ Let's assume the caller is trying to produce a 100,000 satoshi output\.
First, the caller estimates the weight of the core (typically 42) and
known outputs of the transaction (typically (9 + scriptlen) * 4)\. For
a simple P2WPKH it's a 22 byte scriptpubkey, so that's 164 weight\.
a simple P2WPKH it's a 22 byte scriptpubkey, so that's 124 weight\.
It calls "\fIfundpsbt\fR 100000sat slow 206", which succeeds, and returns
It calls "\fIfundpsbt\fR 100000sat slow 166", which succeeds, and returns
the \fIpsbt\fR and \fIfeerate_per_kw\fR it used, the \fIestimated_final_weight\fR
and any \fIexcess_msat\fR\.
@ -61,9 +61,9 @@ and any \fIexcess_msat\fR\.
If \fIexcess_msat\fR is greater than the cost of adding a change output,
the caller adds a change output randomly to position 0 or 1 in the
PSBT\. Say \fIfeerate_per_kw\fR is 253, and the change output is a P2WPKH
(weight 164), that would cost the cost is around 41 sats\. With the
dust limit disallowing payments below 546 satoshis, we would only create
a change output if \fIexcess_msat\fR was greater or equal to 41 + 546\.
(weight 124), the cost is around 31 sats\. With the dust limit disallowing
payments below 546 satoshis, we would only create a change output
if \fIexcess_msat\fR was greater or equal to 31 + 546\.
.SH RETURN VALUE
@ -104,4 +104,4 @@ Rusty Russell \fI<rusty@rustcorp.com.au\fR> is mainly responsible\.
Main web site: \fIhttps://github.com/ElementsProject/lightning\fR
\" SHA256STAMP:0a80505110887fe165580fd6420d681b7cdcdae89d5c45d863510f1405d70040
\" SHA256STAMP:8eb6970e2d625198db9b8e5ab7f90f9fb141744a837f58ee68ef54d28c7066b0

10
doc/lightning-fundpsbt.7.md

@ -46,18 +46,18 @@ Let's assume the caller is trying to produce a 100,000 satoshi output.
First, the caller estimates the weight of the core (typically 42) and
known outputs of the transaction (typically (9 + scriptlen) * 4). For
a simple P2WPKH it's a 22 byte scriptpubkey, so that's 164 weight.
a simple P2WPKH it's a 22 byte scriptpubkey, so that's 124 weight.
It calls "*fundpsbt* 100000sat slow 206", which succeeds, and returns
It calls "*fundpsbt* 100000sat slow 166", which succeeds, and returns
the *psbt* and *feerate_per_kw* it used, the *estimated_final_weight*
and any *excess_msat*.
If *excess_msat* is greater than the cost of adding a change output,
the caller adds a change output randomly to position 0 or 1 in the
PSBT. Say *feerate_per_kw* is 253, and the change output is a P2WPKH
(weight 164), that would cost the cost is around 41 sats. With the
dust limit disallowing payments below 546 satoshis, we would only create
a change output if *excess_msat* was greater or equal to 41 + 546.
(weight 124), the cost is around 31 sats. With the dust limit disallowing
payments below 546 satoshis, we would only create a change output
if *excess_msat* was greater or equal to 31 + 546.
RETURN VALUE
------------

2
tests/plugins/df_accepter.py

@ -56,7 +56,7 @@ def on_openchannel(openchannel2, plugin, **kwargs):
psbt_obj = psbt_from_base64(funding['psbt'])
excess = Millisatoshi(funding['excess_msat'])
change_cost = Millisatoshi(164 * feerate // 1000 * 1000)
change_cost = Millisatoshi(124 * feerate // 1000 * 1000)
dust_limit = Millisatoshi(253 * 1000)
if excess > (dust_limit + change_cost):
addr = plugin.rpc.newaddr()['bech32']

Loading…
Cancel
Save