mirror of
https://github.com/lightninglabs/loop
synced 2024-11-16 00:12:52 +00:00
f559120565
This commit exposes router sub server functionality to loop. This is a preparation for using reliable payments in loop out.
44 lines
1015 B
Go
44 lines
1015 B
Go
package test
|
|
|
|
import (
|
|
"github.com/lightninglabs/loop/lndclient"
|
|
"github.com/lightningnetwork/lnd/lntypes"
|
|
"golang.org/x/net/context"
|
|
)
|
|
|
|
type mockRouter struct {
|
|
lnd *LndMockServices
|
|
}
|
|
|
|
func (r *mockRouter) SendPayment(ctx context.Context,
|
|
request lndclient.SendPaymentRequest) (chan lndclient.PaymentStatus,
|
|
chan error, error) {
|
|
|
|
statusChan := make(chan lndclient.PaymentStatus)
|
|
errorChan := make(chan error)
|
|
|
|
r.lnd.RouterSendPaymentChannel <- RouterPaymentChannelMessage{
|
|
SendPaymentRequest: request,
|
|
TrackPaymentMessage: TrackPaymentMessage{
|
|
Updates: statusChan,
|
|
Errors: errorChan,
|
|
},
|
|
}
|
|
|
|
return statusChan, errorChan, nil
|
|
}
|
|
|
|
func (r *mockRouter) TrackPayment(ctx context.Context,
|
|
hash lntypes.Hash) (chan lndclient.PaymentStatus, chan error, error) {
|
|
|
|
statusChan := make(chan lndclient.PaymentStatus)
|
|
errorChan := make(chan error)
|
|
r.lnd.TrackPaymentChannel <- TrackPaymentMessage{
|
|
Hash: hash,
|
|
Updates: statusChan,
|
|
Errors: errorChan,
|
|
}
|
|
|
|
return statusChan, errorChan, nil
|
|
}
|