mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-06-29 18:10:48 +02:00
funding: disallow channel creation before lnd is synced to the chain
This commit adds a new restriction around funding channels at the daemon level: lnd nodes will not allow either the initiation or the acceptance of a channel before the node is fully synced to the best known chain. This fixes a class of bug that arises when a new node joins the network and either attempts to open a channel or has a channel extended to them before the node is fully synced to the network.
This commit is contained in:
12
rpcserver.go
12
rpcserver.go
@ -4,6 +4,7 @@ import (
|
||||
"bytes"
|
||||
"crypto/rand"
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"math"
|
||||
@ -331,6 +332,17 @@ func (r *rpcServer) OpenChannelSync(ctx context.Context,
|
||||
"allocation(us=%v, them=%v) numconfs=%v", in.TargetPeerId,
|
||||
in.LocalFundingAmount, in.PushSat, in.NumConfs)
|
||||
|
||||
// Creation of channels before the wallet syncs up is currently
|
||||
// disallowed.
|
||||
isSynced, err := r.server.lnwallet.IsSynced()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !isSynced {
|
||||
return nil, errors.New("channels cannot be created before the " +
|
||||
"wallet is fully synced")
|
||||
}
|
||||
|
||||
// Decode the provided target node's public key, parsing it into a pub
|
||||
// key object. For all sync call, byte slices are expected to be
|
||||
// encoded as hex strings.
|
||||
|
Reference in New Issue
Block a user