mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-07-28 13:52:55 +02:00
breacharbiter: add chainhash to retributionInfo struct
In this commit we add a chainhash field to the retributionInfo struct as within the database, channels are now further namespaced by their chain hash, and all ChannelCloseSummary structs now also carry the chain hash of their respective chain.
This commit is contained in:
@@ -777,6 +777,7 @@ func (b *breachArbiter) breachObserver(contract *lnwallet.LightningChannel,
|
||||
// BreachClose.
|
||||
closeInfo := &channeldb.ChannelCloseSummary{
|
||||
ChanPoint: *chanPoint,
|
||||
ChainHash: breachInfo.ChainHash,
|
||||
ClosingTXID: breachInfo.BreachTransaction.TxHash(),
|
||||
RemotePub: &chanInfo.RemoteIdentity,
|
||||
Capacity: chanInfo.Capacity,
|
||||
@@ -918,6 +919,7 @@ var _ SpendableOutput = (*breachedOutput)(nil)
|
||||
type retributionInfo struct {
|
||||
commitHash chainhash.Hash
|
||||
chanPoint wire.OutPoint
|
||||
chainHash chainhash.Hash
|
||||
|
||||
// TODO(conner): remove the following group of fields after decoupling
|
||||
// the breach arbiter from the wallet.
|
||||
@@ -1007,6 +1009,7 @@ func newRetributionInfo(chanPoint *wire.OutPoint,
|
||||
|
||||
return &retributionInfo{
|
||||
commitHash: breachInfo.BreachTransaction.TxHash(),
|
||||
chainHash: chanInfo.ChainHash,
|
||||
chanPoint: *chanPoint,
|
||||
remoteIdentity: &chanInfo.RemoteIdentity,
|
||||
capacity: chanInfo.Capacity,
|
||||
@@ -1325,6 +1328,10 @@ func (ret *retributionInfo) Encode(w io.Writer) error {
|
||||
return err
|
||||
}
|
||||
|
||||
if _, err := w.Write(ret.chainHash[:]); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if _, err := w.Write(
|
||||
ret.remoteIdentity.SerializeCompressed()); err != nil {
|
||||
return err
|
||||
@@ -1371,6 +1378,15 @@ func (ret *retributionInfo) Decode(r io.Reader) error {
|
||||
return err
|
||||
}
|
||||
|
||||
if _, err := io.ReadFull(r, scratch[:32]); err != nil {
|
||||
return err
|
||||
}
|
||||
chainHash, err := chainhash.NewHash(scratch[:32])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ret.chainHash = *chainHash
|
||||
|
||||
if _, err = io.ReadFull(r, scratch[:33]); err != nil {
|
||||
return err
|
||||
}
|
||||
|
Reference in New Issue
Block a user