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:
5 files changed
+44
-4
No files matched your search
@@ -20,6 +20,17 @@ func testMaxHtlcPathfind(ht *lntest.HarnessTest) {
|
|||||||
maxHtlcs := 5
|
maxHtlcs := 5
|
||||||
|
|
||||||
alice, bob := ht.Alice, ht.Bob
|
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(
|
chanPoint := ht.OpenChannel(
|
||||||
alice, bob, lntest.OpenChannelParams{
|
alice, bob, lntest.OpenChannelParams{
|
||||||
Amt: 1000000,
|
Amt: 1000000,
|
||||||
|
|||||||
@@ -10,9 +10,18 @@ import (
|
|||||||
// The fields with struct tags are meant to be parsed as normal configuration
|
// 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
|
// options, while if able to be populated, the latter fields MUST also be
|
||||||
// specified.
|
// specified.
|
||||||
|
//
|
||||||
|
//nolint:lll
|
||||||
type Config struct {
|
type Config struct {
|
||||||
RoutingConfig
|
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
|
// RouterMacPath is the path for the router macaroon. If unspecified
|
||||||
// then we assume that the macaroon will be found under the network
|
// then we assume that the macaroon will be found under the network
|
||||||
// directory, named DefaultRouterMacFilename.
|
// directory, named DefaultRouterMacFilename.
|
||||||
|
|||||||
@@ -98,6 +98,13 @@ type RouterBackend struct {
|
|||||||
// SetChannelAuto exposes the ability to restore automatic channel state
|
// SetChannelAuto exposes the ability to restore automatic channel state
|
||||||
// management after manually setting channel status.
|
// management after manually setting channel status.
|
||||||
SetChannelAuto func(wire.OutPoint) error
|
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.
|
// MissionControl defines the mission control dependencies of routerrpc.
|
||||||
@@ -1542,7 +1549,9 @@ func (r *RouterBackend) MarshallPayment(payment *channeldb.MPPayment) (
|
|||||||
msatValue := int64(payment.Info.Value)
|
msatValue := int64(payment.Info.Value)
|
||||||
satValue := int64(payment.Info.Value.ToSatoshis())
|
satValue := int64(payment.Info.Value.ToSatoshis())
|
||||||
|
|
||||||
status, err := convertPaymentStatus(payment.Status)
|
status, err := convertPaymentStatus(
|
||||||
|
payment.Status, r.UseStatusInitiated,
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -1589,12 +1598,18 @@ func (r *RouterBackend) MarshallPayment(payment *channeldb.MPPayment) (
|
|||||||
|
|
||||||
// convertPaymentStatus converts a channeldb.PaymentStatus to the type expected
|
// convertPaymentStatus converts a channeldb.PaymentStatus to the type expected
|
||||||
// by the RPC.
|
// by the RPC.
|
||||||
func convertPaymentStatus(dbStatus channeldb.PaymentStatus) (
|
func convertPaymentStatus(dbStatus channeldb.PaymentStatus, useInit bool) (
|
||||||
lnrpc.Payment_PaymentStatus, error) {
|
lnrpc.Payment_PaymentStatus, error) {
|
||||||
|
|
||||||
switch dbStatus {
|
switch dbStatus {
|
||||||
case channeldb.StatusInitiated:
|
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:
|
case channeldb.StatusInFlight:
|
||||||
return lnrpc.Payment_IN_FLIGHT, nil
|
return lnrpc.Payment_IN_FLIGHT, nil
|
||||||
|
|||||||
+2
-1
@@ -715,7 +715,8 @@ func (r *rpcServer) addDeps(s *server, macService *macaroons.Service,
|
|||||||
SetChannelDisabled: func(outpoint wire.OutPoint) error {
|
SetChannelDisabled: func(outpoint wire.OutPoint) error {
|
||||||
return s.chanStatusMgr.RequestDisable(outpoint, true)
|
return s.chanStatusMgr.RequestDisable(outpoint, true)
|
||||||
},
|
},
|
||||||
SetChannelAuto: s.chanStatusMgr.RequestAuto,
|
SetChannelAuto: s.chanStatusMgr.RequestAuto,
|
||||||
|
UseStatusInitiated: subServerCgs.RouterRPC.UseStatusInitiated,
|
||||||
}
|
}
|
||||||
|
|
||||||
genInvoiceFeatures := func() *lnwire.FeatureVector {
|
genInvoiceFeatures := func() *lnwire.FeatureVector {
|
||||||
|
|||||||
@@ -1201,6 +1201,10 @@
|
|||||||
; failures in channels.
|
; failures in channels.
|
||||||
; routerrpc.bimodal.decaytime=168h
|
; 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]
|
[workers]
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user