-
Notifications
You must be signed in to change notification settings - Fork 0
/
status.go
54 lines (35 loc) · 1.18 KB
/
status.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
53
54
package tapcards
import (
"fmt"
"log/slog"
)
func (satscard *Satscard) StatusRequest() ([]byte, error) {
satscard.queue.enqueue("status")
return satscard.nextCommand()
}
func (satscard *Satscard) statusRequest() ([]byte, error) {
slog.Debug("Request status")
statusCommand := statusCommand{command{Cmd: "status"}}
return apduWrap(statusCommand)
}
func (satscard *Satscard) parseStatusData(statusData statusData) error {
slog.Debug("Parse status")
slog.Debug("STATUS", "PublicKey", fmt.Sprintf("%x", statusData.PublicKey))
slog.Debug("STATUS", "CardNonce", fmt.Sprintf("%x", statusData.CardNonce))
slog.Debug("STATUS", "AuthDelay", statusData.AuthDelay)
satscard.cardPublicKey = statusData.PublicKey
satscard.currentCardNonce = statusData.CardNonce
identity, err := identity(satscard.cardPublicKey[:])
if err != nil {
return err
}
satscard.ActiveSlot = statusData.Slots[0]
satscard.NumberOfSlots = statusData.Slots[1]
satscard.Identity = identity
satscard.ActiveSlotPaymentAddress = statusData.Address
satscard.Proto = statusData.Proto
satscard.Birth = statusData.Birth
satscard.Version = statusData.Version
satscard.AuthDelay = statusData.AuthDelay
return nil
}