Skip to content

Commit bff8498

Browse files
committed
Add channel_creation_fee_sat to funding rate
Creating a new channel has an additional cost compared to adding liquidity to an existing channel: the channel will be closed in the future, which will require paying on-chain fees. Node operators can include some `channel_creation_fee_sat` to their liquidity ads to cover some of that future cost.
1 parent 6ce338d commit bff8498

File tree

2 files changed

+37
-17
lines changed

2 files changed

+37
-17
lines changed

07-routing-gossip.md

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,6 +1134,7 @@ are selling.
11341134
* [`u16`:`funding_weight`]
11351135
* [`u16`:`funding_fee_basis`]
11361136
* [`u32`:`funding_fee_base_sat`]
1137+
* [`u32`:`channel_creation_fee_sat`]
11371138

11381139
Sellers also define how the fees can be paid by listing the `payment_type`s
11391140
they support.
@@ -1201,16 +1202,27 @@ When `request_funds` and `will_fund` have been exchanged, the buyer agrees to
12011202
pay fees to the seller for the funding they provide to the channel based on
12021203
the proposed `funding_weight`, `funding_fee_basis` and `funding_fee_base_sat`.
12031204

1205+
If the buyer is opening a new channel, an additional `channel_creation_fee_sat`
1206+
is applied. This can be used to hedge some of the future cost of closing that
1207+
channel, which doesn't apply when additional liquidity is purchased on an
1208+
existing channel (since the creation fee has already been paid).
1209+
12041210
The funding fee has three components:
12051211

1206-
* a fixed amount: `funding_fee_base_sat`
1212+
* a fixed amount:
1213+
* `funding_fee_base_sat` if liquidity is purchased on an existing channel
1214+
* `funding_fee_base_sat + channel_creation_fee_sat` when opening a channel
12071215
* a proportional amount based on the seller's `funding_amount`:
12081216
* `paid_funding_contribution = min(funding_amount, request_funds.requested_sats)`
12091217
* `funding_fee_proportional_sat = paid_funding_contribution * funding_fee_basis / 10_000`
12101218
* a contribution to the on-chain fees paid by the seller:
12111219
* `funding_fee_mining_sat = funding_weight * funding_feerate_perkw / 1000`
12121220

1213-
The total fee is then:
1221+
The total fee for a channel creation is then:
1222+
1223+
funding_fee_total = funding_fee_base_sat + channel_creation_fee_sat + funding_fee_proportional_sat + funding_fee_mining_sat
1224+
1225+
The total fee for buying liquidity on an existing channel is:
12141226

12151227
funding_fee_total = funding_fee_base_sat + funding_fee_proportional_sat + funding_fee_mining_sat
12161228

@@ -1228,6 +1240,8 @@ A node advertising a `funding_rate`:
12281240
- MUST set `min_funding_amount_sat` and `max_funding_amount_sat` to the
12291241
minimum and maximum amount it will contribute at this rate.
12301242
- MUST set `funding_fee_base_sat` to the base fee (in satoshi) it will charge.
1243+
- MUST set `channel_creation_fee_sat` to the additional fee it will charge for
1244+
channel creation.
12311245
- MUST set `funding_fee_basis` to the amount it will charge per contributed
12321246
satoshi (in basis points, ie 1/10_000).
12331247
- MUST set `funding_weight` to the transaction weight that will be charged.
@@ -1254,28 +1268,30 @@ The seller contributes `1_100_000 sats` with the following funding rate:
12541268

12551269
funding_weight = 444
12561270
funding_fee_base_sat = 233 sats
1271+
channel_creation_fee_sat = 500 sats
12571272
funding_fee_basis = 22
12581273

12591274
The funding fee is:
12601275

12611276
funding_fee_base_sat = 233 sats
1277+
channel_creation_fee_sat = 500 sats
12621278
funding_fee_proportional_sat = min(1_000_000, 1_100_000) * 22 / 10_000 = 2200 sats
12631279
funding_fee_mining_sat = 444 * 2500 / 1000 = 1110 sats
1264-
funding_fee_total = 3543 sats
1280+
funding_fee_total = 4043 sats
12651281

12661282
The outputs to the peers in the commitment transaction will be
12671283

12681284
to-buyer: 500_000 sats
1269-
to-seller: 1_103_543 sats
1285+
to-seller: 1_104_043 sats
12701286

12711287
The miner fee for the buyer will be `720 * 2500 / 1000 = 1800 sats`.
12721288

12731289
Minimum funds that the buyer must contribute to the funding transaction:
12741290

12751291
open_channel2.funding_satoshis: 500_000 sats
1276-
funding fee: 3_543 sats
1292+
funding fee: 4_043 sats
12771293
miner fee: 1_800 sats
1278-
total required contribution: 505_343 sats
1294+
total required contribution: 505_843 sats
12791295

12801296
Minimum funds that the seller must contribute to the funding transaction:
12811297

