diff --git a/htlcswitch/link_test.go b/htlcswitch/link_test.go index 646c6450..ac3a1b12 100644 --- a/htlcswitch/link_test.go +++ b/htlcswitch/link_test.go @@ -1118,7 +1118,7 @@ func TestChannelLinkMultiHopUnknownPaymentHash(t *testing.T) { } resultChan, err := n.aliceServer.htlcSwitch.GetPaymentResult( - pid, newMockDeobfuscator(), + pid, htlc.PaymentHash, newMockDeobfuscator(), ) if err != nil { t.Fatalf("unable to get payment result: %v", err) @@ -3898,7 +3898,7 @@ func TestChannelLinkAcceptDuplicatePayment(t *testing.T) { } resultChan, err := n.aliceServer.htlcSwitch.GetPaymentResult( - pid, newMockDeobfuscator(), + pid, htlc.PaymentHash, newMockDeobfuscator(), ) if err != nil { t.Fatalf("unable to get payment result: %v", err) diff --git a/htlcswitch/switch.go b/htlcswitch/switch.go index 45e2e2db..efbcf608 100644 --- a/htlcswitch/switch.go +++ b/htlcswitch/switch.go @@ -342,7 +342,7 @@ func (s *Switch) ProcessContractResolution(msg contractcourt.ResolutionMsg) erro // result is received on the channel, the HTLC is guaranteed to no longer be in // flight. The switch shutting down is signaled by closing the channel. If the // paymentID is unknown, ErrPaymentIDNotFound will be returned. -func (s *Switch) GetPaymentResult(paymentID uint64, +func (s *Switch) GetPaymentResult(paymentID uint64, paymentHash lntypes.Hash, deobfuscator ErrorDecrypter) (<-chan *PaymentResult, error) { s.pendingMutex.Lock() @@ -375,7 +375,7 @@ func (s *Switch) GetPaymentResult(paymentID uint64, // Extract the result and pass it to the result channel. result, err := s.extractResult( - deobfuscator, n, paymentID, payment.paymentHash, + deobfuscator, n, paymentID, paymentHash, ) if err != nil { e := fmt.Errorf("Unable to extract result: %v", err) diff --git a/htlcswitch/switch_test.go b/htlcswitch/switch_test.go index cd798301..af7c0fca 100644 --- a/htlcswitch/switch_test.go +++ b/htlcswitch/switch_test.go @@ -1743,7 +1743,7 @@ func TestSwitchSendPayment(t *testing.T) { // First check that the switch will correctly respond that this payment // ID is unknown. _, err = s.GetPaymentResult( - paymentID, newMockDeobfuscator(), + paymentID, rhash, newMockDeobfuscator(), ) if err != ErrPaymentIDNotFound { t.Fatalf("expected ErrPaymentIDNotFound, got %v", err) @@ -1761,7 +1761,7 @@ func TestSwitchSendPayment(t *testing.T) { } resultChan, err := s.GetPaymentResult( - paymentID, newMockDeobfuscator(), + paymentID, rhash, newMockDeobfuscator(), ) if err != nil { errChan <- err diff --git a/htlcswitch/test_utils.go b/htlcswitch/test_utils.go index fa8ff886..5ae959bc 100644 --- a/htlcswitch/test_utils.go +++ b/htlcswitch/test_utils.go @@ -801,7 +801,7 @@ func preparePayment(sendingPeer, receivingPeer lnpeer.Peer, return err } resultChan, err := sender.htlcSwitch.GetPaymentResult( - pid, newMockDeobfuscator(), + pid, hash, newMockDeobfuscator(), ) if err != nil { return err @@ -1289,7 +1289,7 @@ func (n *twoHopNetwork) makeHoldPayment(sendingPeer, receivingPeer lnpeer.Peer, } resultChan, err := sender.htlcSwitch.GetPaymentResult( - pid, newMockDeobfuscator(), + pid, rhash, newMockDeobfuscator(), ) if err != nil { paymentErr <- err diff --git a/routing/mock_test.go b/routing/mock_test.go index 600c5587..f2f7de78 100644 --- a/routing/mock_test.go +++ b/routing/mock_test.go @@ -52,7 +52,8 @@ func (m *mockPaymentAttemptDispatcher) SendHTLC(firstHop lnwire.ShortChannelID, } func (m *mockPaymentAttemptDispatcher) GetPaymentResult(paymentID uint64, - _ htlcswitch.ErrorDecrypter) (<-chan *htlcswitch.PaymentResult, error) { + _ lntypes.Hash, _ htlcswitch.ErrorDecrypter) ( + <-chan *htlcswitch.PaymentResult, error) { c := make(chan *htlcswitch.PaymentResult, 1) res, ok := m.results[paymentID] @@ -139,8 +140,8 @@ func (m *mockPayer) SendHTLC(_ lnwire.ShortChannelID, } -func (m *mockPayer) GetPaymentResult(paymentID uint64, _ htlcswitch.ErrorDecrypter) ( - <-chan *htlcswitch.PaymentResult, error) { +func (m *mockPayer) GetPaymentResult(paymentID uint64, _ lntypes.Hash, + _ htlcswitch.ErrorDecrypter) (<-chan *htlcswitch.PaymentResult, error) { select { case res := <-m.paymentResult: diff --git a/routing/payment_lifecycle.go b/routing/payment_lifecycle.go index 46993d2a..3710ff58 100644 --- a/routing/payment_lifecycle.go +++ b/routing/payment_lifecycle.go @@ -95,7 +95,7 @@ func (p *paymentLifecycle) resumePayment() ([32]byte, *route.Route, error) { // Now ask the switch to return the result of the payment when // available. resultChan, err := p.router.cfg.Payer.GetPaymentResult( - p.attempt.PaymentID, errorDecryptor, + p.attempt.PaymentID, p.payment.PaymentHash, errorDecryptor, ) switch { diff --git a/routing/router.go b/routing/router.go index fd0f689a..8bb50742 100644 --- a/routing/router.go +++ b/routing/router.go @@ -138,7 +138,8 @@ type PaymentAttemptDispatcher interface { // HTLC is guaranteed to no longer be in flight. The switch shutting // down is signaled by closing the channel. If the paymentID is // unknown, ErrPaymentIDNotFound will be returned. - GetPaymentResult(paymentID uint64, deobfuscator htlcswitch.ErrorDecrypter) ( + GetPaymentResult(paymentID uint64, paymentHash lntypes.Hash, + deobfuscator htlcswitch.ErrorDecrypter) ( <-chan *htlcswitch.PaymentResult, error) }