walletrpc: use bytes to represent master key fingerprint

The integer representation is not common and using bytes allows users to
easily confirm whether their master key fingerprint is correct.
This commit is contained in:
Wilmer Paulino committed 2021-05-07 13:07:10 -07:00
1 parent f7b130b5ca
commit e079a9583c
5 files changed
+54 -30

No files matched your search

+5 -5
View File
@@ -4,7 +4,6 @@ package main
import (
"encoding/base64"
"encoding/binary"
"encoding/hex"
"encoding/json"
"errors"
@@ -988,13 +987,14 @@ func importAccount(ctx *cli.Context) error {
return err
}
var masterKeyFingerprint uint32
var mkfpBytes []byte
if ctx.IsSet("master_key_fingerprint") {
mkfp, err := hex.DecodeString(ctx.String("master_key_fingerprint"))
mkfpBytes, err = hex.DecodeString(
ctx.String("master_key_fingerprint"),
)
if err != nil {
return fmt.Errorf("invalid master key fingerprint: %v", err)
}
masterKeyFingerprint = binary.LittleEndian.Uint32(mkfp)
}
walletClient, cleanUp := getWalletClient(ctx)
@@ -1004,7 +1004,7 @@ func importAccount(ctx *cli.Context) error {
req := &walletrpc.ImportAccountRequest{
Name: ctx.Args().Get(1),
ExtendedPublicKey: ctx.Args().Get(0),
MasterKeyFingerprint: masterKeyFingerprint,
MasterKeyFingerprint: mkfpBytes,
AddressType: addrType,
DryRun: dryRun,
}