summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Akiki <stephen.akiki@algorand.com>2022-06-24 10:38:38 -0400
committerStephen Akiki <stephen.akiki@algorand.com>2022-06-24 10:38:38 -0400
commit6da469b83b7a9a1cf0813f46241d1de5d440b8f1 (patch)
treeb32391beebec05582d18678a130dc4a18dbb8a06
parentbe3a235b509ef1b14c501eab71dfc389d267538d (diff)
-rw-r--r--cmd/goal/account.go21
-rw-r--r--daemon/algod/api/server/v2/handlers.go22
2 files changed, 23 insertions, 20 deletions
diff --git a/cmd/goal/account.go b/cmd/goal/account.go
index 467bad0cd..4b249033f 100644
--- a/cmd/goal/account.go
+++ b/cmd/goal/account.go
@@ -1409,24 +1409,9 @@ var partkeyInfoCmd = &cobra.Command{
fmt.Printf("Selection key: %s\n", base64.StdEncoding.EncodeToString(part.Key.SelectionParticipationKey))
fmt.Printf("Voting key: %s\n", base64.StdEncoding.EncodeToString(part.Key.VoteParticipationKey))
if part.Key.StateProofKey != nil {
- // A part.Key.StateProofKey (aka a state proof verifier) is a constant size block of bytes
- // If all those bytes are zero, then we don't want to display a "bogus" hash,
- // instead we want to output "n/a" to inform the user
- allZero := true
- blockLength := len(*part.Key.StateProofKey)
- for i := 0; i < blockLength; i++ {
- keyByte := (*part.Key.StateProofKey)[i]
- if keyByte != byte(0) {
- allZero = false
- break
- }
- }
-
- if allZero {
- fmt.Printf("State proof key: n/a\n")
- } else {
- fmt.Printf("State proof key: %s\n", base64.StdEncoding.EncodeToString(*part.Key.StateProofKey))
- }
+ fmt.Printf("State proof key: %s\n", base64.StdEncoding.EncodeToString(*part.Key.StateProofKey))
+ } else {
+ fmt.Printf("State proof key: n/a\n")
}
}
})
diff --git a/daemon/algod/api/server/v2/handlers.go b/daemon/algod/api/server/v2/handlers.go
index 9e18ca7d2..128490d8d 100644
--- a/daemon/algod/api/server/v2/handlers.go
+++ b/daemon/algod/api/server/v2/handlers.go
@@ -112,12 +112,30 @@ func convertParticipationRecord(record account.ParticipationRecord) generated.Pa
VoteFirstValid: uint64(record.FirstValid),
VoteLastValid: uint64(record.LastValid),
VoteKeyDilution: record.KeyDilution,
+ // Explicitly initialize to nil for zero key checking below
+ StateProofKey: nil,
},
}
if record.StateProof != nil {
- tmp := record.StateProof[:]
- participationKey.Key.StateProofKey = &tmp
+ // A record.StateProof (aka a state proof verifier) is a constant size block of bytes
+ // If all those bytes are zero, then we don't want to display a "bogus" hash,
+ // instead we want to output "n/a" to inform the user
+ allZero := true
+ blockLength := len(*record.StateProof)
+ for i := 0; i < blockLength; i++ {
+ keyByte := (*record.StateProof)[i]
+ if keyByte != byte(0) {
+ allZero = false
+ break
+ }
+ }
+
+ if !allZero {
+ tmp := record.StateProof[:]
+ participationKey.Key.StateProofKey = &tmp
+ }
+
}
// These are pointers but should always be present.