lnd: add support for multi-hop (Sphinx) onion routed payments
This commit adds full support for multi-hop onion routed payments within the daemon. The switch has been greatly extended in order to gain the functionality required to manage Sphinx payment circuits amongst active links. A payment circuit is initiated when a link sends an HTLC add to the downstream htlcSwitch it received from the upstream peer. The switch then examines the parsed sphinx packet to set up the clear/settle ends of the circuit. Created circuits can be re-used amongst HTLC payments which share the same RHash. All bandwidth updates within a link’s internal state are now managed with atomic increments/decrements in order to avoid race conditions amongst the two goroutines the switch currently uses. Each channel’s htlcManager has also been extended to parse out the next-hop contained within Sphinx packets, and construct a proper htlcPkt such that the htlcSwitch can initiate then manage the payment circuit.
This commit is contained in:
3 files changed
+330
-83
No files matched your search
+1
-1
@@ -110,7 +110,7 @@ func (i *invoiceRegistry) LookupInvoice(rHash wire.ShaHash) (*channeldb.Invoice,
|
||||
// dbueg invoice, then this method is a nooop as debug invoices are never fully
|
||||
// settled.
|
||||
func (i *invoiceRegistry) SettleInvoice(rHash wire.ShaHash) error {
|
||||
ltndLog.Debugf("Setting invoice %x", rHash[:])
|
||||
ltndLog.Debugf("Settling invoice %x", rHash[:])
|
||||
|
||||
// First check the in-memory debug invoice index to see if this is an
|
||||
// existing invoice added for debugging.
|
||||
|
||||
Reference in new issue
Block a user