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:
Olaoluwa Osuntokun
2017-01-24 17:12:51 -08:00
parent 73d5daa2c3
commit a658fabf48
4 changed files with 60 additions and 11 deletions

View File

@@ -236,7 +236,7 @@ func testBasicChannelFunding(net *networkHarness, t *harnessTest) {
}
if bobBal.Balance != int64(pushAmt) {
t.Fatalf("bob's balance is incorrect: expected %v got %v",
pushAmt, bobBal)
pushAmt, bobBal.Balance)
}
// Finally, immediately close the channel. This function will also
@@ -1124,7 +1124,7 @@ func testMaxPendingChannels(net *networkHarness, t *harnessTest) {
_, err = net.OpenChannel(ctx, net.Alice, carol, amount, 0, 1)
if err == nil {
t.Fatalf("error wasn't received")
} else if grpc.Code(err) != lnwire.ErrorMaxPendingChannels.ToGrpcCode() {
} else if grpc.Code(err) != lnwire.ErrMaxPendingChannels.ToGrpcCode() {
t.Fatalf("not expected error was received: %v", err)
}