Skip to content

Commit 0484317

Browse files
committed
fixup: updates based on feedback
1 parent 6751029 commit 0484317

File tree

3 files changed

+92
-57
lines changed

3 files changed

+92
-57
lines changed

02-peer-protocol.md

Lines changed: 78 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -978,16 +978,16 @@ acceptance of the new channel.
978978
* [`shutdown_len*byte`:`shutdown_scriptpubkey`]
979979
1. type: 2 (`will_fund`)
980980
2. data:
981-
* [`lease_rates`:`lease_rates`]
982981
* [`signature`:`signature`]
982+
* [`lease_rates`:`lease_rates`]
983983

984984
1. subtype: `lease_rates`
985985
2. data:
986-
* [`u16`:`funding_fee_proportional_basis`]
987-
* [`u32`:`funding_fee_base_sat`]
988-
* [`u16`:`funding_weight_max`]
989-
* [`u16`:`channel_fee_proportional_basis_max`]
990-
* [`tu32`:`channel_fee_base_max_msat`]
986+
* [`u16`:`funding_weight`]
987+
* [`u16`:`lease_fee_basis`]
988+
* [`u16`:`channel_fee_max_proportional_thousandths`]
989+
* [`u32`:`lease_fee_base_sat`]
990+
* [`tu32`:`channel_fee_max_base_msat`]
991991

