Merge pull request #1246 from wpaulino/bump-ltc-limits

config: increase max funding and payment amount 60x under Litecoin
This commit is contained in:
Olaoluwa Osuntokun 2018-05-25 19:33:04 -07:00 committed by GitHub
commit fa5c0b9ee7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 99 additions and 67 deletions

@ -44,6 +44,10 @@ const (
defaultLitecoinTimeLockDelta = 576 defaultLitecoinTimeLockDelta = 576
defaultLitecoinStaticFeeRate = lnwallet.SatPerVByte(200) defaultLitecoinStaticFeeRate = lnwallet.SatPerVByte(200)
defaultLitecoinDustLimit = btcutil.Amount(54600) defaultLitecoinDustLimit = btcutil.Amount(54600)
// btcToLtcConversionRate is a fixed ratio used in order to scale up
// payments when running on the Litecoin chain.
btcToLtcConversionRate = 60
) )
// defaultBtcChannelConstraints is the default set of channel constraints that are // defaultBtcChannelConstraints is the default set of channel constraints that are

@ -353,42 +353,6 @@ func loadConfig() (*config, error) {
cfg.BitcoindMode.Dir = cleanAndExpandPath(cfg.BitcoindMode.Dir) cfg.BitcoindMode.Dir = cleanAndExpandPath(cfg.BitcoindMode.Dir)
cfg.LitecoindMode.Dir = cleanAndExpandPath(cfg.LitecoindMode.Dir) cfg.LitecoindMode.Dir = cleanAndExpandPath(cfg.LitecoindMode.Dir)
// Ensure that the user didn't attempt to specify negative values for
// any of the autopilot params.
if cfg.Autopilot.MaxChannels < 0 {
str := "%s: autopilot.maxchannels must be non-negative"
err := fmt.Errorf(str, funcName)
fmt.Fprintln(os.Stderr, err)
return nil, err
}
if cfg.Autopilot.Allocation < 0 {
str := "%s: autopilot.allocation must be non-negative"
err := fmt.Errorf(str, funcName)
fmt.Fprintln(os.Stderr, err)
return nil, err
}
if cfg.Autopilot.MinChannelSize < 0 {
str := "%s: autopilot.minchansize must be non-negative"
err := fmt.Errorf(str, funcName)
fmt.Fprintln(os.Stderr, err)
return nil, err
}
if cfg.Autopilot.MaxChannelSize < 0 {
str := "%s: autopilot.maxchansize must be non-negative"
err := fmt.Errorf(str, funcName)
fmt.Fprintln(os.Stderr, err)
return nil, err
}
// Ensure that the specified values for the min and max channel size
// don't are within the bounds of the normal chan size constraints.
if cfg.Autopilot.MinChannelSize < int64(minChanFundingSize) {
cfg.Autopilot.MinChannelSize = int64(minChanFundingSize)
}
if cfg.Autopilot.MaxChannelSize > int64(maxFundingAmount) {
cfg.Autopilot.MaxChannelSize = int64(maxFundingAmount)
}
// Setup dial and DNS resolution functions depending on the specified // Setup dial and DNS resolution functions depending on the specified
// options. The default is to use the standard golang "net" package // options. The default is to use the standard golang "net" package
// functions. When Tor's proxy is specified, the dial function is set to // functions. When Tor's proxy is specified, the dial function is set to
@ -533,6 +497,8 @@ func loadConfig() (*config, error) {
// Finally we'll register the litecoin chain as our current // Finally we'll register the litecoin chain as our current
// primary chain. // primary chain.
registeredChains.RegisterPrimaryChain(litecoinChain) registeredChains.RegisterPrimaryChain(litecoinChain)
maxFundingAmount = maxLtcFundingAmount
maxPaymentMSat = maxLtcPaymentMSat
case cfg.Bitcoin.Active: case cfg.Bitcoin.Active:
// Multiple networks can't be selected simultaneously. Count // Multiple networks can't be selected simultaneously. Count
@ -626,6 +592,42 @@ func loadConfig() (*config, error) {
registeredChains.RegisterPrimaryChain(bitcoinChain) registeredChains.RegisterPrimaryChain(bitcoinChain)
} }
// Ensure that the user didn't attempt to specify negative values for
// any of the autopilot params.
if cfg.Autopilot.MaxChannels < 0 {
str := "%s: autopilot.maxchannels must be non-negative"
err := fmt.Errorf(str, funcName)
fmt.Fprintln(os.Stderr, err)
return nil, err
}
if cfg.Autopilot.Allocation < 0 {
str := "%s: autopilot.allocation must be non-negative"
err := fmt.Errorf(str, funcName)
fmt.Fprintln(os.Stderr, err)
return nil, err
}
if cfg.Autopilot.MinChannelSize < 0 {
str := "%s: autopilot.minchansize must be non-negative"
err := fmt.Errorf(str, funcName)
fmt.Fprintln(os.Stderr, err)
return nil, err
}
if cfg.Autopilot.MaxChannelSize < 0 {
str := "%s: autopilot.maxchansize must be non-negative"
err := fmt.Errorf(str, funcName)
fmt.Fprintln(os.Stderr, err)
return nil, err
}
// Ensure that the specified values for the min and max channel size
// don't are within the bounds of the normal chan size constraints.
if cfg.Autopilot.MinChannelSize < int64(minChanFundingSize) {
cfg.Autopilot.MinChannelSize = int64(minChanFundingSize)
}
if cfg.Autopilot.MaxChannelSize > int64(maxFundingAmount) {
cfg.Autopilot.MaxChannelSize = int64(maxFundingAmount)
}
// Validate profile port number. // Validate profile port number.
if cfg.Profile != "" { if cfg.Profile != "" {
profilePort, err := strconv.Atoi(cfg.Profile) profilePort, err := strconv.Atoi(cfg.Profile)

@ -33,15 +33,6 @@ const (
// TODO(roasbeef): tune // TODO(roasbeef): tune
msgBufferSize = 50 msgBufferSize = 50
// maxFundingAmount is a soft-limit of the maximum channel size
// accepted within the Lightning Protocol Currently. This limit is
// currently defined in BOLT-0002, and serves as an initial
// precautionary limit while implementations are battle tested in the
// real world.
//
// TODO(roasbeef): add command line param to modify
maxFundingAmount = btcutil.Amount(1 << 24)
// minBtcRemoteDelay and maxBtcRemoteDelay is the extremes of the // minBtcRemoteDelay and maxBtcRemoteDelay is the extremes of the
// Bitcoin CSV delay we will require the remote to use for its // Bitcoin CSV delay we will require the remote to use for its
// commitment transaction. The actual delay we will require will be // commitment transaction. The actual delay we will require will be
@ -64,6 +55,31 @@ const (
// minChanFundingSize is the smallest channel that we'll allow to be // minChanFundingSize is the smallest channel that we'll allow to be
// created over the RPC interface. // created over the RPC interface.
minChanFundingSize = btcutil.Amount(20000) minChanFundingSize = btcutil.Amount(20000)
// maxBtcFundingAmount is a soft-limit of the maximum channel size
// currently accepted on the Bitcoin chain within the Lightning
// Protocol. This limit is defined in BOLT-0002, and serves as an
// initial precautionary limit while implementations are battle tested
// in the real world.
maxBtcFundingAmount = btcutil.Amount(1<<24) - 1
// maxLtcFundingAmount is a soft-limit of the maximum channel size
// currently accepted on the Litecoin chain within the Lightning
// Protocol.
maxLtcFundingAmount = maxBtcFundingAmount * btcToLtcConversionRate
)
var (
// maxFundingAmount is a soft-limit of the maximum channel size
// currently accepted within the Lightning Protocol. This limit is
// defined in BOLT-0002, and serves as an initial precautionary limit
// while implementations are battle tested in the real world.
//
// At the moment, this value depends on which chain is active. It is set
// to the value under the Bitcoin chain as default.
//
// TODO(roasbeef): add command line param to modify
maxFundingAmount = maxBtcFundingAmount
) )
// reservationWithCtx encapsulates a pending channel reservation. This wrapper // reservationWithCtx encapsulates a pending channel reservation. This wrapper

@ -623,7 +623,7 @@ func testBasicChannelFunding(net *lntest.NetworkHarness, t *harnessTest) {
timeout := time.Duration(time.Second * 5) timeout := time.Duration(time.Second * 5)
ctxb := context.Background() ctxb := context.Background()
chanAmt := maxFundingAmount chanAmt := maxBtcFundingAmount
pushAmt := btcutil.Amount(100000) pushAmt := btcutil.Amount(100000)
// First establish a channel with a capacity of 0.5 BTC between Alice // First establish a channel with a capacity of 0.5 BTC between Alice
@ -688,7 +688,7 @@ func testUpdateChannelPolicy(net *lntest.NetworkHarness, t *harnessTest) {
bobUpdates, bQuit := subscribeGraphNotifications(t, ctxb, net.Bob) bobUpdates, bQuit := subscribeGraphNotifications(t, ctxb, net.Bob)
defer close(bQuit) defer close(bQuit)
chanAmt := maxFundingAmount chanAmt := maxBtcFundingAmount
pushAmt := btcutil.Amount(100000) pushAmt := btcutil.Amount(100000)
// Create a channel Alice->Bob. // Create a channel Alice->Bob.
@ -1057,7 +1057,7 @@ func testOpenChannelAfterReorg(net *lntest.NetworkHarness, t *harnessTest) {
// Create a new channel that requires 1 confs before it's considered // Create a new channel that requires 1 confs before it's considered
// open, then broadcast the funding transaction // open, then broadcast the funding transaction
chanAmt := maxFundingAmount chanAmt := maxBtcFundingAmount
pushAmt := btcutil.Amount(0) pushAmt := btcutil.Amount(0)
ctxt, _ := context.WithTimeout(ctxb, timeout) ctxt, _ := context.WithTimeout(ctxb, timeout)
pendingUpdate, err := net.OpenPendingChannel(ctxt, net.Alice, net.Bob, pendingUpdate, err := net.OpenPendingChannel(ctxt, net.Alice, net.Bob,
@ -1193,7 +1193,7 @@ func testDisconnectingTargetPeer(net *lntest.NetworkHarness, t *harnessTest) {
// Check existing connection. // Check existing connection.
assertNumConnections(ctxb, t, net.Alice, net.Bob, 1) assertNumConnections(ctxb, t, net.Alice, net.Bob, 1)
chanAmt := maxFundingAmount chanAmt := maxBtcFundingAmount
pushAmt := btcutil.Amount(0) pushAmt := btcutil.Amount(0)
timeout := time.Duration(time.Second * 10) timeout := time.Duration(time.Second * 10)
@ -1329,7 +1329,7 @@ func testDisconnectingTargetPeer(net *lntest.NetworkHarness, t *harnessTest) {
func testChannelFundingPersistence(net *lntest.NetworkHarness, t *harnessTest) { func testChannelFundingPersistence(net *lntest.NetworkHarness, t *harnessTest) {
ctxb := context.Background() ctxb := context.Background()
chanAmt := maxFundingAmount chanAmt := maxBtcFundingAmount
pushAmt := btcutil.Amount(0) pushAmt := btcutil.Amount(0)
timeout := time.Duration(time.Second * 10) timeout := time.Duration(time.Second * 10)
@ -1463,7 +1463,7 @@ func testChannelBalance(net *lntest.NetworkHarness, t *harnessTest) {
// Open a channel with 0.16 BTC between Alice and Bob, ensuring the // Open a channel with 0.16 BTC between Alice and Bob, ensuring the
// channel has been opened properly. // channel has been opened properly.
amount := maxFundingAmount amount := maxBtcFundingAmount
ctx, _ := context.WithTimeout(context.Background(), timeout) ctx, _ := context.WithTimeout(context.Background(), timeout)
// Creates a helper closure to be used below which asserts the proper // Creates a helper closure to be used below which asserts the proper
@ -3848,7 +3848,7 @@ func testBasicChannelCreation(net *lntest.NetworkHarness, t *harnessTest) {
const ( const (
numChannels = 2 numChannels = 2
timeout = time.Duration(time.Second * 5) timeout = time.Duration(time.Second * 5)
amount = maxFundingAmount amount = maxBtcFundingAmount
) )
// Open the channel between Alice and Bob, asserting that the // Open the channel between Alice and Bob, asserting that the
@ -3874,7 +3874,7 @@ func testBasicChannelCreation(net *lntest.NetworkHarness, t *harnessTest) {
// exists and works properly. // exists and works properly.
func testMaxPendingChannels(net *lntest.NetworkHarness, t *harnessTest) { func testMaxPendingChannels(net *lntest.NetworkHarness, t *harnessTest) {
maxPendingChannels := defaultMaxPendingChannels + 1 maxPendingChannels := defaultMaxPendingChannels + 1
amount := maxFundingAmount amount := maxBtcFundingAmount
timeout := time.Duration(time.Second * 10) timeout := time.Duration(time.Second * 10)
ctx, _ := context.WithTimeout(context.Background(), timeout) ctx, _ := context.WithTimeout(context.Background(), timeout)
@ -4253,7 +4253,7 @@ func testRevokedCloseRetribution(net *lntest.NetworkHarness, t *harnessTest) {
ctxb := context.Background() ctxb := context.Background()
const ( const (
timeout = time.Duration(time.Second * 10) timeout = time.Duration(time.Second * 10)
chanAmt = maxFundingAmount chanAmt = maxBtcFundingAmount
paymentAmt = 10000 paymentAmt = 10000
numInvoices = 6 numInvoices = 6
) )
@ -4499,7 +4499,7 @@ func testRevokedCloseRetributionZeroValueRemoteOutput(net *lntest.NetworkHarness
ctxb := context.Background() ctxb := context.Background()
const ( const (
timeout = time.Duration(time.Second * 10) timeout = time.Duration(time.Second * 10)
chanAmt = maxFundingAmount chanAmt = maxBtcFundingAmount
paymentAmt = 10000 paymentAmt = 10000
numInvoices = 6 numInvoices = 6
) )
@ -4731,7 +4731,7 @@ func testRevokedCloseRetributionRemoteHodl(net *lntest.NetworkHarness,
ctxb := context.Background() ctxb := context.Background()
const ( const (
timeout = time.Duration(time.Second * 10) timeout = time.Duration(time.Second * 10)
chanAmt = maxFundingAmount chanAmt = maxBtcFundingAmount
pushAmt = 200000 pushAmt = 200000
paymentAmt = 10000 paymentAmt = 10000
numInvoices = 6 numInvoices = 6
@ -4768,7 +4768,7 @@ func testRevokedCloseRetributionRemoteHodl(net *lntest.NetworkHarness,
// In order to test Dave's response to an uncooperative channel closure // In order to test Dave's response to an uncooperative channel closure
// by Carol, we'll first open up a channel between them with a // by Carol, we'll first open up a channel between them with a
// maxFundingAmount (2^24) satoshis value. // maxBtcFundingAmount (2^24) satoshis value.
ctxt, _ := context.WithTimeout(ctxb, timeout) ctxt, _ := context.WithTimeout(ctxb, timeout)
chanPoint := openChannelAndAssert( chanPoint := openChannelAndAssert(
ctxt, t, net, dave, carol, chanAmt, pushAmt, false, ctxt, t, net, dave, carol, chanAmt, pushAmt, false,
@ -5163,7 +5163,7 @@ func testHtlcErrorPropagation(net *lntest.NetworkHarness, t *harnessTest) {
timeout := time.Duration(time.Second * 15) timeout := time.Duration(time.Second * 15)
ctxb := context.Background() ctxb := context.Background()
const chanAmt = maxFundingAmount const chanAmt = maxBtcFundingAmount
// First establish a channel with a capacity of 0.5 BTC between Alice // First establish a channel with a capacity of 0.5 BTC between Alice
// and Bob. // and Bob.
@ -5212,7 +5212,7 @@ func testHtlcErrorPropagation(net *lntest.NetworkHarness, t *harnessTest) {
t.Fatalf("unable to connect bob to carol: %v", err) t.Fatalf("unable to connect bob to carol: %v", err)
} }
ctxt, _ = context.WithTimeout(ctxb, timeout) ctxt, _ = context.WithTimeout(ctxb, timeout)
const bobChanAmt = maxFundingAmount const bobChanAmt = maxBtcFundingAmount
chanPointBob := openChannelAndAssert( chanPointBob := openChannelAndAssert(
ctxt, t, net, net.Bob, carol, chanAmt, 0, false, ctxt, t, net, net.Bob, carol, chanAmt, 0, false,
) )
@ -5493,7 +5493,7 @@ func subscribeGraphNotifications(t *harnessTest, ctxb context.Context,
} }
func testGraphTopologyNotifications(net *lntest.NetworkHarness, t *harnessTest) { func testGraphTopologyNotifications(net *lntest.NetworkHarness, t *harnessTest) {
const chanAmt = maxFundingAmount const chanAmt = maxBtcFundingAmount
timeout := time.Duration(time.Second * 5) timeout := time.Duration(time.Second * 5)
ctxb := context.Background() ctxb := context.Background()
@ -5777,7 +5777,7 @@ func testNodeSignVerify(net *lntest.NetworkHarness, t *harnessTest) {
timeout := time.Duration(time.Second * 15) timeout := time.Duration(time.Second * 15)
ctxb := context.Background() ctxb := context.Background()
chanAmt := maxFundingAmount chanAmt := maxBtcFundingAmount
pushAmt := btcutil.Amount(100000) pushAmt := btcutil.Amount(100000)
// Create a channel between alice and bob. // Create a channel between alice and bob.

@ -39,7 +39,23 @@ import (
"golang.org/x/net/context" "golang.org/x/net/context"
) )
const (
// maxBtcPaymentMSat is the maximum allowed Bitcoin payment currently
// permitted as defined in BOLT-0002.
maxBtcPaymentMSat = lnwire.MilliSatoshi(math.MaxUint32)
// maxLtcPaymentMSat is the maximum allowed Litecoin payment currently
// permitted.
maxLtcPaymentMSat = lnwire.MilliSatoshi(math.MaxUint32) *
btcToLtcConversionRate
)
var ( var (
// maxPaymentMSat is the maximum allowed payment currently permitted as
// defined in BOLT-002. This value depends on which chain is active.
// It is set to the value under the Bitcoin chain as default.
maxPaymentMSat = maxBtcPaymentMSat
defaultAccount uint32 = waddrmgr.DefaultAccountNum defaultAccount uint32 = waddrmgr.DefaultAccountNum
// readPermissions is a slice of all entities that allow read // readPermissions is a slice of all entities that allow read
@ -300,12 +316,6 @@ var (
} }
) )
const (
// maxPaymentMSat is the maximum allowed payment permitted currently as
// defined in BOLT-0002.
maxPaymentMSat = lnwire.MilliSatoshi(math.MaxUint32)
)
// rpcServer is a gRPC, RPC front end to the lnd daemon. // rpcServer is a gRPC, RPC front end to the lnd daemon.
// TODO(roasbeef): pagination support for the list-style calls // TODO(roasbeef): pagination support for the list-style calls
type rpcServer struct { type rpcServer struct {