From f1f1a38663c1c8d4f3288f2fd131884dd5609d91 Mon Sep 17 00:00:00 2001 From: "Johan T. Halseth" Date: Wed, 28 Feb 2018 23:35:03 +0100 Subject: [PATCH] funding: add method IsPendingChannel --- fundingmanager.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/fundingmanager.go b/fundingmanager.go index e1e98872..a9784f0a 100644 --- a/fundingmanager.go +++ b/fundingmanager.go @@ -2639,6 +2639,22 @@ func (f *fundingManager) getReservationCtx(peerKey *btcec.PublicKey, return resCtx, nil } +// IsPendingChannel returns a boolean indicating whether the channel identified +// by the pendingChanID and given peer is pending, meaning it is in the process +// of being funded. After the funding transaction has been confirmed, the +// channel will receive a new, permanent channel ID, and will no longer be +// considered pending. +func (f *fundingManager) IsPendingChannel(pendingChanID [32]byte, + peerAddress *lnwire.NetAddress) bool { + + peerIDKey := newSerializedKey(peerAddress.IdentityKey) + f.resMtx.RLock() + _, ok := f.activeReservations[peerIDKey][pendingChanID] + f.resMtx.RUnlock() + + return ok +} + func copyPubKey(pub *btcec.PublicKey) *btcec.PublicKey { return &btcec.PublicKey{ Curve: btcec.S256(),