lnwallet: sync revocation state after receiving a revocation
This commit is contained in:
parent
14d669dfd1
commit
06f062e678
@ -838,6 +838,7 @@ func (lc *LightningChannel) RevokeCurrentCommitment() (*lnwire.CommitRevocation,
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
revocationMsg.ChannelPoint = lc.channelState.ChanID
|
||||||
return revocationMsg, nil
|
return revocationMsg, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -896,6 +897,19 @@ func (lc *LightningChannel) ReceiveRevocation(revMsg *lnwire.CommitRevocation) (
|
|||||||
lc.usedRevocations = lc.usedRevocations[1:]
|
lc.usedRevocations = lc.usedRevocations[1:]
|
||||||
lc.revocationWindow = append(lc.revocationWindow, revMsg)
|
lc.revocationWindow = append(lc.revocationWindow, revMsg)
|
||||||
|
|
||||||
|
log.Tracef("ChannelPoint(%v): remote party accepted state transition, "+
|
||||||
|
"revoked height %v, now at %v", lc.channelState.ChanID,
|
||||||
|
lc.remoteCommitChain.tail().height,
|
||||||
|
lc.remoteCommitChain.tail().height+1)
|
||||||
|
|
||||||
|
// At this point, the revocation has been accepted, and we've rotated
|
||||||
|
// the current revocation key+hash for the remote party. Therefore we
|
||||||
|
// sync now to ensure the elkrem receiver state is consistent with the
|
||||||
|
// current commitment height.
|
||||||
|
if err := lc.channelState.SyncRevocation(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
// Since they revoked the current lowest height in their commitment
|
// Since they revoked the current lowest height in their commitment
|
||||||
// chain, we can advance their chain by a single commitment.
|
// chain, we can advance their chain by a single commitment.
|
||||||
lc.remoteCommitChain.advanceTail()
|
lc.remoteCommitChain.advanceTail()
|
||||||
@ -950,6 +964,7 @@ func (lc *LightningChannel) ExtendRevocationWindow() (*lnwire.CommitRevocation,
|
|||||||
// InitialRevocationWindow
|
// InitialRevocationWindow
|
||||||
|
|
||||||
revMsg := &lnwire.CommitRevocation{}
|
revMsg := &lnwire.CommitRevocation{}
|
||||||
|
revMsg.ChannelPoint = lc.channelState.ChanID
|
||||||
|
|
||||||
nextHeight := lc.revocationWindowEdge + 1
|
nextHeight := lc.revocationWindowEdge + 1
|
||||||
revocation, err := lc.channelState.LocalElkrem.AtIndex(nextHeight)
|
revocation, err := lc.channelState.LocalElkrem.AtIndex(nextHeight)
|
||||||
@ -1226,20 +1241,6 @@ func (lc *LightningChannel) StateSnapshot() *channeldb.ChannelSnapshot {
|
|||||||
return lc.channelState.Snapshot()
|
return lc.channelState.Snapshot()
|
||||||
}
|
}
|
||||||
|
|
||||||
// RequestPayment...
|
|
||||||
func (lc *LightningChannel) RequestPayment(amount btcutil.Amount) error {
|
|
||||||
// Validate amount
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// PaymentRequest...
|
|
||||||
// TODO(roasbeef): serialization (bip 70, QR code, etc)
|
|
||||||
// * routing handled by upper layer
|
|
||||||
type PaymentRequest struct {
|
|
||||||
PaymentPreImage [32]byte
|
|
||||||
Value btcutil.Amount
|
|
||||||
}
|
|
||||||
|
|
||||||
// createCommitTx creates a commitment transaction, spending from specified
|
// createCommitTx creates a commitment transaction, spending from specified
|
||||||
// funding output. The commitment transaction contains two outputs: one paying
|
// funding output. The commitment transaction contains two outputs: one paying
|
||||||
// to the "owner" of the commitment transaction which can be spent after a
|
// to the "owner" of the commitment transaction which can be spent after a
|
||||||
|
Loading…
Reference in New Issue
Block a user