mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-06 09:34:13 +02:00
watchtower/wtdb/breach_hint: adds BreachHint, txid prefix
This commit is contained in:
committed by
Conner Fromknecht
parent
463d352fa8
commit
bc86ccf212
27
watchtower/wtdb/breach_hint.go
Normal file
27
watchtower/wtdb/breach_hint.go
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
package wtdb
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/hex"
|
||||||
|
|
||||||
|
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||||
|
)
|
||||||
|
|
||||||
|
// BreachHintSize is the length of the txid prefix used to identify remote
|
||||||
|
// commitment broadcasts.
|
||||||
|
const BreachHintSize = 16
|
||||||
|
|
||||||
|
// BreachHint is the first 16-bytes of the txid belonging to a revoked
|
||||||
|
// commitment transaction.
|
||||||
|
type BreachHint [BreachHintSize]byte
|
||||||
|
|
||||||
|
// NewBreachHintFromHash creates a breach hint from a transaction ID.
|
||||||
|
func NewBreachHintFromHash(hash *chainhash.Hash) BreachHint {
|
||||||
|
var hint BreachHint
|
||||||
|
copy(hint[:], hash[:BreachHintSize])
|
||||||
|
return hint
|
||||||
|
}
|
||||||
|
|
||||||
|
// String returns a hex encoding of the breach hint.
|
||||||
|
func (h BreachHint) String() string {
|
||||||
|
return hex.EncodeToString(h[:])
|
||||||
|
}
|
Reference in New Issue
Block a user