@@ -277,7 +277,7 @@ nodes not associated with an already known channel are ignored.
2772772 . types:
278278 1 . type: 1 (` option_will_fund ` )
279279 2 . data:
280- * [ ` will_fund_lease_rates ` :` will_fund_lease_rates ` ]
280+ * [ ` will_fund_rates ` :` will_fund_rates ` ]
281281
282282` timestamp ` allows for the ordering of messages, in the case of multiple
283283announcements. ` rgb_color ` and ` alias ` allow intelligence services to assign
@@ -1156,62 +1156,89 @@ above.
11561156
11571157Liquidity ads allow nodes to announce their willingness to provide funding to
11581158other nodes for a fee. Sellers advertise various rates for the liquidity they
1159- are selling depending on the guarantees offered to buyers .
1159+ are selling.
11601160
1161- 1 . subtype: ` will_fund_lease_rates `
1161+ 1 . ` lease_type ` : 0 ( ` basic_funding_lease ` )
116211622 . data:
1163- * [ ` will_fund_lease_rates_tlvs ` :` lease_rates ` ]
1163+ * [ ` u32 ` :` min_lease_amount_sat ` ]
1164+ * [ ` u32 ` :` max_lease_amount_sat ` ]
1165+ * [ ` u16 ` :` funding_weight ` ]
1166+ * [ ` u16 ` :` lease_fee_basis ` ]
1167+ * [ ` tu32 ` :` lease_fee_base_sat ` ]
11641168
1165- 1 . ` tlv_stream ` : ` will_fund_lease_rates_tlvs `
1166- 2 . types:
1167- 1 . type: 1 (` basic_funding_leases ` )
1168- 2 . data:
1169- * [ ` ...*basic_funding_lease ` :` funding_lease_rates ` ]
1169+ Each ` lease_type ` has a matching ` lease_witness ` that commits to the lease.
1170+
1171+ 1 . ` lease_type ` : 0 (` basic_funding_lease_witness ` )
1172+ 2 . data:
1173+ * [ ` ...*byte ` :` funding_script ` ]
1174+
1175+ Lease types and lease witnesses are encoded using the TLV format, using the
1176+ ` lease_type ` for the type field.
1177+
1178+ Sellers also define how the fees can be paid by listing the ` payment_type ` s
1179+ they support.
1180+
1181+ 1 . ` payment_type ` : 0 (` from_channel_balance ` )
1182+
1183+ Payment types are encoded using the TLV format, using the ` payment_type ` for
1184+ the type field.
1185+
1186+ Sellers advertize their rates and payment types using ` will_fund_rates ` .
1187+
1188+ 1 . subtype: ` will_fund_rates `
1189+ 2 . data:
1190+ * [ ` u16 ` :` funding_rates_count ` ]
1191+ * [ ` funding_rates_count*funding_lease ` :` funding_rates ` ]
1192+ * [ ` u16 ` :` payment_types_len ` ]
1193+ * [ ` payment_types_len*byte ` :` payment_types ` ]
1194+
1195+ Buyers select a specific lease and a ` payment_type ` offered by the seller
1196+ and use ` request_funds ` to purchase that lease.
11701197
117111981 . subtype: ` request_funds `
117211992 . data:
11731200 * [ ` u64 ` :` requested_sats ` ]
1174- * [ ` byte ` :` lease_type ` ]
11751201 * [ ` funding_lease ` :` funding_lease ` ]
1202+ * [ ` payment_type ` :` payment_type ` ]
11761203
1177- 1 . ` lease_type ` : 1 (` basic_funding_lease ` )
1178- 2 . data:
1179- * [ ` u32 ` :` min_lease_amount_sat ` ]
1180- * [ ` u32 ` :` max_lease_amount_sat ` ]
1181- * [ ` u16 ` :` funding_weight ` ]
1182- * [ ` u16 ` :` lease_fee_basis ` ]
1183- * [ ` u32 ` :` lease_fee_base_sat ` ]
1204+ Sellers accept the purchase with ` will_fund ` containing a signature that
1205+ commits to the lease parameters included in the ` lease_witness ` .
11841206
118512071 . subtype: ` will_fund `
118612082 . data:
1187- * [ ` byte ` :` lease_witness_type ` ]
11881209 * [ ` lease_witness ` :` lease_witness ` ]
11891210 * [ ` signature ` :` signature ` ]
11901211
1191- 1 . ` lease_witness_type ` : 1 (` basic_funding_lease_witness ` )
1192- 2 . data:
1193- * [ ` u16 ` :` funding_script_size ` ]
1194- * [ ` funding_script_size ` :` funding_script ` ]
1212+ ### Requirements
11951213
1196- Sellers may offer multiple ` lease_type ` s, described in the following sections.
1197- Buyers select a specific lease offered by the seller and use ` request_funds `
1198- to purchase that lease. Sellers answer with ` will_fund ` containing a signature
1199- that commits to the lease parameters included in the ` lease_witness ` .
1214+ A node selling liquidity:
1215+ - MUST advertise its funding rates with ` will_fund_rates ` :
1216+ - MUST include a list of ` lease_type ` s in ` funding_rates ` .
1217+ - MUST encode each ` funding_lease ` using the TLV format.
1218+ - MAY include multiple ` funding_lease ` s with the same ` lease_type ` .
1219+ - MUST include a ` payment_types ` bitfield: for each ` payment_type ` that it
1220+ supports, the bit at the position matching this type MUST be set.
1221+ - When receiving ` request_funds ` :
1222+ - If the ` funding_lease ` does not match a lease it offers:
1223+ - MUST reject the funding attempt.
1224+ - If the ` payment_type ` is not supported:
1225+ - MUST reject the funding attempt.
1226+ - Otherwise:
1227+ - MUST send ` will_fund ` with the ` lease_witness ` matching the requested
1228+ ` funding_lease ` and a signature covering that witness (see below).
1229+
1230+ A node buying liquidity:
1231+ - MUST ignore any unknown ` lease_type ` in ` will_fund_rates.funding_rates ` .
1232+ - MUST ignore any unknown ` payment_type ` in ` will_fund_rates.payment_types ` .
1233+ - MUST create ` request_funds ` with a ` funding_lease ` from the ` funding_rates `
1234+ and a ` payment_type ` from the ` payment_types ` bitfield.
1235+ - MUST encode ` funding_lease ` and ` payment_type ` using the TLV format.
12001236
12011237### The ` basic_funding_lease ` type
12021238
1203- A ` basic_funding_lease ` does not provide any guarantee that the seller won't
1204- close the channel or increase their routing fees after the purchase, if the
1205- liquidity isn't actually used.
1206-
1207- When ` request_funds ` and ` will_fund ` have been exchanged, the buyer must pay
1208- fees to the seller for the funding they provide to the channel based on the
1209- agreed upon ` funding_weight ` , ` lease_fee_basis ` and ` lease_fee_base_sat ` .
1210-
1211- The lease fee is taken from the buyer's funding inputs and added to the
1212- seller's channel balance during the funding flow. The buyer must contribute
1213- enough funds to cover their channel balance, the lease fee, and the on-chain
1214- fees for the weight of the funding transaction they're responsible for.
1239+ When ` request_funds ` and ` will_fund ` have been exchanged, the buyer agrees to
1240+ pay fees to the seller for the funding they provide to the channel based on
1241+ the proposed ` funding_weight ` , ` lease_fee_basis ` and ` lease_fee_base_sat ` .
12151242
12161243The lease fee has three components:
12171244
@@ -1231,6 +1258,8 @@ associated with their `node_id`. The data signed is:
12311258
12321259 SHA256("basic_funding_lease" || basic_funding_lease_witness)
12331260
1261+ The ` basic_funding_lease_witness ` is encoded using the TLV format.
1262+
12341263We use a tagged hash to ensure that this signature cannot be used in a
12351264different context.
12361265
@@ -1246,14 +1275,23 @@ A node selling a `basic_funding_lease`:
12461275 It ensures that the funding node is refunded for some of the on-chain
12471276 fees it will pay to contribute the requested funds to a channel.
12481277
1278+ ### The ` from_channel_balance ` payment type
1279+
1280+ The lease fee is taken from the buyer's transaction inputs and added to the
1281+ seller's channel balance during the funding flow, using the
1282+ [ interactive-tx] ( ./02-peer-protocol.md#interactive-transaction-construction )
1283+ protocol. The buyer must contribute enough funds to cover their channel
1284+ balance, the lease fee, and the on-chain fees for the weight of the funding
1285+ transaction they're responsible for.
1286+
12491287#### Example
12501288
12511289A node contributes ` 500_000 sats ` to a channel and requests ` 1_000_000 sats `
12521290from its peer, at a feerate of ` 2500 sat/kw ` . The total weight of their inputs
12531291and outputs in the funding transaction is 720. More details about transaction
12541292weight can be found in the [ interactive-tx section] ( 02-peer-protocol.md#interactive-transaction-construction ) .
12551293
1256- The seller contributes ` 1_100_000 sats ` with the following ` lease_rate ` :
1294+ The seller contributes ` 1_100_000 sats ` with the following lease rate :
12571295
12581296 funding_weight = 444
12591297 lease_fee_base_sat = 233 sats
0 commit comments