rpcserver: add wallet sync check to OpenChannel
This commit is contained in:
parent
f996203883
commit
5660a26b60
@ -214,9 +214,15 @@ func openChannelAndAssert(ctx context.Context, t *harnessTest,
|
||||
net *lntest.NetworkHarness, alice, bob *lntest.HarnessNode,
|
||||
p lntest.OpenChannelParams) *lnrpc.ChannelPoint {
|
||||
|
||||
chanOpenUpdate, err := net.OpenChannel(
|
||||
ctx, alice, bob, p,
|
||||
)
|
||||
// Wait until we are able to fund a channel successfully. This wait
|
||||
// prevents us from erroring out when trying to create a channel while
|
||||
// the node is starting up.
|
||||
var chanOpenUpdate lnrpc.Lightning_OpenChannelClient
|
||||
err := wait.NoError(func() error {
|
||||
var err error
|
||||
chanOpenUpdate, err = net.OpenChannel(ctx, alice, bob, p)
|
||||
return err
|
||||
}, defaultTimeout)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to open channel: %v", err)
|
||||
}
|
||||
|
11
rpcserver.go
11
rpcserver.go
@ -1616,6 +1616,17 @@ func (r *rpcServer) OpenChannel(in *lnrpc.OpenChannelRequest,
|
||||
return ErrServerNotActive
|
||||
}
|
||||
|
||||
// Creation of channels before the wallet syncs up is currently
|
||||
// disallowed.
|
||||
isSynced, _, err := r.server.cc.wallet.IsSynced()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !isSynced {
|
||||
return errors.New("channels cannot be created before the " +
|
||||
"wallet is fully synced")
|
||||
}
|
||||
|
||||
localFundingAmt := btcutil.Amount(in.LocalFundingAmount)
|
||||
remoteInitialBalance := btcutil.Amount(in.PushSat)
|
||||
minHtlcIn := lnwire.MilliSatoshi(in.MinHtlcMsat)
|
||||
|
Loading…
Reference in New Issue
Block a user