lightning icon indicating copy to clipboard operation
lightning copied to clipboard

[Feature Request] Add payer_offer to fetchinvoice

Open hMsats opened this issue 4 months ago • 0 comments

When a client is paying a qr-code of an offer, give the client the possibility to include/send an offer for any amount. This allows the service to pay/refund to the client's wallet directly, without further client-service interaction. Note that it is already possible for a client (or his wallet) to send his offer to the service by using payer_note=lno1... in fetchinvoice but this would allow wallets to include it in a standard manner.

I'm aware of invoicerequest and sendinvoice but as far as I understand it, this still requires service-client interaction for a refund after the payment by the client.

EDIT:

As a demonstration, I have now implemented this in my working spark-wallet by changing:

const { invoice: bolt12_invoice, changes } = await this.fetchinvoice(bolt12_offer, amount_msat, quantity, null, null, null, null, payer_note)

into

const {offer_id, active, single_use, bolt12: payer_offer, used, created } = await this.offer("any")
const { invoice: bolt12_invoice, changes } = await this.fetchinvoice(bolt12_offer, amount_msat, quantity, null, null, null, null, payer_offer)

in src/cmd.js

This allows me to play my lightning game without registration, by just paying the initial bet and receiving double the reward if guessed right :-)

hMsats avatar Oct 15 '24 15:10 hMsats