mirror of https://github.com/BTCPrivate/lnd.git
lnwallet: add new ShortChanID method to LightningChannel
This commit is contained in:
parent
26c14c7de5
commit
6937a42f2d
|
@ -677,9 +677,8 @@ type LightningChannel struct {
|
||||||
// channel.
|
// channel.
|
||||||
RemoteFundingKey *btcec.PublicKey
|
RemoteFundingKey *btcec.PublicKey
|
||||||
|
|
||||||
// availableLocalBalance represent the amount of available money
|
// availableLocalBalance represent the amount of available money which
|
||||||
// which might be procced by this channel at the specific point of
|
// might be processed by this channel at the specific point of time.
|
||||||
// time.
|
|
||||||
availableLocalBalance btcutil.Amount
|
availableLocalBalance btcutil.Amount
|
||||||
|
|
||||||
shutdown int32
|
shutdown int32
|
||||||
|
@ -801,7 +800,7 @@ func NewLightningChannel(signer Signer, events chainntnfs.ChainNotifier,
|
||||||
// As a height hint, we'll try to use the opening height, but
|
// As a height hint, we'll try to use the opening height, but
|
||||||
// if the channel isn't yet open, then we'll use the height it
|
// if the channel isn't yet open, then we'll use the height it
|
||||||
// was broadcast at.
|
// was broadcast at.
|
||||||
heightHint := lc.channelState.OpeningHeight
|
heightHint := lc.channelState.ShortChanID.BlockHeight
|
||||||
if heightHint == 0 {
|
if heightHint == 0 {
|
||||||
heightHint = lc.channelState.FundingBroadcastHeight
|
heightHint = lc.channelState.FundingBroadcastHeight
|
||||||
}
|
}
|
||||||
|
@ -2333,9 +2332,22 @@ func (lc *LightningChannel) ReceiveFailHTLC(logIndex uint64) error {
|
||||||
// created this active channel. This outpoint is used throughout various
|
// created this active channel. This outpoint is used throughout various
|
||||||
// subsystems to uniquely identify an open channel.
|
// subsystems to uniquely identify an open channel.
|
||||||
func (lc *LightningChannel) ChannelPoint() *wire.OutPoint {
|
func (lc *LightningChannel) ChannelPoint() *wire.OutPoint {
|
||||||
|
lc.RLock()
|
||||||
|
defer lc.RUnlock()
|
||||||
|
|
||||||
return lc.channelState.ChanID
|
return lc.channelState.ChanID
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ShortChanID returns the short channel ID for the channel. The short channel
|
||||||
|
// ID encodes the exact location in the main chain that the original
|
||||||
|
// funding output can be found.
|
||||||
|
func (lc *LightningChannel) ShortChanID() lnwire.ShortChannelID {
|
||||||
|
lc.RLock()
|
||||||
|
defer lc.RUnlock()
|
||||||
|
|
||||||
|
return lc.channelState.ShortChanID
|
||||||
|
}
|
||||||
|
|
||||||
// genHtlcScript generates the proper P2WSH public key scripts for the
|
// genHtlcScript generates the proper P2WSH public key scripts for the
|
||||||
// HTLC output modified by two-bits denoting if this is an incoming HTLC, and
|
// HTLC output modified by two-bits denoting if this is an incoming HTLC, and
|
||||||
// if the HTLC is being applied to their commitment transaction or ours.
|
// if the HTLC is being applied to their commitment transaction or ours.
|
||||||
|
|
|
@ -1355,10 +1355,11 @@ func TestLightningWallet(t *testing.T) {
|
||||||
// Execute every test, clearing possibly mutated wallet state after
|
// Execute every test, clearing possibly mutated wallet state after
|
||||||
// each step.
|
// each step.
|
||||||
for _, walletTest := range walletTests {
|
for _, walletTest := range walletTests {
|
||||||
|
// TODO(roasbeef): run as parallel sub-tests?
|
||||||
walletTest(miningNode, lnw, t)
|
walletTest(miningNode, lnw, t)
|
||||||
|
|
||||||
// TODO(roasbeef): possible reset mining node's chainstate to
|
// TODO(roasbeef): possible reset mining node's
|
||||||
// initial level, cleanly wipe buckets
|
// chainstate to initial level, cleanly wipe buckets
|
||||||
if err := clearWalletState(lnw); err != nil &&
|
if err := clearWalletState(lnw); err != nil &&
|
||||||
err != bolt.ErrBucketNotFound {
|
err != bolt.ErrBucketNotFound {
|
||||||
t.Fatalf("unable to wipe wallet state: %v", err)
|
t.Fatalf("unable to wipe wallet state: %v", err)
|
||||||
|
|
Loading…
Reference in New Issue