mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-06-21 22:32:33 +02:00
lnd+funding: move Manager to funding, change references
This commit is contained in:
parent
e7e872f19a
commit
dcdf36f410
3528
funding/manager.go
3528
funding/manager.go
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
||||
// +build !rpctest
|
||||
|
||||
package lnd
|
||||
package funding
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
@ -27,7 +27,6 @@ import (
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
"github.com/lightningnetwork/lnd/channelnotifier"
|
||||
"github.com/lightningnetwork/lnd/discovery"
|
||||
"github.com/lightningnetwork/lnd/funding"
|
||||
"github.com/lightningnetwork/lnd/htlcswitch"
|
||||
"github.com/lightningnetwork/lnd/input"
|
||||
"github.com/lightningnetwork/lnd/keychain"
|
||||
@ -60,6 +59,10 @@ const (
|
||||
|
||||
// A dummy value to use for the funding broadcast height.
|
||||
fundingBroadcastHeight = 123
|
||||
|
||||
// defaultMaxLocalCSVDelay is the maximum delay we accept on our
|
||||
// commitment output.
|
||||
defaultMaxLocalCSVDelay = 10000
|
||||
)
|
||||
|
||||
var (
|
||||
@ -347,7 +350,7 @@ func createTestFundingManager(t *testing.T, privKey *btcec.PrivateKey,
|
||||
|
||||
chainedAcceptor := chanacceptor.NewChainedAcceptor()
|
||||
|
||||
fundingCfg := fundingConfig{
|
||||
fundingCfg := Config{
|
||||
IDKey: privKey.PubKey(),
|
||||
Wallet: lnw,
|
||||
Notifier: chainNotifier,
|
||||
@ -434,7 +437,7 @@ func createTestFundingManager(t *testing.T, privKey *btcec.PrivateKey,
|
||||
},
|
||||
ZombieSweeperInterval: 1 * time.Hour,
|
||||
ReservationTimeout: 1 * time.Nanosecond,
|
||||
MaxChanSize: funding.MaxBtcFundingAmount,
|
||||
MaxChanSize: MaxBtcFundingAmount,
|
||||
MaxLocalCSVDelay: defaultMaxLocalCSVDelay,
|
||||
MaxPendingChannels: lncfg.DefaultMaxPendingChannels,
|
||||
NotifyOpenChannelEvent: evt.NotifyOpenChannelEvent,
|
||||
@ -492,7 +495,7 @@ func recreateAliceFundingManager(t *testing.T, alice *testNode) {
|
||||
|
||||
chainedAcceptor := chanacceptor.NewChainedAcceptor()
|
||||
|
||||
f, err := NewFundingManager(fundingConfig{
|
||||
f, err := NewFundingManager(Config{
|
||||
IDKey: oldCfg.IDKey,
|
||||
Wallet: oldCfg.Wallet,
|
||||
Notifier: oldCfg.Notifier,
|
||||
@ -557,7 +560,7 @@ func recreateAliceFundingManager(t *testing.T, alice *testNode) {
|
||||
}
|
||||
}
|
||||
|
||||
type cfgOption func(*fundingConfig)
|
||||
type cfgOption func(*Config)
|
||||
|
||||
func setupFundingManagers(t *testing.T,
|
||||
options ...cfgOption) (*testNode, *testNode) {
|
||||
@ -2864,7 +2867,7 @@ func TestFundingManagerMaxPendingChannels(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
alice, bob := setupFundingManagers(
|
||||
t, func(cfg *fundingConfig) {
|
||||
t, func(cfg *Config) {
|
||||
cfg.MaxPendingChannels = maxPending
|
||||
},
|
||||
)
|
||||
@ -3037,7 +3040,7 @@ func TestFundingManagerRejectPush(t *testing.T) {
|
||||
|
||||
// Enable 'rejectpush' option and initialize funding managers.
|
||||
alice, bob := setupFundingManagers(
|
||||
t, func(cfg *fundingConfig) {
|
||||
t, func(cfg *Config) {
|
||||
cfg.RejectPush = true
|
||||
},
|
||||
)
|
||||
@ -3377,10 +3380,10 @@ func TestMaxChannelSizeConfig(t *testing.T) {
|
||||
// Create a set of funding managers that will reject wumbo
|
||||
// channels but set --maxchansize explicitly lower than soft-limit.
|
||||
// Verify that wumbo rejecting funding managers will respect --maxchansize
|
||||
// below 16777215 satoshi (funding.MaxBtcFundingAmount) limit.
|
||||
alice, bob := setupFundingManagers(t, func(cfg *fundingConfig) {
|
||||
// below 16777215 satoshi (MaxBtcFundingAmount) limit.
|
||||
alice, bob := setupFundingManagers(t, func(cfg *Config) {
|
||||
cfg.NoWumboChans = true
|
||||
cfg.MaxChanSize = funding.MaxBtcFundingAmount - 1
|
||||
cfg.MaxChanSize = MaxBtcFundingAmount - 1
|
||||
})
|
||||
|
||||
// Attempt to create a channel above the limit
|
||||
@ -3391,7 +3394,7 @@ func TestMaxChannelSizeConfig(t *testing.T) {
|
||||
Peer: bob,
|
||||
TargetPubkey: bob.privKey.PubKey(),
|
||||
ChainHash: *fundingNetParams.GenesisHash,
|
||||
LocalFundingAmt: funding.MaxBtcFundingAmount,
|
||||
LocalFundingAmt: MaxBtcFundingAmount,
|
||||
PushAmt: lnwire.NewMSatFromSatoshis(0),
|
||||
Private: false,
|
||||
Updates: updateChan,
|
||||
@ -3409,9 +3412,9 @@ func TestMaxChannelSizeConfig(t *testing.T) {
|
||||
// channels but set --maxchansize explicitly higher than soft-limit
|
||||
// A --maxchansize greater than this limit should have no effect.
|
||||
tearDownFundingManagers(t, alice, bob)
|
||||
alice, bob = setupFundingManagers(t, func(cfg *fundingConfig) {
|
||||
alice, bob = setupFundingManagers(t, func(cfg *Config) {
|
||||
cfg.NoWumboChans = true
|
||||
cfg.MaxChanSize = funding.MaxBtcFundingAmount + 1
|
||||
cfg.MaxChanSize = MaxBtcFundingAmount + 1
|
||||
})
|
||||
|
||||
// Reset the Peer to the newly created one.
|
||||
@ -3427,7 +3430,7 @@ func TestMaxChannelSizeConfig(t *testing.T) {
|
||||
// Create the funding managers, this time allowing
|
||||
// wumbo channels but setting --maxchansize explicitly.
|
||||
tearDownFundingManagers(t, alice, bob)
|
||||
alice, bob = setupFundingManagers(t, func(cfg *fundingConfig) {
|
||||
alice, bob = setupFundingManagers(t, func(cfg *Config) {
|
||||
cfg.NoWumboChans = false
|
||||
cfg.MaxChanSize = btcutil.Amount(100000000)
|
||||
})
|
||||
@ -3454,7 +3457,7 @@ func TestWumboChannelConfig(t *testing.T) {
|
||||
|
||||
// First we'll create a set of funding managers that will reject wumbo
|
||||
// channels.
|
||||
alice, bob := setupFundingManagers(t, func(cfg *fundingConfig) {
|
||||
alice, bob := setupFundingManagers(t, func(cfg *Config) {
|
||||
cfg.NoWumboChans = true
|
||||
})
|
||||
|
||||
@ -3467,7 +3470,7 @@ func TestWumboChannelConfig(t *testing.T) {
|
||||
Peer: bob,
|
||||
TargetPubkey: bob.privKey.PubKey(),
|
||||
ChainHash: *fundingNetParams.GenesisHash,
|
||||
LocalFundingAmt: funding.MaxBtcFundingAmount,
|
||||
LocalFundingAmt: MaxBtcFundingAmount,
|
||||
PushAmt: lnwire.NewMSatFromSatoshis(0),
|
||||
Private: false,
|
||||
Updates: updateChan,
|
||||
@ -3494,9 +3497,9 @@ func TestWumboChannelConfig(t *testing.T) {
|
||||
// Next, we'll re-create the funding managers, but this time allowing
|
||||
// wumbo channels explicitly.
|
||||
tearDownFundingManagers(t, alice, bob)
|
||||
alice, bob = setupFundingManagers(t, func(cfg *fundingConfig) {
|
||||
alice, bob = setupFundingManagers(t, func(cfg *Config) {
|
||||
cfg.NoWumboChans = false
|
||||
cfg.MaxChanSize = funding.MaxBtcFundingAmountWumbo
|
||||
cfg.MaxChanSize = MaxBtcFundingAmountWumbo
|
||||
})
|
||||
|
||||
// Reset the Peer to the newly created one.
|
3540
fundingmanager.go
3540
fundingmanager.go
File diff suppressed because it is too large
Load Diff
1
log.go
1
log.go
@ -82,7 +82,6 @@ var (
|
||||
ltndLog = addLndPkgLogger("LTND")
|
||||
rpcsLog = addLndPkgLogger("RPCS")
|
||||
srvrLog = addLndPkgLogger("SRVR")
|
||||
fndgLog = addLndPkgLogger("FNDG")
|
||||
utxnLog = addLndPkgLogger("UTXN")
|
||||
brarLog = addLndPkgLogger("BRAR")
|
||||
atplLog = addLndPkgLogger("ATPL")
|
||||
|
3
pilot.go
3
pilot.go
@ -10,6 +10,7 @@ import (
|
||||
"github.com/btcsuite/btcutil"
|
||||
"github.com/lightningnetwork/lnd/autopilot"
|
||||
"github.com/lightningnetwork/lnd/chainreg"
|
||||
"github.com/lightningnetwork/lnd/funding"
|
||||
"github.com/lightningnetwork/lnd/lncfg"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
"github.com/lightningnetwork/lnd/tor"
|
||||
@ -97,7 +98,7 @@ func (c *chanController) OpenChannel(target *btcec.PublicKey,
|
||||
|
||||
// Construct the open channel request and send it to the server to begin
|
||||
// the funding workflow.
|
||||
req := &InitFundingMsg{
|
||||
req := &funding.InitFundingMsg{
|
||||
TargetPubkey: target,
|
||||
ChainHash: *c.netParams.GenesisHash,
|
||||
SubtractFees: true,
|
||||
|
@ -1765,7 +1765,7 @@ func (r *rpcServer) canOpenChannel() error {
|
||||
// struct. The logic is abstracted so that it can be shared between OpenChannel
|
||||
// and OpenChannelSync.
|
||||
func (r *rpcServer) parseOpenChannelReq(in *lnrpc.OpenChannelRequest,
|
||||
isSync bool) (*InitFundingMsg, error) {
|
||||
isSync bool) (*funding.InitFundingMsg, error) {
|
||||
|
||||
rpcsLog.Debugf("[openchannel] request to NodeKey(%x) "+
|
||||
"allocation(us=%v, them=%v)", in.NodePubkey,
|
||||
@ -1892,7 +1892,7 @@ func (r *rpcServer) parseOpenChannelReq(in *lnrpc.OpenChannelRequest,
|
||||
// Instruct the server to trigger the necessary events to attempt to
|
||||
// open a new channel. A stream is returned in place, this stream will
|
||||
// be used to consume updates of the state of the pending channel.
|
||||
return &InitFundingMsg{
|
||||
return &funding.InitFundingMsg{
|
||||
TargetPubkey: nodePubKey,
|
||||
ChainHash: *r.cfg.ActiveNetParams.GenesisHash,
|
||||
LocalFundingAmt: localFundingAmt,
|
||||
|
@ -218,7 +218,7 @@ type server struct {
|
||||
|
||||
cc *chainreg.ChainControl
|
||||
|
||||
fundingMgr *Manager
|
||||
fundingMgr *funding.Manager
|
||||
|
||||
localChanDB *channeldb.DB
|
||||
|
||||
@ -1001,7 +1001,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
s.fundingMgr, err = NewFundingManager(fundingConfig{
|
||||
s.fundingMgr, err = funding.NewFundingManager(funding.Config{
|
||||
NoWumboChans: !cfg.ProtocolOptions.Wumbo(),
|
||||
IDKey: nodeKeyECDH.PubKey(),
|
||||
Wallet: cc.Wallet,
|
||||
@ -3627,7 +3627,7 @@ func (s *server) DisconnectPeer(pubKey *btcec.PublicKey) error {
|
||||
//
|
||||
// NOTE: This function is safe for concurrent access.
|
||||
func (s *server) OpenChannel(
|
||||
req *InitFundingMsg) (chan *lnrpc.OpenStatusUpdate, chan error) {
|
||||
req *funding.InitFundingMsg) (chan *lnrpc.OpenStatusUpdate, chan error) {
|
||||
|
||||
// The updateChan will have a buffer of 2, since we expect a ChanPending
|
||||
// + a ChanOpen update, and we want to make sure the funding process is
|
||||
|
Loading…
x
Reference in New Issue
Block a user