wtxmgr: extract label deserialization into separate function

Requrired so that we can use the same logic in dropwtxmgr.
This commit is contained in:
carla 2020-05-28 09:07:31 +02:00
parent 4ec3fb4928
commit ab19740c94
No known key found for this signature in database
GPG key ID: 4CA7FE54A6213C91

View file

@ -1025,6 +1025,12 @@ func FetchTxLabel(ns walletdb.ReadBucket, txid chainhash.Hash) (string, error) {
return "", ErrTxLabelNotFound
}
return DeserializeLabel(v)
}
// DeserializeLabel reads a deserializes a length-value encoded label from the
// byte array provided.
func DeserializeLabel(v []byte) (string, error) {
// If the label is empty, return an error.
length := binary.BigEndian.Uint16(v[0:2])
if length == 0 {