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:
1 file changed
+16
@@ -777,6 +777,7 @@ func (b *breachArbiter) breachObserver(contract *lnwallet.LightningChannel,
|
|||||||
// BreachClose.
|
// BreachClose.
|
||||||
closeInfo := &channeldb.ChannelCloseSummary{
|
closeInfo := &channeldb.ChannelCloseSummary{
|
||||||
ChanPoint: *chanPoint,
|
ChanPoint: *chanPoint,
|
||||||
|
ChainHash: breachInfo.ChainHash,
|
||||||
ClosingTXID: breachInfo.BreachTransaction.TxHash(),
|
ClosingTXID: breachInfo.BreachTransaction.TxHash(),
|
||||||
RemotePub: &chanInfo.RemoteIdentity,
|
RemotePub: &chanInfo.RemoteIdentity,
|
||||||
Capacity: chanInfo.Capacity,
|
Capacity: chanInfo.Capacity,
|
||||||
@@ -918,6 +919,7 @@ var _ SpendableOutput = (*breachedOutput)(nil)
|
|||||||
type retributionInfo struct {
|
type retributionInfo struct {
|
||||||
commitHash chainhash.Hash
|
commitHash chainhash.Hash
|
||||||
chanPoint wire.OutPoint
|
chanPoint wire.OutPoint
|
||||||
|
chainHash chainhash.Hash
|
||||||
|
|
||||||
// TODO(conner): remove the following group of fields after decoupling
|
// TODO(conner): remove the following group of fields after decoupling
|
||||||
// the breach arbiter from the wallet.
|
// the breach arbiter from the wallet.
|
||||||
@@ -1007,6 +1009,7 @@ func newRetributionInfo(chanPoint *wire.OutPoint,
|
|||||||
|
|
||||||
return &retributionInfo{
|
return &retributionInfo{
|
||||||
commitHash: breachInfo.BreachTransaction.TxHash(),
|
commitHash: breachInfo.BreachTransaction.TxHash(),
|
||||||
|
chainHash: chanInfo.ChainHash,
|
||||||
chanPoint: *chanPoint,
|
chanPoint: *chanPoint,
|
||||||
remoteIdentity: &chanInfo.RemoteIdentity,
|
remoteIdentity: &chanInfo.RemoteIdentity,
|
||||||
capacity: chanInfo.Capacity,
|
capacity: chanInfo.Capacity,
|
||||||
@@ -1325,6 +1328,10 @@ func (ret *retributionInfo) Encode(w io.Writer) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if _, err := w.Write(ret.chainHash[:]); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
if _, err := w.Write(
|
if _, err := w.Write(
|
||||||
ret.remoteIdentity.SerializeCompressed()); err != nil {
|
ret.remoteIdentity.SerializeCompressed()); err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -1371,6 +1378,15 @@ func (ret *retributionInfo) Decode(r io.Reader) error {
|
|||||||
return err
|
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 {
|
if _, err = io.ReadFull(r, scratch[:33]); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user