From aj at erisian.com.au Wed Jan 4 03:08:47 2023 From: aj at erisian.com.au (Anthony Towns) Date: Wed, 4 Jan 2023 13:08:47 +1000 Subject: [Lightning-dev] Swap-in-Potentiam: Moving Onchain Funds "Instantly" To Lightning In-Reply-To: References: Message-ID: On Wed, Jan 04, 2023 at 01:06:36PM +1100, Lloyd Fournier wrote: > The advantage of using a covenant > is that the channel would not have an expiry date and therefore be a first > class citizen among channels. I think the approach here would be: * receive funds on the in-potentiam address with 8000 block CSV * LSP tracks immediately * user's wallet wakes up, LSP reports address to user, user signs a funding tx to establish the channel, and the state 0 close tx * LSP considers it immediately active * LSP broadcasts the tx, targeting confirmation within 3 days * if the funding tx confirms promptly, you just have an ordinary channel * after 800 blocks, if the tx hasn't confirmed, LSP fee bumps or closes the channel (relying on the high-feerate unilateral close tx to do the fee bumping) ie: day 0: someone -> in-potentiam address (payment made on-chain, confirmed) day 7: in-potentiam -> funding (wallet wakes up, tx signed and broadcast, not necessarily confirmed, channel active) day 12: in-potentiam -> funding (confirmed) day 9999: funding -> unilateral/cooperative close or: day 0: someone -> in-potentiam address (payment made on-chain, confirmed) day 14: LSP forgets about in-potentiam utxo as its expiry is only 1000 blocks away day 420: in-potentiam -> wherever (payment made on-chain by user) So while the tx introspection approach you advocate *would* allow the setup phase to skip the "expiry on day 14" restriction, I think the *bigger* benefit is that you also wouldn't need the on-chain "in-potentiam -> funding" transaction, but could instead just leave the in-potentiam tx on chain indefinitely, until it was time to close the channel (which, if it was a cooperative close, could just be a musig key path spend). Either approach probably implies that you either have multiple channels with your LSP (one for each in-potentiam payment you receive), or that your single channel with your LSP is backed by multiple UTXOs (maybe you choose an order for them, so that Alice owns 100% of the balance in utxos 1..(k-1) and Bob owns 100% of the balance in utxos (k+1)..n?). Otherwise you'd need an on-chain tx anyway to splice the new funds into your existing channel; and that seems both annoying of itself, and probably bad for privacy. Cheers, aj