mirror of
https://github.com/status-im/status-keycard-go.git
synced 2025-02-07 03:54:47 +00:00
parse int from KeycardApplicationInfo
This commit is contained in:
parent
c8d0142a16
commit
622a50e950
15
main.go
15
main.go
@ -3,6 +3,7 @@ package main
|
|||||||
// #cgo LDFLAGS: -shared
|
// #cgo LDFLAGS: -shared
|
||||||
import "C"
|
import "C"
|
||||||
import (
|
import (
|
||||||
|
"encoding/binary"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
@ -103,8 +104,8 @@ func Select() *C.char {
|
|||||||
Initialized: info.Initialized,
|
Initialized: info.Initialized,
|
||||||
InstanceUID: info.InstanceUID,
|
InstanceUID: info.InstanceUID,
|
||||||
SecureChannelPublicKey: info.SecureChannelPublicKey,
|
SecureChannelPublicKey: info.SecureChannelPublicKey,
|
||||||
Version: info.Version,
|
Version: bytesToInt(info.Version),
|
||||||
AvailableSlots: info.AvailableSlots,
|
AvailableSlots: bytesToInt(info.AvailableSlots),
|
||||||
KeyUID: info.KeyUID,
|
KeyUID: info.KeyUID,
|
||||||
Capabilities: Capability(info.Capabilities),
|
Capabilities: Capability(info.Capabilities),
|
||||||
})
|
})
|
||||||
@ -411,3 +412,13 @@ func ChangePairingPassword(jsonParams *C.char) *C.char {
|
|||||||
func SetSignalEventCallback(cb unsafe.Pointer) {
|
func SetSignalEventCallback(cb unsafe.Pointer) {
|
||||||
signal.SetSignalEventCallback(cb)
|
signal.SetSignalEventCallback(cb)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func bytesToInt(s []byte) int {
|
||||||
|
if len(s) > 4 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
var b [4]byte
|
||||||
|
copy(b[4-len(s):], s)
|
||||||
|
return int(binary.BigEndian.Uint32(b[:]))
|
||||||
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package signal
|
package signal
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// EventSignRequestAdded is triggered when send transaction request is queued
|
|
||||||
EventKeycardConnected = "keycard.connected"
|
EventKeycardConnected = "keycard.connected"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
4
types.go
4
types.go
@ -93,8 +93,8 @@ type ApplicationInfo struct {
|
|||||||
Initialized bool `json:"initialized"`
|
Initialized bool `json:"initialized"`
|
||||||
InstanceUID hexString `json:"instanceUID"`
|
InstanceUID hexString `json:"instanceUID"`
|
||||||
SecureChannelPublicKey hexString `json:"secureChannelPublicKey"`
|
SecureChannelPublicKey hexString `json:"secureChannelPublicKey"`
|
||||||
Version hexString `json:"version"`
|
Version int `json:"version"`
|
||||||
AvailableSlots hexString `json:"availableSlots"`
|
AvailableSlots int `json:"availableSlots"`
|
||||||
// KeyUID is the sha256 of of the master public key on the card.
|
// KeyUID is the sha256 of of the master public key on the card.
|
||||||
// It's empty if the card doesn't contain any key.
|
// It's empty if the card doesn't contain any key.
|
||||||
KeyUID hexString `json:"keyUID"`
|
KeyUID hexString `json:"keyUID"`
|
||||||
|
Loading…
x
Reference in New Issue
Block a user