forked from btcsuite/btcd
-
Notifications
You must be signed in to change notification settings - Fork 25
/
session_state_update.go
52 lines (43 loc) · 1.21 KB
/
session_state_update.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package wtdb
import (
"io"
"github.com/pkt-cash/pktd/btcutil/er"
"github.com/pkt-cash/pktd/lnd/watchtower/blob"
)
// SessionStateUpdate holds a state update sent by a client along with its
// SessionID.
type SessionStateUpdate struct {
// ID the session id of the client who sent the state update.
ID SessionID
// SeqNum the sequence number of the update within the session.
SeqNum uint16
// LastApplied the highest index that client has acknowledged is
// committed
LastApplied uint16
// Hint is the 16-byte prefix of the revoked commitment transaction.
Hint blob.BreachHint
// EncryptedBlob is a ciphertext containing the sweep information for
// exacting justice if the commitment transaction matching the breach
// hint is broadcast.
EncryptedBlob []byte
}
// Encode serializes the state update into the provided io.Writer.
func (u *SessionStateUpdate) Encode(w io.Writer) er.R {
return WriteElements(w,
u.ID,
u.SeqNum,
u.LastApplied,
u.Hint,
u.EncryptedBlob,
)
}
// Decode deserializes the target state update from the provided io.Reader.
func (u *SessionStateUpdate) Decode(r io.Reader) er.R {
return ReadElements(r,
&u.ID,
&u.SeqNum,
&u.LastApplied,
&u.Hint,
&u.EncryptedBlob,
)
}