mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-07-12 14:12:27 +02:00
multi: add new config usestatusinitiated
for the new payment status
This commit adds a new config value to signal that the user understands the new payment status `StatusInitiated`.
This commit is contained in:
@ -20,6 +20,17 @@ func testMaxHtlcPathfind(ht *lntest.HarnessTest) {
|
||||
maxHtlcs := 5
|
||||
|
||||
alice, bob := ht.Alice, ht.Bob
|
||||
|
||||
// Restart nodes with the new flag so they understand the new payment
|
||||
// status.
|
||||
ht.RestartNodeWithExtraArgs(alice, []string{
|
||||
"--routerrpc.usestatusinitiated",
|
||||
})
|
||||
ht.RestartNodeWithExtraArgs(bob, []string{
|
||||
"--routerrpc.usestatusinitiated",
|
||||
})
|
||||
|
||||
ht.EnsureConnected(alice, bob)
|
||||
chanPoint := ht.OpenChannel(
|
||||
alice, bob, lntest.OpenChannelParams{
|
||||
Amt: 1000000,
|
||||
|
@ -10,9 +10,18 @@ import (
|
||||
// The fields with struct tags are meant to be parsed as normal configuration
|
||||
// options, while if able to be populated, the latter fields MUST also be
|
||||
// specified.
|
||||
//
|
||||
//nolint:lll
|
||||
type Config struct {
|
||||
RoutingConfig
|
||||
|
||||
// UseStatusInitiated is a boolean that indicates whether the router
|
||||
// should use the new status code `Payment_INITIATED`.
|
||||
//
|
||||
// TODO(yy): remove this config after the new status code is fully
|
||||
// deployed to the network(v0.20.0).
|
||||
UseStatusInitiated bool `long:"usestatusinitiated" description:"If true, the router will send Payment_INITIATED for new payments, otherwise Payment_In_FLIGHT will be sent for compatibility concerns."`
|
||||
|
||||
// RouterMacPath is the path for the router macaroon. If unspecified
|
||||
// then we assume that the macaroon will be found under the network
|
||||
// directory, named DefaultRouterMacFilename.
|
||||
|
@ -98,6 +98,13 @@ type RouterBackend struct {
|
||||
// SetChannelAuto exposes the ability to restore automatic channel state
|
||||
// management after manually setting channel status.
|
||||
SetChannelAuto func(wire.OutPoint) error
|
||||
|
||||
// UseStatusInitiated is a boolean that indicates whether the router
|
||||
// should use the new status code `Payment_INITIATED`.
|
||||
//
|
||||
// TODO(yy): remove this config after the new status code is fully
|
||||
// deployed to the network(v0.20.0).
|
||||
UseStatusInitiated bool
|
||||
}
|
||||
|
||||
// MissionControl defines the mission control dependencies of routerrpc.
|
||||
@ -1542,7 +1549,9 @@ func (r *RouterBackend) MarshallPayment(payment *channeldb.MPPayment) (
|
||||
msatValue := int64(payment.Info.Value)
|
||||
satValue := int64(payment.Info.Value.ToSatoshis())
|
||||
|
||||
status, err := convertPaymentStatus(payment.Status)
|
||||
status, err := convertPaymentStatus(
|
||||
payment.Status, r.UseStatusInitiated,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -1589,12 +1598,18 @@ func (r *RouterBackend) MarshallPayment(payment *channeldb.MPPayment) (
|
||||
|
||||
// convertPaymentStatus converts a channeldb.PaymentStatus to the type expected
|
||||
// by the RPC.
|
||||
func convertPaymentStatus(dbStatus channeldb.PaymentStatus) (
|
||||
func convertPaymentStatus(dbStatus channeldb.PaymentStatus, useInit bool) (
|
||||
lnrpc.Payment_PaymentStatus, error) {
|
||||
|
||||
switch dbStatus {
|
||||
case channeldb.StatusInitiated:
|
||||
return lnrpc.Payment_INITIATED, nil
|
||||
// If the client understands the new status, return it.
|
||||
if useInit {
|
||||
return lnrpc.Payment_INITIATED, nil
|
||||
}
|
||||
|
||||
// Otherwise remain the old behavior.
|
||||
return lnrpc.Payment_IN_FLIGHT, nil
|
||||
|
||||
case channeldb.StatusInFlight:
|
||||
return lnrpc.Payment_IN_FLIGHT, nil
|
||||
|
@ -715,7 +715,8 @@ func (r *rpcServer) addDeps(s *server, macService *macaroons.Service,
|
||||
SetChannelDisabled: func(outpoint wire.OutPoint) error {
|
||||
return s.chanStatusMgr.RequestDisable(outpoint, true)
|
||||
},
|
||||
SetChannelAuto: s.chanStatusMgr.RequestAuto,
|
||||
SetChannelAuto: s.chanStatusMgr.RequestAuto,
|
||||
UseStatusInitiated: subServerCgs.RouterRPC.UseStatusInitiated,
|
||||
}
|
||||
|
||||
genInvoiceFeatures := func() *lnwire.FeatureVector {
|
||||
|
@ -1201,6 +1201,10 @@
|
||||
; failures in channels.
|
||||
; routerrpc.bimodal.decaytime=168h
|
||||
|
||||
; If set, the router will send `Payment_INITIATED` for new payments, otherwise
|
||||
; `Payment_In_FLIGHT` will be sent for compatibility concerns.
|
||||
; routerrpc.usestatusinitiated=false
|
||||
|
||||
|
||||
[workers]
|
||||
|
||||
|
Reference in New Issue
Block a user