bolt07/liquidity-ads.json

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,17 @@
2020
"funding_weight": 550,
2121
"funding_fee_basis": 100,
2222
"funding_fee_base_sat": 5000,
23-
"encoded": "000186a0 0007a120 0226 0064 00001388"
23+
"channel_creation_fee_sat": 1000,
24+
"encoded": "000186a0 0007a120 0226 0064 00001388 000003e8"
2425
},
2526
{
2627
"min_funding_amount_sat": 500000,
2728
"max_funding_amount_sat": 5000000,
2829
"funding_weight": 1100,
2930
"funding_fee_basis": 75,
3031
"funding_fee_base_sat": 0,
31-
"encoded": "0007a120 004c4b40 044c 004b 00000000"
32+
"channel_creation_fee_sat": 1500,
33+
"encoded": "0007a120 004c4b40 044c 004b 00000000 000005dc"
3234
}
3335
],
3436
"payment_types": {
@@ -39,8 +41,8 @@
3941
}
4042
}
4143
},
42-
"signature": "a822c88c3807659ce1c74866f3346444d0fe6ceb25f86804b245af064f77d0a83b8457732d77386a3b10cf4c80a1811d02f34770eefbef9548ab3a3ce3d629df",
43-
"encoded": "0101 a822c88c3807659ce1c74866f3346444d0fe6ceb25f86804b245af064f77d0a83b8457732d77386a3b10cf4c80a1811d02f34770eefbef9548ab3a3ce3d629df 0000 661cebc9 03ca9b880627d2d4e3b33164f66946349f820d26aa9572fe0e525e534850cbd413 2a7557 4c4e2d4c69717569646974790000000000000000000000000000000000000000 0000 01250002000186a00007a12002260064000013880007a120004c4b40044c004b00000000000101"
44+
"signature": "22ec2e2a6e02f54d949e332cbce571d123ae20dda98d0340ac7e64f60f11d413659a2a9645adea8f886bb5dd40cc589bd3e0f4f8b2ab333d323b74b7762b4ca1",
45+
"encoded": "0101 22ec2e2a6e02f54d949e332cbce571d123ae20dda98d0340ac7e64f60f11d413659a2a9645adea8f886bb5dd40cc589bd3e0f4f8b2ab333d323b74b7762b4ca1 0000 661cebc9 03ca9b880627d2d4e3b33164f66946349f820d26aa9572fe0e525e534850cbd413 2a7557 4c4e2d4c69717569646974790000000000000000000000000000000000000000 0000 012d0002000186a00007a1200226006400001388000003e80007a120004c4b40044c004b00000000000005dc000101"
4446
},
4547
"open_channel2": {
4648
"chainHash": "6fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d6190000000000",
@@ -72,16 +74,17 @@
7274
"max_funding_amount_sat": 5000000,
7375
"funding_weight": 1100,
7476
"funding_fee_basis": 75,
75-
"funding_fee_base_sat": 0
77+
"funding_fee_base_sat": 0,
78+
"channel_creation_fee_sat": 1500
7679
},
7780
"payment_type": {
7881
"type": "from_channel_balance",
7982
"encoded": "0000"
8083
},
81-
"encoded": "03 1a 00000000000b71b0 0007a120004c4b40044c004b00000000 0000"
84+
"encoded": "03 1e 00000000000b71b0 0007a120004c4b40044c004b00000000000005dc 0000"
8285
}
8386
},
84-
"encoded": "0040 6fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d6190000000000 0100000000000000000000000000000000000000000000000000000000000000 00001388 00000fa0 000000000003d090 00000000000001f4 000000000000c350 000000000000000f 0090 01e3 0009eb10 031b84c5567b126440995d3ed5aaba0565d71e1834604819ff9c17f5e9d5dd078f 024d4b6cd1361032ca9bd2aeb9d900aa4d45d9ead80ac9423374c451a7254d0766 02531fe6068134503d2723133227c867ac8fa6c83c537e9a44c3c5bdbdcb1fe337 03462779ad4aad39514614751a71085f2f10e1c7a593e4e030efb5b8721ce55b0b 0362c0a046dacce86ddd0343c6d3c7c79c2208ba0d9c9cf24a6d046d21d21f90f7 03f006a18d5653c4edf5391ff23a61f03ff83d237e880ee61187fa9f379a028e0a 02989c0b76cb563971fdc9bef31ec06c3560f3249d6ee9e5d83c57625596e05f6f 01 031a00000000000b71b00007a120004c4b40044c004b000000000000"
87+
"encoded": "0040 6fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d6190000000000 0100000000000000000000000000000000000000000000000000000000000000 00001388 00000fa0 000000000003d090 00000000000001f4 000000000000c350 000000000000000f 0090 01e3 0009eb10 031b84c5567b126440995d3ed5aaba0565d71e1834604819ff9c17f5e9d5dd078f 024d4b6cd1361032ca9bd2aeb9d900aa4d45d9ead80ac9423374c451a7254d0766 02531fe6068134503d2723133227c867ac8fa6c83c537e9a44c3c5bdbdcb1fe337 03462779ad4aad39514614751a71085f2f10e1c7a593e4e030efb5b8721ce55b0b 0362c0a046dacce86ddd0343c6d3c7c79c2208ba0d9c9cf24a6d046d21d21f90f7 03f006a18d5653c4edf5391ff23a61f03ff83d237e880ee61187fa9f379a028e0a 02989c0b76cb563971fdc9bef31ec06c3560f3249d6ee9e5d83c57625596e05f6f 01 031e00000000000b71b00007a120004c4b40044c004b00000000000005dc0000"
8588
},
8689
"accept_channel2": {
8790
"temporaryChannelId": "0100000000000000000000000000000000000000000000000000000000000000",
@@ -106,13 +109,14 @@
106109
"max_funding_amount_sat": 5000000,
107110
"funding_weight": 1100,
108111
"funding_fee_basis": 75,
109-
"funding_fee_base_sat": 0
112+
"funding_fee_base_sat": 0,
113+
"channel_creation_fee_sat": 1500
110114
},
111115
"funding_script": "00202ec38203f4cf37a3b377d9a55c7ae0153c643046dbdbe2ffccfb11b74420103c",
112-
"signature": "35962783e077e3c5214ba829752be2a3994a7c5e0e9d735ef5a9dab3ce1d6dda6282c3252b20af52e58c33c0e164167fd59e19114a8a8f9eb76b33008205dcb6",
113-
"encoded": "03 74 0007a120004c4b40044c004b00000000 002200202ec38203f4cf37a3b377d9a55c7ae0153c643046dbdbe2ffccfb11b74420103c 35962783e077e3c5214ba829752be2a3994a7c5e0e9d735ef5a9dab3ce1d6dda6282c3252b20af52e58c33c0e164167fd59e19114a8a8f9eb76b33008205dcb6"
116+
"signature": "c57cf393f6bd534472ec08cbfbbc7268501b32f563a21cdf02a99127c4f25168249acd6509f96b2e93843c3b838ee4808c75d0a15ff71ba886fda980b8ca954f",
117+
"encoded": "03 78 0007a120004c4b40044c004b00000000000005dc 002200202ec38203f4cf37a3b377d9a55c7ae0153c643046dbdbe2ffccfb11b74420103c c57cf393f6bd534472ec08cbfbbc7268501b32f563a21cdf02a99127c4f25168249acd6509f96b2e93843c3b838ee4808c75d0a15ff71ba886fda980b8ca954f"
114118
}
115119
},
116-
"encoded": "0041 0100000000000000000000000000000000000000000000000000000000000000 00000000000aae60 00000000000001d9 0000000005f5e100 0000000000000001 00000006 0090 0032 031b84c5567b126440995d3ed5aaba0565d71e1834604819ff9c17f5e9d5dd078f 024d4b6cd1361032ca9bd2aeb9d900aa4d45d9ead80ac9423374c451a7254d0766 02531fe6068134503d2723133227c867ac8fa6c83c537e9a44c3c5bdbdcb1fe337 03462779ad4aad39514614751a71085f2f10e1c7a593e4e030efb5b8721ce55b0b 0362c0a046dacce86ddd0343c6d3c7c79c2208ba0d9c9cf24a6d046d21d21f90f7 03f006a18d5653c4edf5391ff23a61f03ff83d237e880ee61187fa9f379a028e0a 02989c0b76cb563971fdc9bef31ec06c3560f3249d6ee9e5d83c57625596e05f6f 03740007a120004c4b40044c004b00000000002200202ec38203f4cf37a3b377d9a55c7ae0153c643046dbdbe2ffccfb11b74420103c35962783e077e3c5214ba829752be2a3994a7c5e0e9d735ef5a9dab3ce1d6dda6282c3252b20af52e58c33c0e164167fd59e19114a8a8f9eb76b33008205dcb6"
120+
"encoded": "0041 0100000000000000000000000000000000000000000000000000000000000000 00000000000aae60 00000000000001d9 0000000005f5e100 0000000000000001 00000006 0090 0032 031b84c5567b126440995d3ed5aaba0565d71e1834604819ff9c17f5e9d5dd078f 024d4b6cd1361032ca9bd2aeb9d900aa4d45d9ead80ac9423374c451a7254d0766 02531fe6068134503d2723133227c867ac8fa6c83c537e9a44c3c5bdbdcb1fe337 03462779ad4aad39514614751a71085f2f10e1c7a593e4e030efb5b8721ce55b0b 0362c0a046dacce86ddd0343c6d3c7c79c2208ba0d9c9cf24a6d046d21d21f90f7 03f006a18d5653c4edf5391ff23a61f03ff83d237e880ee61187fa9f379a028e0a 02989c0b76cb563971fdc9bef31ec06c3560f3249d6ee9e5d83c57625596e05f6f 03780007a120004c4b40044c004b00000000000005dc002200202ec38203f4cf37a3b377d9a55c7ae0153c643046dbdbe2ffccfb11b74420103cc57cf393f6bd534472ec08cbfbbc7268501b32f563a21cdf02a99127c4f25168249acd6509f96b2e93843c3b838ee4808c75d0a15ff71ba886fda980b8ca954f"
117121
}
118122
}

0 commit comments

Comments
 (0)