From dave at dtrt.org Tue Oct 24 04:41:34 2023 From: dave at dtrt.org (David A. Harding) Date: Mon, 23 Oct 2023 18:41:34 -1000 Subject: [Lightning-dev] [lightning-dev] Batch exchange withdrawal to lightning requires covenants In-Reply-To: References: Message-ID: On 2023-10-17 03:03, Bastien TEINTURIER via bitcoin-dev wrote: > Good morning list, > > I've been trying to design a protocol to let users withdraw funds from > exchanges directly into their lightning wallet in an efficient way > (with the smallest on-chain footprint possible). Hi, Bastien. Is swap-in-potentiam[1] an option here? For example, Exchange E wants to pay users A, B, and C, who each have different counterparties. Then: - E gets from each of A, B, C a public key for their separate counterparties (e.g., D, E, F) - E gets confirmed a transaction paying three swap-in-potentiam outputs, one each for {A,D}, {B,E}, {C,F} - Each of the parties then offchain spends the SiP outputs into a standard LN-penalty channel construction and starts using it - Ideally, before the SiP expires, each party is able to drain the channel into their other channels and mutually settle it with just an onchain spend of the SiP output - Non-ideally, the previously offchain spend of the SiP output that established the LN-penalty channel is put onchain In the best case, this involves four transactions: - E's one-input, four-output batch withdrawl (the fourth output is E's change) - Three separate one-input, one-output transactions to settle the SiP outputs I think that's the same number (and approximate size) of transactions that you'll get from the SIGHASH_ANYPREVOUT|SIGHASH_SINGLE solution you outline, although your solution allows the channels to remain open indefinitely, whereas the SiP solution has an expiry. -Dave [1] https://lists.linuxfoundation.org/pipermail/lightning-dev/2023-January/003810.html (I know Eclair already uses SiP; the above reference is for other readers)