992992
Rationale and Requirements are the same as listed above,
993993
for [`accept_channel`](#the-accept_channel-message) with the following
@@ -1004,33 +1004,36 @@ The accepting node:
10041004
- if they decide to accept the offer:
10051005
- MUST include a `will_fund` tlv
10061006
- MUST set `funding_satoshis` to a value greater than 0msat
1007-
- MAY provide a `funding_satoshis` of any amount.
1008-
- MUST set `funding_fee_base_sat` to the base fee
1007+
- MAY send `funding_satoshis` less than `requested_sats`
1008+
- MUST set `lease_fee_base_sat` to the base fee
10091009
(in satoshi) it will charge for the `funding_satoshis`
1010-
- MUST set `funding_fee_proportional_basis` to the amount
1010+
- MUST set `lease_fee_basis` to the amount
10111011
(in thousandths of satoshi) it will charge per `funding_satoshi`
1012-
- MUST set `funding_weight` to the weight they
1013-
will contribute to this channel, to fund the request.
1014-
- MUST set `channel_fee_base_max_msat` to the base fee
1012+
- MUST set `funding_weight` to the weight they will charge
1013+
the peer for.
1014+
- MUST set `channel_fee_max_base_msat` to the base fee
10151015
(in millisatoshi) it will charge for any HTLC on this channel
10161016
during the funding period.
1017-
- MUST set `channel_fee_proportional_basis_max` to the amount
1017+
- MUST set `channel_fee_max_proportional_thousandths` to the amount
10181018
(in thousandths of a satoshi) it will charge per transferred
10191019
satoshi during the funding period.
10201020
- MUST set `signature` to the ECDSA signature of
1021-
SHA256("option_will_fund" || `funding_pubkey`|| `blockheight` ||
1022-
`channel_fee_base_max_msat` || `channel_fee_proportional_basis_max`)
1021+
SHA256("option_will_fund" || `funding_pubkey`|| `blockheight` + 4032 ||
1022+
`channel_fee_max_base_msat` || `channel_fee_max_proportional_thousandths`)
10231023
using the node_id key.
10241024

10251025
The receiving node:
10261026
- SHOULD fail the negotiation if:
10271027
- they sent `request_funds` tlv and:
10281028
- the `funding_satoshi` is less than required
1029-
- the `funding_fee_proportional_basis` is too high
1030-
- the `funding_fee_base_sat` is too high
1029+
- the `lease_fee_basis` is too high
1030+
- the `lease_fee_base_sat` is too high
10311031
- the `funding_weight` is too high
1032-
- the `channel_fee_proportional_basis_max` is too high
1033-
- the `channel_fee_base_max_msat` is too high
1032+
- the `channel_fee_max_proportional_thousandths` is too high
1033+
- the `channel_fee_max_base_msat` is too high
1034+
- the `signature` is invalid
1035+
- SHOULD accept the negotiation if:
1036+
- the `funding_satoshi` is excess of `requested_sats`
10341037
- MUST fail the negotiation if they receive a `will_fund` tlv and:
10351038
- they DID NOT send a `request_funds` tlv
10361039

@@ -1064,26 +1067,29 @@ total lease fee at a rate of `funding_weight` times the
10641067
`funding_feerate_perkw` established in `open_channel2`.
10651068

10661069
The total lease fee is added to the accepter node's output in the
1067-
commitment transaction. It is equal to the `funding_fee_base_sat` +
1068-
`accept_channel2`.`funding_satoshis` * `funding_fee_proportional_basis`
1069-
+ `funding_feerate_perkw` * `funding_weight` / 1000, rounded
1070-
down to the nearest satoshi. See [Appendix A: The lease fee](#appendix-a-the-lease-fee).
1071-
1072-
`signature` signs the accepter node's `funding_pubkey`, the opener's
1073-
`locktime`, and the returned `channel_fee` parameters. This provides the opener
1070+
commitment transaction. It is equal to the `lease_fee_base_sat` +
1071+
min(`accept_channel2`.`funding_satoshis`,`open_channel2`.`requested_sats`)
1072+
* `lease_fee_basis` / 10_000 + `funding_feerate_perkw` *
1073+
`funding_weight` / 1000, rounded down to the nearest satoshi. See [Appendix A: The lease fee](#appendix-a-the-lease-fee).
1074+
1075+
`signature` signs the leasing node's `funding_pubkey`, the
1076+
lease expiration block (opener's `blockheight` + 4032), and the returned
1077+
`channel_fee` parameters. This provides the opener
10741078
with proof in the case the accepter does not maintain the stated
10751079
`channel_fee` rates during the channel's funding lease.
10761080

1077-
If the initiating node sent `request_funds` and the accepting node replied
1078-
with `will_fund` this channel is considered 'leased'. The lease ends
1079-
4032 blocks after the `open_channel2` `blockheight`, i.e.
1080-
`lease_end` is defined as the `open_channel2`.`blockheight` + 4032.
1081+
The lessor is the `accepter`, who contributes funds to the channel for a fee.
1082+
The lessee is the `opener`, who requests for funds and pays the lessor a fee
1083+
for the funds they contribute to the channel. A lease is defined as being for
1084+
4032 blocks; a `lease_end` is defined as the `open_channel2`.`blockheight`
1085+
+ 4032. If the initiating node sent `request_funds` and the
1086+
accepting node replied with `will_fund` this channel is considered 'leased'.
10811087

1082-
During the lease, the initiator should consider limiting
1083-
the rate funds are routed through the channel as this provides the opener
1088+
During the duration of the lease, the lessee may limit
1089+
the rate funds are routed through the channel as this provides the lessor
10841090
the opportunity to move the funds elsewhere (and renders the
1085-
lease fairly useless). A sensible policy here depends on the motivation of the
1086-
opener in acquiring the leased funds.
1091+
lease lock fairly useless). A sensible policy here depends on the
1092+
motivation of the lessee in acquiring the lease.
10871093

10881094
### Funding Composition
10891095
Funding composition for channel establishment v2 makes use of the
@@ -1986,25 +1992,33 @@ The node _responsible_ for initiating the channel:
19861992

19871993
The node _not responsible_ for initiating the channel:
19881994
- MUST NOT send `update_blockheight`.
1995+
- if last received `blockheight` is > 1008:
1996+
- SHOULD fail he channel
19891997

19901998
A receiving node:
19911999
- if the `update_blockheight` is less than the last received `blockheight`:
19922000
- SHOULD fail the channel.
19932001
- if the sender is not the initiator:
19942002
- MUST fail the channel.
1995-
- if `blockheight` is more than 504 blocks behind the current blockheight:
2003+
- if `blockheight` is more than 1008 blocks behind the current blockheight:
19962004
- SHOULD fail the channel
19972005
- MUST apply the provided blockheight to their commitment transaction
19982006

19992007
#### Rationale
20002008
An up-to-date `blockheight` is required to ensure that the funding
2001-
lease expires 4032 blocks after the channel is established. (??)
2009+
lease expires 4032 blocks after the channel is established.
20022010

20032011
The opener updates the blockheight, as they are motivated to keep
20042012
the channel open. They do this by continuing to decrement the lock on
20052013
the commitment output for their peer as the funding lease expiration
20062014
approaches.
20072015

2016+
The lessor's lease is only shortened when a new `blockheight` is committed,
2017+
otherwise it's always 4032 blocks in the future. If the peer doesn't
2018+
update the blockheight, at some point it has to start the closing process
2019+
to retrieve its funds. 1008 blocks seems a reasonable (but not compulsory!)
2020+
answer here.
2021+
20082022
## Message Retransmission
20092023

20102024
Because communication transports are unreliable, and may need to be
@@ -2247,38 +2261,49 @@ the lease fee, and their tx weight * `funding_feerate_perkw` / 1000.
22472261

22482262
The lease fee is calculated as:
22492263

2250-
`funding_fee_base_sat` +
2251-
`accept_channel2`.`funding_satoshis` * `funding_fee_proportional_basis` / 1000 +
2264+
`lease_fee_base_sat` +
2265+
min(`accept_channel2`.`funding_satoshis`, `open_channel2`.`requested_sats`) * `lease_fee_basis` / 10_000 +
22522266
`funding_weight` * `funding_feerate_perkw` / 1000
22532267

22542268
E.g.
2255-
An node requests 100.0000sats at a feerate of 2500perkw. They
2256-
are contributing 50.0000sats. Their weight contribution to the
2269+
An node requests 1_000_000sats at a feerate of 2500perkw. They
2270+
are contributing 500_000sats. Their weight contribution to the
22572271
funding transaction will be 720.
22582272

2259-
The accepter charges a base funding fee of 233sats with a
2260-
proportional basis of 22. Their weight charge is 444. The lease fee is as
2261-
follows:
2273+
The accepter adds 1,100,000sats and charges a base funding fee of
2274+
233sats with a lease fee basis of 22. Their funding weight is 444.
2275+
The lease fee is as follows:
22622276

2263-
233 + 100.0000 * 22 / 1000 + 444 * 2500 / 1000
2277+
233 + min(1_000_000,1_100_000) * 22 / 10_000 + 444 * 2500 / 1000
22642278

2265-
The total lease fee for this open is 3.3333sats.
2279+
The total lease fee for this open is 3543sats.
22662280

22672281
The outputs to the peers in the commitment transaction will be
22682282

2269-
to-initiator: 50.0000sats
2270-
to-accepter: 103.3333sats
2283+
to-opener: 500_000sats
2284+
to-accepter: 1_103_543sats
2285+
2286+
The miner fee for the opener will be 720 * 2500 / 1000 or 1800sats.
22712287

2272-
The miner fee for the initiator will be 720 * 2500 / 1000 or 1800sats.
2288+
Minimum funds that the opener must contribute to the channel open
2289+
transaction:
2290+
2291+
open_channel2.funding_satoshis: 500_000sats
2292+
lease fee: 3_543sats
2293+
miner fee: 1_800sats
2294+
2295+
total required contribution: 505_343sats
22732296

2274-
Minimum funds that the initiator must contribute to the channel open
2297+
Minimum funds that the accepter must contribute to the channel open
22752298
transaction:
22762299

2277-
open_channel2.funding_satoshis: 50.0000sats
2278-
lease fee: 3.3333sats
2279-
miner fee: 1800sats
2300+
accept_channel2.funding_satoshis: 1_100_000sats
2301+
miner fee[1]: 1_110sats
2302+
2303+
total required contribution: 1_101_110sats
2304+
22802305

2281-
total required contribution: 53.5133sats
2306+
[1] assumes `444` is their total weight for this transaction.
22822307

22832308

22842309
# Authors

03-transactions.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@ If a revoked commitment transaction is published, the other party can spend this
121121
<revocation_sig> 1
122122

123123
##### Leased channel (`option_will_fund`)
124+
125+
If a `lease` applies to the channel, the `to_local` output of the `accepter`
126+
ensures the `leasor` funds are not spendable until the lease expires.
127+
124128
In a leased channel, the `to_local` output that pays the `accepter` node
125129
is modified so that its CSV is equal to the greater of the
126130
`to_self_delay` or the `lease_end` - `blockheight`.
@@ -156,9 +160,8 @@ Otherwise, this output is a simple P2WPKH to `remotepubkey`.
156160

157161
##### Leased channel (`option_will_fund`)
158162

159-
In a 'leased' channel, the `to_remote` output that pays the `accepter` node
160-
is modified so that it is equal to the greater of the
161-
1 or the `lease_end` - `blockheight`.
163+
If a `lease` applies to the channel, the `to_remote` output of the `initiator`
164+
ensures the `leasor` funds are not spendable until the lease expires.
162165

163166
<remote_pubkey> OP_CHECKSIGVERIFY MAX(1, lease_end - blockheight) OP_CHECKSEQUENCEVERIFY
164167

07-routing-gossip.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ optional padding within `addresses`, if they require certain alignment.
382382

383383
If a node signals `option_will_fund`, they are signaling that they
384384
will provide funding to a node at the stated terms. They also commit
385-
to a feerate they will charge for transmitting funds over the channel
385+
to a maximum feerate they will charge for transmitting funds over the channel
386386
for the duration of the funding lease.
387387

388388

@@ -512,6 +512,13 @@ The origin node:
512512
- MUST set `fee_proportional_millionths` to the amount (in millionths of a
513513
satoshi) it will charge per transferred satoshi.
514514
- SHOULD NOT create redundant `channel_update`s
515+
- if they are the `leasor` for a currently active lease on this channel
516+
(`option_will_fund`):
517+
- MUST NOT set `fee_base_msat` greater than `channel_fee_max_base_msat`
518+
(as committed to in the `accept_channel2`.`will_fund`.`signature`)
519+
- MUST NOT set `fee_proportional_millionths` greater than
520+
`channel_fee_max_proportional_thousands` * 1000
521+
(as committed to in the `accept_channel2`.`will_fund`.`signature`)
515522

516523
The receiving node:
517524
- if the `short_channel_id` does NOT match a previous `channel_announcement`,

0 commit comments

Comments
 (0)