mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-02-23 14:40:30 +01:00
rpcserver: add wallet sync check to OpenChannel
This commit is contained in:
parent
f996203883
commit
5660a26b60
2 changed files with 20 additions and 3 deletions
|
@ -214,9 +214,15 @@ func openChannelAndAssert(ctx context.Context, t *harnessTest,
|
||||||
net *lntest.NetworkHarness, alice, bob *lntest.HarnessNode,
|
net *lntest.NetworkHarness, alice, bob *lntest.HarnessNode,
|
||||||
p lntest.OpenChannelParams) *lnrpc.ChannelPoint {
|
p lntest.OpenChannelParams) *lnrpc.ChannelPoint {
|
||||||
|
|
||||||
chanOpenUpdate, err := net.OpenChannel(
|
// Wait until we are able to fund a channel successfully. This wait
|
||||||
ctx, alice, bob, p,
|
// 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 {
|
if err != nil {
|
||||||
t.Fatalf("unable to open channel: %v", err)
|
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
|
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)
|
localFundingAmt := btcutil.Amount(in.LocalFundingAmount)
|
||||||
remoteInitialBalance := btcutil.Amount(in.PushSat)
|
remoteInitialBalance := btcutil.Amount(in.PushSat)
|
||||||
minHtlcIn := lnwire.MilliSatoshi(in.MinHtlcMsat)
|
minHtlcIn := lnwire.MilliSatoshi(in.MinHtlcMsat)
|
||||||
|
|
Loading…
Add table
Reference in a new issue