BitcoinAndLightningLayerSpecs / lsp

API specifications for Lightning Service Providers
MIT License
109 stars 31 forks source link

LSPS1: Clarify whether `refund_onchain_address` usage is mandatory #122

Open tnull opened 1 month ago

tnull commented 1 month ago

The current LSPS1 spec states in regards to refund_onchain_address:

refund_onchain_address <LSPS0.onchain_address> Address where the LSP will send the funds if the order fails.

    Client MAY omit this field.
    LSP MUST disable on-chain payments if the client omits this field.

and

If the order expired and the channel has NOT been opened, OR the channel open failed.

    MUST refund the client to refund_onchain_address.

So, AFAICT the LSP is currently required to fulfill any refunds to the refund_onchain_address, even if it doesn't support on-chain payments in the first place.

We need to clarify:

  1. if this indeed is the case, or if not, how an LSP only accepting BOLT11 payments would handle refunds.
    • Relatedly, we need to clarify whether mirroring the client-set field in create_order response is mandatory, or if the LSP is allowed to omit it if it doesn't support onchain payments.
  2. If we need to add a refund address/invoice/BOLT12 refund per-payment method rather than just a simple refund_onchain_address
ErikDeSmedt commented 3 weeks ago

I see the source of the confusion here. Below I explain how I intended the spec to be read.

Section 3.1 lightning payments and 3.2 onchain payments both describe state-changes. If a client chooses to pay over lightning the rules in section 3.1 apply. If a client chooses to pay on-chain the rules in section 3.2 apply.

3.1 Lightning payments

If the client paid with Lightning and the LSP failed to open the channel. In that case the LSP should refuse the payment and set the state to CANCELLED.

If the channel failed to open or the order expired or shortly before the payment times out:

    MUST reject the payment.
    MUST set the payment.state to CANCELLED.

3.2 Onchain payments

If the client paid onchain and the LSP failed to open the channel. The LSP should refund the payment on refund_onchaiN_address and set the state to REFUNDED.

refund_onchain_address <LSPS0.onchain_address> Address where the LSP will send the funds if the order fails.

    Client MAY omit this field.
    LSP MUST disable on-chain payments if the client omits this field.

The LSP can only use the refund_onchain_address if the client provided it. Therefore, the LSP will not provide the onchain payment method if the client failed to provide the field. A client that intends to pay with Lightning can omit the refund_onchain_address.

tnull commented 3 weeks ago

I see the source of the confusion here. Below I explain how I intended the spec to be read.

Yeah, in the latest spec call we discussed this for a while and also discovered that refund_onchain_address is actually never mirrored back like all the other fields in create_order response, which we read as a spec bug. We decided to add it (although in the payment: onchain sub-dictionary) to fix this oversight, and clarify the expected behavior around failure handling in a few places. I believe @SeverinAlexB is working on a PR for this currently.