routing: use Identifier in place of PaymentHash

Since we want to support AMP payment using a different unique payment
identifier (AMP payments don't go to one specific hash), we change the
nomenclature to be Identifier instead of PaymentHash.
This commit is contained in:
Johan T. Halseth
2021-03-31 12:23:08 +02:00
parent 6104d12cf8
commit f07c9d002c
17 changed files with 296 additions and 245 deletions

View File

@@ -79,26 +79,26 @@ func TestControlTowerSubscribeSuccess(t *testing.T) {
t.Fatal(err)
}
err = pControl.InitPayment(info.PaymentHash, info)
err = pControl.InitPayment(info.PaymentIdentifier, info)
if err != nil {
t.Fatal(err)
}
// Subscription should succeed and immediately report the InFlight
// status.
subscriber1, err := pControl.SubscribePayment(info.PaymentHash)
subscriber1, err := pControl.SubscribePayment(info.PaymentIdentifier)
if err != nil {
t.Fatalf("expected subscribe to succeed, but got: %v", err)
}
// Register an attempt.
err = pControl.RegisterAttempt(info.PaymentHash, attempt)
err = pControl.RegisterAttempt(info.PaymentIdentifier, attempt)
if err != nil {
t.Fatal(err)
}
// Register a second subscriber after the first attempt has started.
subscriber2, err := pControl.SubscribePayment(info.PaymentHash)
subscriber2, err := pControl.SubscribePayment(info.PaymentIdentifier)
if err != nil {
t.Fatalf("expected subscribe to succeed, but got: %v", err)
}
@@ -108,7 +108,7 @@ func TestControlTowerSubscribeSuccess(t *testing.T) {
Preimage: preimg,
}
htlcAttempt, err := pControl.SettleAttempt(
info.PaymentHash, attempt.AttemptID, &settleInfo,
info.PaymentIdentifier, attempt.AttemptID, &settleInfo,
)
if err != nil {
t.Fatal(err)
@@ -118,7 +118,7 @@ func TestControlTowerSubscribeSuccess(t *testing.T) {
}
// Register a third subscriber after the payment succeeded.
subscriber3, err := pControl.SubscribePayment(info.PaymentHash)
subscriber3, err := pControl.SubscribePayment(info.PaymentIdentifier)
if err != nil {
t.Fatalf("expected subscribe to succeed, but got: %v", err)
}
@@ -196,13 +196,13 @@ func testPaymentControlSubscribeFail(t *testing.T, registerAttempt bool) {
t.Fatal(err)
}
err = pControl.InitPayment(info.PaymentHash, info)
err = pControl.InitPayment(info.PaymentIdentifier, info)
if err != nil {
t.Fatal(err)
}
// Subscription should succeed.
subscriber1, err := pControl.SubscribePayment(info.PaymentHash)
subscriber1, err := pControl.SubscribePayment(info.PaymentIdentifier)
if err != nil {
t.Fatalf("expected subscribe to succeed, but got: %v", err)
}
@@ -212,7 +212,7 @@ func testPaymentControlSubscribeFail(t *testing.T, registerAttempt bool) {
// making any attempts at all.
if registerAttempt {
// Register an attempt.
err = pControl.RegisterAttempt(info.PaymentHash, attempt)
err = pControl.RegisterAttempt(info.PaymentIdentifier, attempt)
if err != nil {
t.Fatal(err)
}
@@ -222,7 +222,7 @@ func testPaymentControlSubscribeFail(t *testing.T, registerAttempt bool) {
Reason: channeldb.HTLCFailInternal,
}
htlcAttempt, err := pControl.FailAttempt(
info.PaymentHash, attempt.AttemptID, &failInfo,
info.PaymentIdentifier, attempt.AttemptID, &failInfo,
)
if err != nil {
t.Fatalf("unable to fail htlc: %v", err)
@@ -233,12 +233,12 @@ func testPaymentControlSubscribeFail(t *testing.T, registerAttempt bool) {
}
// Mark the payment as failed.
if err := pControl.Fail(info.PaymentHash, channeldb.FailureReasonTimeout); err != nil {
if err := pControl.Fail(info.PaymentIdentifier, channeldb.FailureReasonTimeout); err != nil {
t.Fatal(err)
}
// Register a second subscriber after the payment failed.
subscriber2, err := pControl.SubscribePayment(info.PaymentHash)
subscriber2, err := pControl.SubscribePayment(info.PaymentIdentifier)
if err != nil {
t.Fatalf("expected subscribe to succeed, but got: %v", err)
}
@@ -326,10 +326,10 @@ func genInfo() (*channeldb.PaymentCreationInfo, *channeldb.HTLCAttemptInfo,
rhash := sha256.Sum256(preimage[:])
return &channeldb.PaymentCreationInfo{
PaymentHash: rhash,
Value: testRoute.ReceiverAmt(),
CreationTime: time.Unix(time.Now().Unix(), 0),
PaymentRequest: []byte("hola"),
PaymentIdentifier: rhash,
Value: testRoute.ReceiverAmt(),
CreationTime: time.Unix(time.Now().Unix(), 0),
PaymentRequest: []byte("hola"),
},
&channeldb.HTLCAttemptInfo{
AttemptID: 1,

View File

@@ -152,6 +152,11 @@ func (c *integratedRoutingContext) testPayment(maxParts uint32,
MaxParts: maxParts,
}
var paymentHash [32]byte
if err := payment.SetPaymentHash(paymentHash); err != nil {
return nil, err
}
if c.maxShardAmt != nil {
payment.MaxShardAmt = c.maxShardAmt
}

View File

@@ -24,7 +24,7 @@ type paymentLifecycle struct {
router *ChannelRouter
totalAmount lnwire.MilliSatoshi
feeLimit lnwire.MilliSatoshi
paymentHash lntypes.Hash
identifier lntypes.Hash
paySession PaymentSession
shardTracker shards.ShardTracker
timeoutChan <-chan time.Time
@@ -86,7 +86,7 @@ func (p *paymentLifecycle) paymentState(payment *channeldb.MPPayment) (
func (p *paymentLifecycle) resumePayment() ([32]byte, *route.Route, error) {
shardHandler := &shardHandler{
router: p.router,
paymentHash: p.paymentHash,
identifier: p.identifier,
shardTracker: p.shardTracker,
shardErrors: make(chan error),
quit: make(chan struct{}),
@@ -101,7 +101,7 @@ func (p *paymentLifecycle) resumePayment() ([32]byte, *route.Route, error) {
// up goroutines that'll collect their results and deliver them to the
// lifecycle loop below.
payment, err := p.router.cfg.Control.FetchPayment(
p.paymentHash,
p.identifier,
)
if err != nil {
return [32]byte{}, nil, err
@@ -110,8 +110,8 @@ func (p *paymentLifecycle) resumePayment() ([32]byte, *route.Route, error) {
for _, a := range payment.InFlightHTLCs() {
a := a
log.Infof("Resuming payment shard %v for hash %v",
a.AttemptID, p.paymentHash)
log.Infof("Resuming payment shard %v for payment %v",
a.AttemptID, p.identifier)
shardHandler.collectResultAsync(&a.HTLCAttemptInfo)
}
@@ -131,7 +131,7 @@ lifecycle:
// act on the latest available information, whether we are
// resuming an existing payment or just sent a new attempt.
payment, err := p.router.cfg.Control.FetchPayment(
p.paymentHash,
p.identifier,
)
if err != nil {
return [32]byte{}, nil, err
@@ -146,7 +146,7 @@ lifecycle:
log.Debugf("Payment %v in state terminate=%v, "+
"active_shards=%v, rem_value=%v, fee_limit=%v",
p.paymentHash, state.terminate, state.numShardsInFlight,
p.identifier, state.terminate, state.numShardsInFlight,
state.remainingAmt, state.remainingFees)
switch {
@@ -193,7 +193,7 @@ lifecycle:
// return with an error the moment all active shards
// have finished.
saveErr := p.router.cfg.Control.Fail(
p.paymentHash, channeldb.FailureReasonTimeout,
p.identifier, channeldb.FailureReasonTimeout,
)
if saveErr != nil {
return [32]byte{}, nil, saveErr
@@ -215,7 +215,7 @@ lifecycle:
)
if err != nil {
log.Warnf("Failed to find route for payment %v: %v",
p.paymentHash, err)
p.identifier, err)
routeErr, ok := err.(noRouteError)
if !ok {
@@ -229,10 +229,10 @@ lifecycle:
failureCode := routeErr.FailureReason()
log.Debugf("Marking payment %v permanently "+
"failed with no route: %v",
p.paymentHash, failureCode)
p.identifier, failureCode)
saveErr := p.router.cfg.Control.Fail(
p.paymentHash, failureCode,
p.identifier, failureCode,
)
if saveErr != nil {
return [32]byte{}, nil, saveErr
@@ -261,8 +261,8 @@ lifecycle:
// were pathfinding. We know we're in a terminal state here,
// so we can continue and wait for our last shards to return.
case err == channeldb.ErrPaymentTerminal:
log.Infof("Payment: %v in terminal state, abandoning "+
"shard", p.paymentHash)
log.Infof("Payment %v in terminal state, abandoning "+
"shard", p.identifier)
continue lifecycle
@@ -275,7 +275,7 @@ lifecycle:
if outcome.err != nil {
log.Warnf("Failed to launch shard %v for "+
"payment %v: %v", attempt.AttemptID,
p.paymentHash, outcome.err)
p.identifier, outcome.err)
// We must inspect the error to know whether it was
// critical or not, to decide whether we should
@@ -301,7 +301,7 @@ lifecycle:
// shardHandler holds what is necessary to send and collect the result of
// shards.
type shardHandler struct {
paymentHash lntypes.Hash
identifier lntypes.Hash
router *ChannelRouter
shardTracker shards.ShardTracker
@@ -398,7 +398,7 @@ func (p *shardHandler) launchShard(rt *route.Route,
// of the payment that we attempted to send, such that we can query the
// Switch for its whereabouts. The route is needed to handle the result
// when it eventually comes back.
err = p.router.cfg.Control.RegisterAttempt(p.paymentHash, attempt)
err = p.router.cfg.Control.RegisterAttempt(p.identifier, attempt)
if err != nil {
return nil, nil, err
}
@@ -450,7 +450,7 @@ func (p *shardHandler) collectResultAsync(attempt *channeldb.HTLCAttemptInfo) {
log.Errorf("Error collecting result for "+
"shard %v for payment %v: %v",
attempt.AttemptID, p.paymentHash, err)
attempt.AttemptID, p.identifier, err)
}
select {
@@ -515,7 +515,7 @@ func (p *shardHandler) collectResult(attempt *channeldb.HTLCAttemptInfo) (
// Now ask the switch to return the result of the payment when
// available.
resultChan, err := p.router.cfg.Payer.GetPaymentResult(
attempt.AttemptID, p.paymentHash, errorDecryptor,
attempt.AttemptID, p.identifier, errorDecryptor,
)
switch {
@@ -524,9 +524,9 @@ func (p *shardHandler) collectResult(attempt *channeldb.HTLCAttemptInfo) (
// case we can safely send a new payment attempt, and wait for its
// result to be available.
case err == htlcswitch.ErrPaymentIDNotFound:
log.Debugf("Payment ID %v for hash %v not found in "+
log.Debugf("Attempt ID %v for payment %v not found in "+
"the Switch, retrying.", attempt.AttemptID,
p.paymentHash)
p.identifier)
attempt, cErr := p.failAttempt(attempt, err)
if cErr != nil {
@@ -582,7 +582,7 @@ func (p *shardHandler) collectResult(attempt *channeldb.HTLCAttemptInfo) (
// We successfully got a payment result back from the switch.
log.Debugf("Payment %v succeeded with pid=%v",
p.paymentHash, attempt.AttemptID)
p.identifier, attempt.AttemptID)
// Report success to mission control.
err = p.router.cfg.MissionControl.ReportPaymentSuccess(
@@ -596,7 +596,7 @@ func (p *shardHandler) collectResult(attempt *channeldb.HTLCAttemptInfo) (
// In case of success we atomically store settle result to the DB move
// the shard to the settled state.
htlcAttempt, err := p.router.cfg.Control.SettleAttempt(
p.paymentHash, attempt.AttemptID,
p.identifier, attempt.AttemptID,
&channeldb.HTLCSettleInfo{
Preimage: result.Preimage,
SettleTime: p.router.cfg.Clock.Now(),
@@ -696,7 +696,7 @@ func (p *shardHandler) sendPaymentAttempt(
htlcAdd *lnwire.UpdateAddHTLC) error {
log.Tracef("Attempting to send payment %v (pid=%v), "+
"using route: %v", p.paymentHash, attempt.AttemptID,
"using route: %v", p.identifier, attempt.AttemptID,
newLogClosure(func() string {
return spew.Sdump(attempt.Route)
}),
@@ -712,12 +712,12 @@ func (p *shardHandler) sendPaymentAttempt(
if err != nil {
log.Errorf("Failed sending attempt %d for payment "+
"%v to switch: %v", attempt.AttemptID,
p.paymentHash, err)
p.identifier, err)
return err
}
log.Debugf("Payment %v (pid=%v) successfully sent to switch, route: %v",
p.paymentHash, attempt.AttemptID, &attempt.Route)
p.identifier, attempt.AttemptID, &attempt.Route)
return nil
}
@@ -737,9 +737,9 @@ func (p *shardHandler) handleSendError(attempt *channeldb.HTLCAttemptInfo,
}
log.Infof("Payment %v failed: final_outcome=%v, raw_err=%v",
p.paymentHash, *reason, sendErr)
p.identifier, *reason, sendErr)
err := p.router.cfg.Control.Fail(p.paymentHash, *reason)
err := p.router.cfg.Control.Fail(p.identifier, *reason)
if err != nil {
return err
}
@@ -752,7 +752,7 @@ func (p *shardHandler) failAttempt(attempt *channeldb.HTLCAttemptInfo,
sendError error) (*channeldb.HTLCAttempt, error) {
log.Warnf("Attempt %v for payment %v failed: %v", attempt.AttemptID,
p.paymentHash, sendError)
p.identifier, sendError)
failInfo := marshallError(
sendError,
@@ -767,7 +767,7 @@ func (p *shardHandler) failAttempt(attempt *channeldb.HTLCAttemptInfo,
}
return p.router.cfg.Control.FailAttempt(
p.paymentHash, attempt.AttemptID,
p.identifier, attempt.AttemptID,
failInfo,
)
}

View File

@@ -815,7 +815,7 @@ func testPaymentLifecycle(t *testing.T, test paymentLifecycleTestCase,
Target: testGraph.aliasMap["c"],
Amount: paymentAmt,
FeeLimit: noFeeLimit,
PaymentHash: payHash,
paymentHash: &payHash,
}
// Setup our payment session source to block on release of

View File

@@ -171,7 +171,7 @@ func newPaymentSession(p *LightningPayment,
return nil, err
}
logPrefix := fmt.Sprintf("PaymentSession(%x):", p.PaymentHash)
logPrefix := fmt.Sprintf("PaymentSession(%x):", p.Identifier())
return &paymentSession{
additionalEdges: edges,

View File

@@ -23,6 +23,11 @@ func TestRequestRoute(t *testing.T) {
FeeLimit: 1000,
}
var paymentHash [32]byte
if err := payment.SetPaymentHash(paymentHash); err != nil {
t.Fatal(err)
}
session, err := newPaymentSession(
payment,
func() (map[uint64]lnwire.MilliSatoshi,

View File

@@ -600,7 +600,7 @@ func (r *ChannelRouter) Start() error {
}
for _, payment := range payments {
log.Infof("Resuming payment with hash %v", payment.Info.PaymentHash)
log.Infof("Resuming payment %v", payment.Info.PaymentIdentifier)
r.wg.Add(1)
go func(payment *channeldb.MPPayment) {
defer r.wg.Done()
@@ -613,7 +613,7 @@ func (r *ChannelRouter) Start() error {
// We check whether the individual attempts
// have their HTLC hash set, if not we'll fall
// back to the overall payment hash.
hash := payment.Info.PaymentHash
hash := payment.Info.PaymentIdentifier
if a.Hash != nil {
hash = *a.Hash
}
@@ -631,30 +631,32 @@ func (r *ChannelRouter) Start() error {
// we don't currently persist the root share necessary
// to re-derive them.
shardTracker := shards.NewSimpleShardTracker(
payment.Info.PaymentHash, htlcs,
payment.Info.PaymentIdentifier, htlcs,
)
// We create a dummy, empty payment session such that
// we won't make another payment attempt when the
// result for the in-flight attempt is received.
paySession := r.cfg.SessionSource.NewPaymentSessionEmpty()
// We pass in a zero timeout value, to indicate we
// don't need it to timeout. It will stop immediately
// after the existing attempt has finished anyway. We
// also set a zero fee limit, as no more routes should
// be tried.
_, _, err := r.sendPayment(
payment.Info.Value, 0, payment.Info.PaymentHash,
0, paySession, shardTracker,
payment.Info.Value, 0,
payment.Info.PaymentIdentifier, 0, paySession,
shardTracker,
)
if err != nil {
log.Errorf("Resuming payment with hash %v "+
"failed: %v.", payment.Info.PaymentHash, err)
log.Errorf("Resuming payment %v failed: %v.",
payment.Info.PaymentIdentifier, err)
return
}
log.Infof("Resumed payment with hash %v completed.",
payment.Info.PaymentHash)
log.Infof("Resumed payment %v completed.",
payment.Info.PaymentIdentifier)
}(payment)
}
@@ -1719,9 +1721,9 @@ type LightningPayment struct {
// complete this payment.
CltvLimit uint32
// PaymentHash is the r-hash value to use within the HTLC extended to
// the first hop.
PaymentHash [32]byte
// paymentHash is the r-hash value to use within the HTLC extended to
// the first hop. This won't be set for AMP payments.
paymentHash *lntypes.Hash
// amp is an optional field that is set if and only if this is am AMP
// payment.
@@ -1801,6 +1803,20 @@ type AMPOptions struct {
RootShare [32]byte
}
// SetPaymentHash sets the given hash as the payment's overall hash. This
// should only be used for non-AMP payments.
func (l *LightningPayment) SetPaymentHash(hash lntypes.Hash) error {
l.paymentHash = &hash
return nil
}
// Identifier returns a 32-byte slice that uniquely identifies this single
// payment. For non-AMP payments this will be the payment hash, for AMP
// payments this will be the used SetID.
func (l *LightningPayment) Identifier() [32]byte {
return *l.paymentHash
}
// SendPayment attempts to send a payment as described within the passed
// LightningPayment. This function is blocking and will return either: when the
// payment is successful, or all candidates routes have been attempted and
@@ -1822,7 +1838,7 @@ func (r *ChannelRouter) SendPayment(payment *LightningPayment) ([32]byte,
// Since this is the first time this payment is being made, we pass nil
// for the existing attempt.
return r.sendPayment(
payment.Amount, payment.FeeLimit, payment.PaymentHash,
payment.Amount, payment.FeeLimit, payment.Identifier(),
payment.PayAttemptTimeout, paySession, shardTracker,
)
}
@@ -1845,12 +1861,12 @@ func (r *ChannelRouter) SendPaymentAsync(payment *LightningPayment) error {
spewPayment(payment))
_, _, err := r.sendPayment(
payment.Amount, payment.FeeLimit, payment.PaymentHash,
payment.Amount, payment.FeeLimit, payment.Identifier(),
payment.PayAttemptTimeout, paySession, shardTracker,
)
if err != nil {
log.Errorf("Payment with hash %x failed: %v",
payment.PaymentHash, err)
log.Errorf("Payment %x failed: %v",
payment.Identifier(), err)
}
}()
@@ -1897,10 +1913,10 @@ func (r *ChannelRouter) preparePayment(payment *LightningPayment) (
//
// TODO(roasbeef): store records as part of creation info?
info := &channeldb.PaymentCreationInfo{
PaymentHash: payment.PaymentHash,
Value: payment.Amount,
CreationTime: r.cfg.Clock.Now(),
PaymentRequest: payment.PaymentRequest,
PaymentIdentifier: payment.Identifier(),
Value: payment.Amount,
CreationTime: r.cfg.Clock.Now(),
PaymentRequest: payment.PaymentRequest,
}
// Create a new ShardTracker that we'll use during the life cycle of
@@ -1919,11 +1935,11 @@ func (r *ChannelRouter) preparePayment(payment *LightningPayment) (
// the same payment hash.
default:
shardTracker = shards.NewSimpleShardTracker(
payment.PaymentHash, nil,
payment.Identifier(), nil,
)
}
err = r.cfg.Control.InitPayment(payment.PaymentHash, info)
err = r.cfg.Control.InitPayment(payment.Identifier(), info)
if err != nil {
return nil, nil, err
}
@@ -1936,7 +1952,7 @@ func (r *ChannelRouter) preparePayment(payment *LightningPayment) (
// information as it is stored in the database. For a successful htlc, this
// information will contain the preimage. If an error occurs after the attempt
// was initiated, both return values will be non-nil.
func (r *ChannelRouter) SendToRoute(hash lntypes.Hash, rt *route.Route) (
func (r *ChannelRouter) SendToRoute(htlcHash lntypes.Hash, rt *route.Route) (
*channeldb.HTLCAttempt, error) {
// Calculate amount paid to receiver.
@@ -1950,16 +1966,20 @@ func (r *ChannelRouter) SendToRoute(hash lntypes.Hash, rt *route.Route) (
amt = mpp.TotalMsat()
}
// For non-AMP payments the overall payment identifier will be the same
// hash as used for this HTLC.
paymentIdentifier := htlcHash
// Record this payment hash with the ControlTower, ensuring it is not
// already in-flight.
info := &channeldb.PaymentCreationInfo{
PaymentHash: hash,
Value: amt,
CreationTime: r.cfg.Clock.Now(),
PaymentRequest: nil,
PaymentIdentifier: paymentIdentifier,
Value: amt,
CreationTime: r.cfg.Clock.Now(),
PaymentRequest: nil,
}
err := r.cfg.Control.InitPayment(hash, info)
err := r.cfg.Control.InitPayment(paymentIdentifier, info)
switch {
// If this is an MPP attempt and the hash is already registered with
// the database, we can go on to launch the shard.
@@ -1970,8 +1990,8 @@ func (r *ChannelRouter) SendToRoute(hash lntypes.Hash, rt *route.Route) (
return nil, err
}
log.Tracef("Dispatching SendToRoute for hash %v: %v",
hash, newLogClosure(func() string {
log.Tracef("Dispatching SendToRoute for HTLC hash %v: %v",
htlcHash, newLogClosure(func() string {
return spew.Sdump(rt)
}),
)
@@ -1981,12 +2001,12 @@ func (r *ChannelRouter) SendToRoute(hash lntypes.Hash, rt *route.Route) (
// a ShardTracker that can generate hashes for AMP payments. Instead we
// create a simple tracker that can just return the hash for the single
// shard we'll now launch.
shardTracker := shards.NewSimpleShardTracker(hash, nil)
shardTracker := shards.NewSimpleShardTracker(htlcHash, nil)
// Launch a shard along the given route.
sh := &shardHandler{
router: r,
paymentHash: hash,
identifier: paymentIdentifier,
shardTracker: shardTracker,
}
@@ -1999,10 +2019,10 @@ func (r *ChannelRouter) SendToRoute(hash lntypes.Hash, rt *route.Route) (
err == sphinx.ErrMaxRoutingInfoSizeExceeded {
log.Debugf("Invalid route provided for payment %x: %v",
hash, err)
paymentIdentifier, err)
controlErr := r.cfg.Control.Fail(
hash, channeldb.FailureReasonError,
paymentIdentifier, channeldb.FailureReasonError,
)
if controlErr != nil {
return nil, controlErr
@@ -2050,7 +2070,7 @@ func (r *ChannelRouter) SendToRoute(hash lntypes.Hash, rt *route.Route) (
reason = &r
}
err = r.cfg.Control.Fail(hash, *reason)
err = r.cfg.Control.Fail(paymentIdentifier, *reason)
if err != nil {
return nil, err
}
@@ -2075,7 +2095,7 @@ func (r *ChannelRouter) SendToRoute(hash lntypes.Hash, rt *route.Route) (
// router will call this method for every payment still in-flight according to
// the ControlTower.
func (r *ChannelRouter) sendPayment(
totalAmt, feeLimit lnwire.MilliSatoshi, paymentHash lntypes.Hash,
totalAmt, feeLimit lnwire.MilliSatoshi, identifier lntypes.Hash,
timeout time.Duration, paySession PaymentSession,
shardTracker shards.ShardTracker) ([32]byte, *route.Route, error) {
@@ -2092,7 +2112,7 @@ func (r *ChannelRouter) sendPayment(
router: r,
totalAmount: totalAmt,
feeLimit: feeLimit,
paymentHash: paymentHash,
identifier: identifier,
paySession: paySession,
shardTracker: shardTracker,
currentHeight: currentHeight,

View File

@@ -275,13 +275,13 @@ func TestSendPaymentRouteFailureFallback(t *testing.T) {
// Craft a LightningPayment struct that'll send a payment from roasbeef
// to luo ji for 1000 satoshis, with a maximum of 1000 satoshis in fees.
var payHash [32]byte
var payHash lntypes.Hash
paymentAmt := lnwire.NewMSatFromSatoshis(1000)
payment := LightningPayment{
Target: ctx.aliases["sophon"],
Amount: paymentAmt,
FeeLimit: noFeeLimit,
PaymentHash: payHash,
paymentHash: &payHash,
}
var preImage [32]byte
@@ -510,13 +510,13 @@ func TestSendPaymentErrorRepeatedFeeInsufficient(t *testing.T) {
// Craft a LightningPayment struct that'll send a payment from roasbeef
// to luo ji for 100 satoshis.
var payHash [32]byte
var payHash lntypes.Hash
amt := lnwire.NewMSatFromSatoshis(1000)
payment := LightningPayment{
Target: ctx.aliases["sophon"],
Amount: amt,
FeeLimit: noFeeLimit,
PaymentHash: payHash,
paymentHash: &payHash,
}
var preImage [32]byte
@@ -611,13 +611,13 @@ func TestSendPaymentErrorNonFinalTimeLockErrors(t *testing.T) {
// Craft a LightningPayment struct that'll send a payment from roasbeef
// to sophon for 1k satoshis.
var payHash [32]byte
var payHash lntypes.Hash
amt := lnwire.NewMSatFromSatoshis(1000)
payment := LightningPayment{
Target: ctx.aliases["sophon"],
Amount: amt,
FeeLimit: noFeeLimit,
PaymentHash: payHash,
paymentHash: &payHash,
}
var preImage [32]byte
@@ -720,7 +720,7 @@ func TestSendPaymentErrorNonFinalTimeLockErrors(t *testing.T) {
// Once again, Roasbeef should route around Goku since they disagree
// w.r.t to the block height, and instead go through Pham Nuwen. We
// flip a bit in the payment hash to allow resending this payment.
payment.PaymentHash[1] ^= 1
payment.paymentHash[1] ^= 1
paymentPreImage, rt, err = ctx.router.SendPayment(&payment)
if err != nil {
t.Fatalf("unable to send payment: %v", err)
@@ -744,13 +744,13 @@ func TestSendPaymentErrorPathPruning(t *testing.T) {
// Craft a LightningPayment struct that'll send a payment from roasbeef
// to luo ji for 1000 satoshis, with a maximum of 1000 satoshis in fees.
var payHash [32]byte
var payHash lntypes.Hash
paymentAmt := lnwire.NewMSatFromSatoshis(1000)
payment := LightningPayment{
Target: ctx.aliases["sophon"],
Amount: paymentAmt,
FeeLimit: noFeeLimit,
PaymentHash: payHash,
paymentHash: &payHash,
}
var preImage [32]byte
@@ -887,7 +887,7 @@ func TestSendPaymentErrorPathPruning(t *testing.T) {
})
// We flip a bit in the payment hash to allow resending this payment.
payment.PaymentHash[1] ^= 1
payment.paymentHash[1] ^= 1
paymentPreImage, rt, err = ctx.router.SendPayment(&payment)
if err != nil {
t.Fatalf("unable to send payment: %v", err)
@@ -2565,11 +2565,12 @@ func TestUnknownErrorSource(t *testing.T) {
}
// Create a payment to node c.
var payHash lntypes.Hash
payment := LightningPayment{
Target: ctx.aliases["c"],
Amount: lnwire.NewMSatFromSatoshis(1000),
FeeLimit: noFeeLimit,
PaymentHash: lntypes.Hash{},
paymentHash: &payHash,
}
// We'll modify the SendToSwitch method so that it simulates hop b as a
@@ -2616,7 +2617,8 @@ func TestUnknownErrorSource(t *testing.T) {
// Send off the payment request to the router. We expect the payment to
// fail because both routes have been pruned.
payment.PaymentHash = lntypes.Hash{1}
payHash = lntypes.Hash{1}
payment.paymentHash = &payHash
_, _, err = ctx.router.SendPayment(&payment)
if err == nil {
t.Fatalf("expected payment to fail")