lnwallet: add new ShortChanID method to LightningChannel

This commit is contained in:
Olaoluwa Osuntokun 2017-06-16 23:25:07 +02:00
parent 26c14c7de5
commit 6937a42f2d
No known key found for this signature in database
GPG Key ID: 9CC5B105D03521A2
2 changed files with 19 additions and 6 deletions

View File

@ -677,9 +677,8 @@ type LightningChannel struct {
// channel.
RemoteFundingKey *btcec.PublicKey
// availableLocalBalance represent the amount of available money
// which might be procced by this channel at the specific point of
// time.
// availableLocalBalance represent the amount of available money which
// might be processed by this channel at the specific point of time.
availableLocalBalance btcutil.Amount
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
// if the channel isn't yet open, then we'll use the height it
// was broadcast at.
heightHint := lc.channelState.OpeningHeight
heightHint := lc.channelState.ShortChanID.BlockHeight
if heightHint == 0 {
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
// subsystems to uniquely identify an open channel.
func (lc *LightningChannel) ChannelPoint() *wire.OutPoint {
lc.RLock()
defer lc.RUnlock()
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
// 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.

View File

@ -1355,10 +1355,11 @@ func TestLightningWallet(t *testing.T) {
// Execute every test, clearing possibly mutated wallet state after
// each step.
for _, walletTest := range walletTests {
// TODO(roasbeef): run as parallel sub-tests?
walletTest(miningNode, lnw, t)
// TODO(roasbeef): possible reset mining node's chainstate to
// initial level, cleanly wipe buckets
// TODO(roasbeef): possible reset mining node's
// chainstate to initial level, cleanly wipe buckets
if err := clearWalletState(lnw); err != nil &&
err != bolt.ErrBucketNotFound {
t.Fatalf("unable to wipe wallet state: %v", err)