Research/Bitcoin Dev Archive / lightning-dev list
Channel top-up
9 messages, May 3 to 9, 2017. Started by ZmnSCPxj.
ZmnSCPxj (5), Christian Decker (3), Rusty Russell
Good morning people,
I want to propose, the addition of a new operation (and related messages) to the Lightning Network protocol.
Suppose Alice and Bob have a micropayment channel. Now, because Bob provides an excellent service, Alice's side of the micropayment channel is eventually depleted. If Alice needs to spend more for Bob's services, she can either look for another route on a channel she has with someone else, or open a new channel to Bob and close the existing channel.
I would like to propose a "top-up" operation which transmits Bitcoins to Bob on-chain in exchange for crediting that amount to Alice's side in the micropayment channel.
Effectively, this is equivalent, in spirit, to Alice paying Bob to pay Alice. Although no money effectively is transferred by the operation, it moves the state of the channel between Alice and Bob.
Intuitively, for a casual user of LN, it should be possible to "top up" the channel, so that Alice can continuously pay for Bob's excellent service. The concept of topping up already exists outside of LN, and new users might reasonably ask about such a feature. Given that funds in a channel are locked up in that channel until closed, I think that most LN software would separate the amount spendable via Lightning from the amount spendable via normal Bitcoin transactions. A user of the software might want to increase his or her Lightning-spendable funds as they get depleted. While the software can abstract this away and simply create channels to random other nodes, I think the proposed "top-up" operations may reduce load on both Lightning and Bitcoin layers.
The procedure is below:
1. Alice generates a random number preimage.
2. Alice proposes a top-up operation to Bob.
3. Bob responds with a newly-generated public key hash as payment target.
4. Alice generates a recovery public key hash and creates an HTLC transaction containing the top-up amount from her funds, signs it, and broadcasts it to the Bitoin network. The HTLC will pay to Alice's recovery PKH after a CLTV + 2 day timeout, or pay to Bob's payment target with the random number preimage.
5. When the transaction confirms on the Bitcoin blockchain, Alice provides the transaction ID to Bob as well as the hash of the random number preimage. (This is needed to prevent Alice from double-spending the money that should go to Bob).
6. Bob sends a (standard) update_add_htlc to Alice, referring to their channel, with a CLTV +1 day timeout. They recreate commitment transactions as normal response to update_add_htlc message..
7. Alice sends a (standard) update_fulfill_htlc, providing the random number preimage.
8. Bob confirms that the preimage hashes to the random number preimage, and if so fulfills the update_fulfill_htlc. They recreate commitment transactions as normal response to update_fulfill_htlc. After this point, Alice may now spend via Lightning for Bob's services.
9. Bob creates a transaction from the on-chain HTLC transaction to another address he controls.
Hi ZmnSCPxj,
thanks for proposing this, it looks quite interesting, and the top-up problem is definitely worth looking into. However, I think there are a few problems with your proposal: it is rather complicated and needs to track funds in the channel as well as "side-stashed" funds, also the HTLCs in the channel cannot possibly make use of the topped up funds since they are not spending them, they'd need to be aggregated first.
At the Scaling Bitcoin workshop I proposed a mechanism that I called splice-in/-out that would also solve the top-up problem, but I never got around to write it up, mea culpa. Splicing is just a clever way of closing a channel and reopening a new one right from the settlement, and the new one does not need to be confirmed before we can perform further updates.
Splice-in --------- So let's say that Alice would like to top-up here channel with Bob. She will take some of her funds and create a new 2-of-2 output with requiring both Alice and Bob's signature, this is preparing funds to be added to the channel. We let the transaction creating that 2-of-2 output confirm. Once that output is securely confirmed Alice asks Bob to splice-in, so they collaboratively close the channel by spending the funding TX output and the prepared top-up output into a new 2-of-2 output. On that final 2-of-2 output we will create the new channel, i.e., the settlement transaction is automatically the funding transaction of the new channel.
Alice and Bob can use the existing channel right up to the splice-in operation, Alice may just be pre-allocating some funds in parallel. During the splice-in we need to stop forwarding HTLCs for a few seconds, so we can settle cleanly. Directly after the splice-in the channel is functional again, no need to let the settlement/funding transaction confirm. That is because the funds in the channel never touched an unconfirmed singlesig output, hence they can never be doublespent without the collaboration of the counterparty.
Splice-out ---------- The opposite problem of moving funds out of a channel can also be addressed with this trick. So we can actually perform on-chain transactions directly from funds that are locked into a channel (that's why I don't think "locked in" is the right word to describe this situation). So let's assume Alice would like to perform an on-chain payment using some funds (x satoshi) that are currently assigned to a channel with Bob. She creates a settlement transactions that spend x satoshi to the desired destination/address, and the remainder is paid back to a 2-of-2 output owned by Alice and Bob. They will then build the new version of the channel on top of this new 2-of-2 output and be able to continue performing transfers right away. Again, this works because the funds that remain in the channel never touch a singlesig, so there is no need to confirm it first.
We might even go a step further and not need to drain the HTLCs from a channel before performing a splice operation, assuming we can get the setup procedure to include all HTLCs that were present before the splice operation.
I'd love feedback and comparisons of both proposals :-)
Cheers, Christian
Good morning Christian,
Quoted text (2 lines)
>thanks for proposing this, it looks quite interesting, and the top-up >problem is definitely worth looking into.
Thank you very much your kindness.
Quoted text (3 lines)
>However, I think there are a >few problems with your proposal: it is rather complicated and needs to >track funds in the channel as well as "side-stashed" funds,
I'm not sure why it's complicated apparently.
Actually, this reuses the same mechanism as onion routing. The only difference is that the first "hop" of the route is performed via an on-chain transaction.
Once the usual onion-routing mechanims has settled with update_fulfill_htlc, the channel state settles to a new topped-up state. The "side funds" are definitely in the possession of Bob, and do not affect the channel state and are not considered in the channel state.
Here is concrete example.
1. First, the channel has state: Alice=0.0, Bob=1.0
2. Alice requests a top-up to Bob. She makes an HTLC(3days, topupsecret) on-chain (written, signed, confirmed) worth 0.25, which Bob can redeem once Alice provides the secret.
3. Bob changes the channel state using update_add_htlc, so the channel now has state: Alice=0.0, Alice+HTLC(1day, topupsecret)=0.25, Bob=0.75.
4. Alice changes the channel state using update_fulfill_htlc, so the channel now has state: Alice=0.25, Bob=0.75. Bob now knows the secret to the HTLC that Alice prepared on-chain.
5. Bob performs an on-chain transaction to recover the 0.25Btc from the on-chain HTLC by Alice.
There is no need to keep track of side funds once the HTLC update_fullfill_htlc command is sent by Alice. At this point, Bob has access to the money.
The limitation here is that the total channel funds limits the amount that Alice can top-up the channel.
Quoted text (3 lines)
>also the >HTLCs in the channel cannot possibly make use of the topped up funds >since they are not spending them, they'd need to be aggregated first.
Sorry, maybe my explanation isn't clear.
Alice's side is depleted, but Bob's side isn't depleted. So Bob can offer an on-channel HTLC to Alice using Bob's funds on the channel.
Quoted text (6 lines)
>At the Scaling Bitcoin workshop I proposed a mechanism that I called >splice-in/-out that would also solve the top-up problem, but I never >got around to write it up, mea culpa. Splicing is just a clever way of >closing a channel and reopening a new one right from the settlement, >and the new one does not need to be confirmed before we can perform >further updates.
I'd considered something similar at first, but realized that some risks were involved.
Quoted text (8 lines)
>Splice-in >--------- >So let's say that Alice would like to top-up here channel with >Bob. She will take some of her funds and create a new 2-of-2 output >with requiring both Alice and Bob's signature, this is preparing funds >to be added to the channel. We let the transaction creating that >2-of-2 output confirm. Once that output is securely confirmed Alice >asks Bob to splice-in,
Bob then creates the following message: "Heya Alice! I see you made a 0.25 btc output requiring a 2-of-2 multisig. One of the signatures on that multisig happens to be my signature. Because of this unauthorized requirement of my signature, I want you to make another transaction spending that transaction, sending 0.13 btc to 18X5NsJrrqgjprXucYTTshjHm3ETYgqk8z. You can transfer 0.12btc minus transaction fees to someone else if you like. Please sign that transaction and send it to me. Love, kisses, hope that helps, Bob." Bob then cryptographically signs the message and sends it off-channel to Alice. Bob then refuses to cooperate with the rest of the splice-in protocol.
Quoted text (14 lines)
>so they collaboratively close the channel by >spending the funding TX output and the prepared top-up output into a >new 2-of-2 output. On that final 2-of-2 output we will create the new >channel, i.e., the settlement transaction is automatically the funding >transaction of the new channel. > >Alice and Bob can use the existing channel right up to the splice-in >operation, Alice may just be pre-allocating some funds in >parallel. During the splice-in we need to stop forwarding HTLCs for a >few seconds, so we can settle cleanly. Directly after the splice-in >the channel is functional again, no need to let the settlement/funding >transaction confirm. That is because the funds in the channel never >touched an unconfirmed singlesig output, hence they can never be >doublespent without the collaboration of the counterparty.
^^ counterparty hostage risk, Bob didn't follow it ^^
Quoted text (4 lines)
>Splice-out >---------- >The opposite problem of moving funds out of a channel can also be >addressed with this trick. So we can actually perform on-chain
t>ransactions directly from funds that are locked into a channel
Quoted text (10 lines)
>(that's why I don't think "locked in" is the right word to describe >this situation). So let's assume Alice would like to perform an >on-chain payment using some funds (x satoshi) that are currently >assigned to a channel with Bob. She creates a settlement transactions >that spend x satoshi to the desired destination/address, and the >remainder is paid back to a 2-of-2 output owned by Alice and Bob. They >will then build the new version of the channel on top of this new >2-of-2 output and be able to continue performing transfers right >away. Again, this works because the funds that remain in the channel >never touch a singlesig, so there is no need to confirm it first.
I see. This seems feasible. The order needs to be specified exactly, though. In this case, to splice out
1. Alice generates a new funding transaction, inputting only the previous funding transaction. It outputs a 2-of-2 multisig Alice+Bob, and another output P2PKH of Alice's selection.
2. Alice sends the splice-out funding transaction to Bob, who checks that the P2PKH of Alice plus the tx fee of the splice-out funding transaction is less than Alice's money on the channel.
3. Alice and Bob create and sign new commitment transactions based on the splice-out funding transaction, checking that the balances are correct, with Alice's balances spliced out correctly.
4. Alice and Bob sign the splice-out funding transaction, and broadcast the tx without waiting for confirmation.
5. Alice and Bob exchange revocation keys for their previous commitment transactions (which were based on the previous funding transaction).
In the above, it's safe to abort at any time, with the money remaining in the channel.
Note however a potential hostage situation: Alice wants to move money out of the channel expeditiously without closing the channel. Bob may refuse to cooperate on a splice-out. Thus, this is the same risk as Alice requesting to close the channel and Bob not cooperating, forcing Alice to use her commitment transaction, which has a time delay.
Thus, it's not safe to think of the channel's fund as anything but locked in, since uncooperation means the channel's funds are returned to you after a timeout.
Quoted text (4 lines)
>We might even go a step further and not need to drain the HTLCs from a >channel before performing a splice operation, assuming we can get the >setup procedure to include all HTLCs that were present before the >splice operation.
Sorry, the interaction of CSV (in commitment transaction timeouts) and CLTV (in HTLC's) still escapes me.
Quoted text (1 line)
>I'd love feedback and comparisons of both proposals :-)
As for my top-up proposal, I realized also, that it's actually an onion route where part of the hop is done on-chain rather than on-Lightning.
Thus, while the top-up procedure is expected to be used by Alice to top up her channel funds, it's actually the first hop of an onion route. The onion route just happens to route from off-LN Alice, to on-LN Bob, to on-LN Alice.
This may be used by someone off-LN to pay into an LN node without committing funds to open a channel, for example for a one-off transaction to a Lightning node. That someone may use onion routing to ensure that it becomes untraceable on LN. Alternatively, a non-Lightning user can claim he or she did an off-LN onion route, but actually just sent the funds to himself/herself to throw off trackers.
Regards, ZmnSCPxj
Hi ZmnSCPxj,
thanks for the clarification, I think I understand the proposal a bit better now.
Quoted text (11 lines)
> I'm not sure why it's complicated apparently. > > Actually, this reuses the same mechanism as onion routing. The only > difference is that the first "hop" of the route is performed via an > on-chain transaction. > > Once the usual onion-routing mechanims has settled with > update_fulfill_htlc, the channel state settles to a new topped-up > state. The "side funds" are definitely in the possession of Bob, and > do not affect the channel state and are not considered in the > channel state.
I see, so you're not actually modifying the total amount in the channel, Alice is just buying back some capacity on the channel using an on-chain transaction.
Quoted text (9 lines)
> >At the Scaling Bitcoin workshop I proposed a mechanism that I called > >splice-in/-out that would also solve the top-up problem, but I never > >got around to write it up, mea culpa. Splicing is just a clever way of > >closing a channel and reopening a new one right from the settlement, > >and the new one does not need to be confirmed before we can perform > >further updates. > > I'd considered something similar at first, but realized that some > risks were involved.
I don't think we are incurring in any exceptional risks, and we are actually reusing the same machinery we already have for the initial establishment of the channel.
Quoted text (20 lines)
> >Splice-in > >--------- > >So let's say that Alice would like to top-up here channel with > >Bob. She will take some of her funds and create a new 2-of-2 output > >with requiring both Alice and Bob's signature, this is preparing funds > >to be added to the channel. We let the transaction creating that > >2-of-2 output confirm. Once that output is securely confirmed Alice > >asks Bob to splice-in, > > Bob then creates the following message: "Heya Alice! I see you made > a 0.25 btc output requiring a 2-of-2 multisig. One of the signatures > on that multisig happens to be my signature. Because of this > unauthorized requirement of my signature, I want you to make another > transaction spending that transaction, sending 0.13 btc to > 18X5NsJrrqgjprXucYTTshjHm3ETYgqk8z. You can transfer 0.12btc minus > transaction fees to someone else if you like. Please sign that > transaction and send it to me. Love, kisses, hope that helps, Bob." > Bob then cryptographically signs the message and sends it > off-channel to Alice. Bob then refuses to cooperate with the rest of > the splice-in protocol.
This is not different from how we are establishing channels initially. Alice would only ever lock in the funds with a guarantee that she can retrieve the funds if Bob decides not to cooperate. We can implement this with locktimes or CSV, and disarm that mechanism later using a re-anchor. So the script is (A+B || A+timeout) if the splice goes well we re-anchor, and the righthand side of the || is disarmed.
Quoted text (16 lines)
> >so they collaboratively close the channel by > >spending the funding TX output and the prepared top-up output into a > >new 2-of-2 output. On that final 2-of-2 output we will create the new > >channel, i.e., the settlement transaction is automatically the funding > >transaction of the new channel. > > > >Alice and Bob can use the existing channel right up to the splice-in > >operation, Alice may just be pre-allocating some funds in > >parallel. During the splice-in we need to stop forwarding HTLCs for a > >few seconds, so we can settle cleanly. Directly after the splice-in > >the channel is functional again, no need to let the settlement/funding > >transaction confirm. That is because the funds in the channel never > >touched an unconfirmed singlesig output, hence they can never be > >doublespent without the collaboration of the counterparty. > > ^^ counterparty hostage risk, Bob didn't follow it ^^
Counterparty hostage risk disarmed ^^
Quoted text (16 lines)
> >Splice-out > >---------- > > In the above, it's safe to abort at any time, with the money > remaining in the channel. > > Note however a potential hostage situation: Alice wants to move > money out of the channel expeditiously without closing the > channel. Bob may refuse to cooperate on a splice-out. Thus, this is > the same risk as Alice requesting to close the channel and Bob not > cooperating, forcing Alice to use her commitment transaction, which > has a time delay. > > Thus, it's not safe to think of the channel's fund as anything but > locked in, since uncooperation means the channel's funds are > returned to you after a timeout.
Right, there remains that risk, but hopefully that wouldn't happen too often ;-)
Quoted text (7 lines)
> >We might even go a step further and not need to drain the HTLCs from a > >channel before performing a splice operation, assuming we can get the > >setup procedure to include all HTLCs that were present before the > >splice operation. > > Sorry, the interaction of CSV (in commitment transaction timeouts) > and CLTV (in HTLC's) still escapes me.
If we are able to recreate the same HTLCs on the re-anchored channel in a safe way then we can avoid draining them off of the channel before splicing. Even if we don't do that we may simply hold back on adding new HTLCs, drain, re-anchor and then add the held back HTLCs once the splice is completed. And finally this could allow us to perform a partial drop to the chain, splicing out just the HTLCs which are about to expire and maintaining the rest of the channel intact.
Quoted text (18 lines)
> >I'd love feedback and comparisons of both proposals :-) > > As for my top-up proposal, I realized also, that it's actually an > onion route where part of the hop is done on-chain rather than > on-Lightning. > > Thus, while the top-up procedure is expected to be used by Alice to > top up her channel funds, it's actually the first hop of an onion > route. The onion route just happens to route from off-LN Alice, to > on-LN Bob, to on-LN Alice. > > This may be used by someone off-LN to pay into an LN node without > committing funds to open a channel, for example for a one-off > transaction to a Lightning node. That someone may use onion routing > to ensure that it becomes untraceable on LN. Alternatively, a > non-Lightning user can claim he or she did an off-LN onion route, > but actually just sent the funds to himself/herself to throw off > trackers.
That's very clever, I like the combination of on-chain and off-chain payments. I still like my splicing approach better (yes, I'm pretty biased in this case ^^) but being able to combine on-chain and off-chain is a great feature, let's see how far we can push it.
Cheers, Christian
Good morning,
Quoted text (9 lines)
>> Once the usual onion-routing mechanims has settled with >> update_fulfill_htlc, the channel state settles to a new topped-up >> state. The "side funds" are definitely in the possession of Bob, and >> do not affect the channel state and are not considered in the >> channel state. > >I see, so you're not actually modifying the total amount in the >channel, Alice is just buying back some capacity on the channel using >an on-chain transaction.
That's correct. Of course, proper splice-in and splice-out operations would allow channel maximum capacity to be controlled by the counterparties, based on their financial situation and growing/shrinking trust in their counterparty.
Quoted text (28 lines)
>> >Splice-in >> >--------- >> >So let's say that Alice would like to top-up here channel with >> >Bob. She will take some of her funds and create a new 2-of-2 output >> >with requiring both Alice and Bob's signature, this is preparing funds >> >to be added to the channel. We let the transaction creating that >> >2-of-2 output confirm. Once that output is securely confirmed Alice >> >asks Bob to splice-in, >> >> Bob then creates the following message: "Heya Alice! I see you made >> a 0.25 btc output requiring a 2-of-2 multisig. One of the signatures >> on that multisig happens to be my signature. Because of this >> unauthorized requirement of my signature, I want you to make another >> transaction spending that transaction, sending 0.13 btc to >> 18X5NsJrrqgjprXucYTTshjHm3ETYgqk8z. You can transfer 0.12btc minus >> transaction fees to someone else if you like. Please sign that >> transaction and send it to me. Love, kisses, hope that helps, Bob." >> Bob then cryptographically signs the message and sends it >> off-channel to Alice. Bob then refuses to cooperate with the rest of >> the splice-in protocol. > >This is not different from how we are establishing channels >initially. Alice would only ever lock in the funds with a guarantee >that she can retrieve the funds if Bob decides not to cooperate. We >can implement this with locktimes or CSV, and disarm that mechanism >later using a re-anchor. So the script is (A+B || A+timeout) if the >splice goes well we re-anchor, and the righthand side of the || is >disarmed.
Ah, I see. However, we need to ensure the new funding transaction can be confirmed before the pre-splice-in transaction times out. This is especially true if we continue to use the channel, based on the new funding transaction, in an asynchronous (i.e. operating the channel before the splice-in funding transaction is confirmed) manner. So the timeout needs to be rather longish, to ensure that the splice-in funding transaction can get on-chain before the pre-splice-in transaction times out.
Needless to say, asynchronous splice-in would require malleability fix, and in the back of my mind I'm forming a contingency plan if Bitcoin really can't deploy a malleability fix in two years (or half a year when I'm feeling particularly excited about LN). At least the off-to-on-LN routing (using an on-chain HTLC to "buy back" some capacity on your side of a channel) could work without malleability fix.
Quoted text (3 lines)
>> ^^ counterparty hostage risk, Bob didn't follow it ^^ > >Counterparty hostage risk disarmed ^^
Yes ^^
About synchrony/asynchrony; perhaps it's possible to also offer a synchronous splice-in. For example, Alice knows she will route a larger-than-normal payment to Bob in the future, but will not be sending micropayments now. Then perhaps the counterparties can use a splice-in funding transaction directly spending from Alice's inputs (rather than from a pre-splice-in that Alice prepares to reassure Bob she won't suddenly invalidate an unconfirmed splice-in funding transaction). This is slightly less costly, but channel operations would have to be suspended while the splice-in funding transaction is confirmed. This reduces on-chain load.
Although I suppose to the rest of the network, the unusable channel waiting for a synchronous splice-in would be no different from closing a channel, then opening a new one in its place, so maybe not.
Quoted text (19 lines)
>> >Splice-out >> >---------- >> >> In the above, it's safe to abort at any time, with the money >> remaining in the channel. >> >> Note however a potential hostage situation: Alice wants to move >> money out of the channel expeditiously without closing the >> channel. Bob may refuse to cooperate on a splice-out. Thus, this is >> the same risk as Alice requesting to close the channel and Bob not >> cooperating, forcing Alice to use her commitment transaction, which >> has a time delay. >> >> Thus, it's not safe to think of the channel's fund as anything but >> locked in, since uncooperation means the channel's funds are >> returned to you after a timeout. > >Right, there remains that risk, but hopefully that wouldn't happen too >often ;-)
Yes, but if there is hostility against LN (as I suspect), it may happen too often T.T
Personally, I think, it's safer to tell our users that indeed, channel funds are locked in, rather than some attacker running a bad LN node suddenly causing a behavior that honest but naive users did not expect.
Quoted text (10 lines)
>> Sorry, the interaction of CSV (in commitment transaction timeouts) >> and CLTV (in HTLC's) still escapes me. > >If we are able to recreate the same HTLCs on the re-anchored channel >in a safe way then we can avoid draining them off of the channel >before splicing. Even if we don't do that we may simply hold back on >adding new HTLCs, drain, re-anchor and then add the held back HTLCs >once the splice is completed. And finally this could allow us to >perform a partial drop to the chain, splicing out just the HTLCs which >are about to expire and maintaining the rest of the channel intact.
I'll have to defer to you on this one. While I can understand the revocable transactions and the HTLC's in isolation, I haven't understood well yet the ramifications of their interactions.
Quoted text (21 lines)
>> As for my top-up proposal, I realized also, that it's actually an >> onion route where part of the hop is done on-chain rather than >> on-Lightning. >> >> Thus, while the top-up procedure is expected to be used by Alice to >> top up her channel funds, it's actually the first hop of an onion >> route. The onion route just happens to route from off-LN Alice, to >> on-LN Bob, to on-LN Alice. >> >> This may be used by someone off-LN to pay into an LN node without >> committing funds to open a channel, for example for a one-off >> transaction to a Lightning node. That someone may use onion routing >> to ensure that it becomes untraceable on LN. Alternatively, a >> non-Lightning user can claim he or she did an off-LN onion route, >> but actually just sent the funds to himself/herself to throw off >> trackers. > >That's very clever, I like the combination of on-chain and off-chain >payments. I still like my splicing approach better (yes, I'm pretty >biased in this case ^^) but being able to combine on-chain and >off-chain is a great feature, let's see how far we can push it.
Suppose Alice is planning a new business that receives Bitcoin. She sets up an LN node. However, because her LN node is new, it doesn't have channels yet. To expedite payments to her when business is launched, she wants her LN node to have channels. But if she initiates channels herself to nodes already on the network, those channels will be set up to send from her business node to the network, when she wants them to be set up to receive. Of course she could leave her node without channels and have her first customers set up a channel directly to her, but that slows down her customers, who must wait for the channels to open before they can spend money on Alice's excellent service.
Instead, in preparation for business launch day, Alice opens a channel to well-connected node Bob. At first, the channel's state is Alice=1.0, Bob=0.0, because Alice initiated the channel, so Alice can't actually use it to receive funds. She sends an invitation-to-top-up to Bob, inviting him to top up the channel by 0.5 btc, and if Bob compiles and does indeed top-up, then the channel's state becomes Alice=0.5, Bob=0.5, so it can now be used by Alice to receive from customers. Alice does this a few more times with various other existing LN nodes, so that on business launch, she can receive money from her first customers immediately.
Of course, if we had a symmetrical rather than a one-sided open, a symmetrical open would be more efficient on the underlying Bitcoin network overall.
Top-up can be used to revive not only exhausted channels, but exhausted routes. Suppose there is one known route from Alice to Carol: Alice->Bob->Carol. Because of Carol's excellent service, Bob->Carol's channel is exhausted. Alice can then use an on-chain HTLC to revive the Alice->Bob->Carol route, by making a top-up operation: Alice ->(onchain)-> Carol -> Bob -> Alice.
Of course, in this case Alice is better off just making a channel directly to Carol, if she is willing to make an on-chain transaction anyway.
Regards, ZmnSCPxj
ZmnSCPxj via Lightning-dev <lightning-dev at lists.linuxfoundation.org> writes:
Quoted text (3 lines)
> Good morning people, > > I want to propose, the addition of a new operation (and related messages) to the Lightning Network protocol.
Hi,
Yes, we call this re-anchoring. The same method can be used for adding or removing funds from the channel, by mutual cooperation. It has the additional merit that (once deeply confirmed) you can forget revocation information for any older commitment transactions.
It was omitted from the 1.0 spec because we have more than enough in there already.
But your solution seems overly complex? A or B can simply propose a new funding transaction which spends the current one, both sides exchange all the output signatures for a new commitment transaction which uses that, then exchange signatures for the new funding transaction.
Even if the new funding tx isn't confirmed yet, they can continue to use the channel as normal.
(FWIW, Christian Decker was the one who pointed out how elegant this is).
Cheers, Rusty.
Good morning Rusty,
Quoted text (15 lines)
>ZmnSCPxj via Lightning-dev <lightning-dev at lists.linuxfoundation.org> >writes: >> Good morning people, >> >> I want to propose, the addition of a new operation (and related messages) to the Lightning Network protocol. > >Hi, > >Yes, we call this re-anchoring. The same method can be used for >adding or removing funds from the channel, by mutual cooperation. It >has the additional merit that (once deeply confirmed) you can forget >revocation information for any older commitment transactions. > >It was omitted from the 1.0 spec because we have more than enough in >there already.
I understand.
Quoted text (4 lines)
>But your solution seems overly complex? A or B can simply propose a new >funding transaction which spends the current one, both sides exchange >all the output signatures for a new commitment transaction which uses >that, then exchange signatures for the new funding transaction.
I'm sorry my poor understanding of complexity.
My thought, was that this simply allows an onion-route payment to be started on-chain. Then normal onion-route messages (update_fulfill_htlc etc) can be used.
Basically, my idea, if onion route code already exists, we just modify this a little by allowing an onion-route to start on-chain rather than on-Lightning. The onion route can still remain terminated into a Lightning node. So we need new message to allow onion route to be initiated on-chain/off-LN, but the rest of the onion-route uses the same, already-tested code.
Originally, I thought similarly to the splice-in/splice-out/reanchoring scheme. But I thought it would be more complex to add new message types to consider reanchoring.
Quoted text (5 lines)
>Even if the new funding tx isn't confirmed yet, they can continue to use >the channel as normal. > >(FWIW, Christian Decker was the one who pointed out how elegant this >is).
If the funding tx will only output (i.e. only reduce money on the channel), it's OK.
If the funding tx will input (increase money on the channel), then we need to confirm a pre-splice-in transaction. Then the reanchoring tx can be made safely "floating", although since the pre-splice-in tx has a timelock, we should still anchor the reanchoring tx before the pre-splice-in transaction's timelock ends.
Regards, ZmnSCPxj
Good morning again,
Quoted text (4 lines)
>That's very clever, I like the combination of on-chain and off-chain >payments. I still like my splicing approach better (yes, I'm pretty >biased in this case ^^) but being able to combine on-chain and >off-chain is a great feature, let's see how far we can push it.
Potentially, another application for onion routes with on-chain and off-chain hops is for exchanges.
Suppose I initially have 1000 BTC but only 0 LTC. Since I can afford it, most of my 1000 BTC is in an LN node, slowly gaining more money from routing fees.
But, with 0 LTC, I can't initiate connections on the LTC side of the network. I can pay to Litecoin users, but I would have to make some out-of-band request for a Litecoin-side LN node to connect a Litecoin channel to me.
One way for me to gain LTC would be to route from my BTC LN node, to a BTC/LTC exchange node, and request the final hop to go to an LTC address I control via an on-chain HTLC transaction.
After that, I can initiate LTC connections to LTC LN nodes directly myself, without going through an exchange each time, or alternatively hodl my LTC.
This would allow anyone to be a cross-currency exchange, without having problems about chicken-and-egg problems like "how do I receive LTC via Lightning if I don't have LTC to initiate a channel on the LTC side". Of course, in reality, cross-currency exchanges already exist, so maybe this is not a problem in practice.
On Fri, May 05, 2017 at 06:00:40AM -0400, ZmnSCPxj wrote:
Quoted text (25 lines)
> Potentially, another application for onion routes with on-chain and > off-chain hops is for exchanges. > > Suppose I initially have 1000 BTC but only 0 LTC. Since I can afford > it, most of my 1000 BTC is in an LN node, slowly gaining more money > from routing fees. > > But, with 0 LTC, I can't initiate connections on the LTC side of the > network. I can pay to Litecoin users, but I would have to make some > out-of-band request for a Litecoin-side LN node to connect a > Litecoin channel to me. > > One way for me to gain LTC would be to route from my BTC LN node, to > a BTC/LTC exchange node, and request the final hop to go to an LTC > address I control via an on-chain HTLC transaction. > > After that, I can initiate LTC connections to LTC LN nodes directly > myself, without going through an exchange each time, or > alternatively hodl my LTC. > > This would allow anyone to be a cross-currency exchange, without > having problems about chicken-and-egg problems like "how do I > receive LTC via Lightning if I don't have LTC to initiate a channel > on the LTC side". Of course, in reality, cross-currency exchanges > already exist, so maybe this is not a problem in practice.
Yes, there is a possibility for doing atomic cross chain swaps using Lightning nodes, and routing in a circle back to ourself, starting with the outgoing currency and ending in the desired currency. The fact that we can directly perform the first hop on-chain, as you pointed out, is a great way of having other nodes connect to us and doing an initial balancing of the capacity, e.g., initially they'd own 100% of the channel, but with the conditional on-chain transfer they'd send us some.
Quoted text (9 lines)
> Now, we can argue that we can add an "invitation to connect to me" > to make a channel that is set up to send money to me. This helps > also the new-business-node case (where Alice is setting up a > business and wants to initiate receive channels, rather than the > default send channels). > > But what is the reason why channel opens, in current 1.0 spec, > require the initiator to be the one, and the only one, to put up > funding for the channel?
It's just simpler, since it requires very little coordination, having multi-party funded channels is definitely on the roadmap, but with your insight above we can already balance the channels right from the get go.
Quoted text (34 lines)
> My understanding (it's not explicitly stated in the paper, or in the > rfc specs I've read) is that the initiator pays for the fees in > setting up the channel. > > If we have an "invitation to connect to me" request, and people > comply with the request, the fees come from their funding of the > channels. If I spam the network with this request, then I will waste > everyone's time making those channels, locking up their funds, and > wasting their transaction fees. If I then don't open up a channel to > anyone else and I don't do some service for which I get paid, then > the channels set up to me are wasted in routing gossip, since no > route can pass through me, as there is no way to move money out of > my node. > > Instead, we can keep the "initiator pays for full funding of channel > open" and not have an "invitation to connect to me" request. Then I > can initiate a channel with a well-connected counterparty (paid for > by me), request a route through the new channel, to my counterparty, > and ending with an on-chain hop back to an address I control. This > effectively reverses the direction of the channel, and because I > have money in the channel, my counterparty can add the tx fees for > the on-chain hop to the routing fees he would charge for this onion > route, paid for from my initially sending-direction channel. > > So I think, basically, that allowing onion routes to start and end > on-chain is an elegant way to modify channel states to what we want, > while ensuring that everyone is reasonably protected from bad actors > on the LN. > > Of course, there is some risk. If I make a request to make a route > to a node, and have that route end up to, say,1.0 BTC to an on-chain > public key I control, and that node accepts, I know that node has at > least 1.0 BTC in spare funds, and I might use this information to > assess if I want to hack that node's operator's computer.
Well, at the latest when the channel is being funded you'd see that information anyway. Also he could fund only part of the amount you provided and instead give you a partial refund if it can't afford to open a channel with the capacity you requested (though we may have to tweak the script of the on-chain tx to ensure the refund has precedence).
As mentioned above, the ability to treat on-chain payments like any other lightning channel transfer is very nice. It allows us to treat the on-chain payments identically to off-chain payments (with the caveat of confirmation times), so we can extend all our Lightning schemes with on-chain hops :-)
Cheers, Christian