|
|
|
@ -3657,3 +3657,38 @@ func storeThawHeight(chanBucket kvdb.RwBucket, height uint32) error {
|
|
|
|
|
func deleteThawHeight(chanBucket kvdb.RwBucket) error { |
|
|
|
|
return chanBucket.Delete(frozenChanKey) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// EKeyLocator is an encoder for keychain.KeyLocator.
|
|
|
|
|
func EKeyLocator(w io.Writer, val interface{}, buf *[8]byte) error { |
|
|
|
|
if v, ok := val.(*keychain.KeyLocator); ok { |
|
|
|
|
err := tlv.EUint32T(w, uint32(v.Family), buf) |
|
|
|
|
if err != nil { |
|
|
|
|
return err |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return tlv.EUint32T(w, v.Index, buf) |
|
|
|
|
} |
|
|
|
|
return tlv.NewTypeForEncodingErr(val, "keychain.KeyLocator") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// DKeyLocator is a decoder for keychain.KeyLocator.
|
|
|
|
|
func DKeyLocator(r io.Reader, val interface{}, buf *[8]byte, l uint64) error { |
|
|
|
|
if v, ok := val.(*keychain.KeyLocator); ok { |
|
|
|
|
var family uint32 |
|
|
|
|
err := tlv.DUint32(r, &family, buf, 4) |
|
|
|
|
if err != nil { |
|
|
|
|
return err |
|
|
|
|
} |
|
|
|
|
v.Family = keychain.KeyFamily(family) |
|
|
|
|
|
|
|
|
|
return tlv.DUint32(r, &v.Index, buf, 4) |
|
|
|
|
} |
|
|
|
|
return tlv.NewTypeForDecodingErr(val, "keychain.KeyLocator", l, 8) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// MakeKeyLocRecord creates a Record out of a KeyLocator using the passed
|
|
|
|
|
// Type and the EKeyLocator and DKeyLocator functions. The size will always be
|
|
|
|
|
// 8 as KeyFamily is uint32 and the Index is uint32.
|
|
|
|
|
func MakeKeyLocRecord(typ tlv.Type, keyLoc *keychain.KeyLocator) tlv.Record { |
|
|
|
|
return tlv.MakeStaticRecord(typ, keyLoc, 8, EKeyLocator, DKeyLocator) |
|
|
|
|
} |
|
|
|
|