diff options
author | Stephen Akiki <stephen.akiki@algorand.com> | 2022-06-24 10:38:38 -0400 |
---|---|---|
committer | Stephen Akiki <stephen.akiki@algorand.com> | 2022-06-24 10:38:38 -0400 |
commit | 6da469b83b7a9a1cf0813f46241d1de5d440b8f1 (patch) | |
tree | b32391beebec05582d18678a130dc4a18dbb8a06 | |
parent | be3a235b509ef1b14c501eab71dfc389d267538d (diff) |
Pushed to REST API2064-display-na-if-there-are-no-state-proof-keys
-rw-r--r-- | cmd/goal/account.go | 21 | ||||
-rw-r--r-- | daemon/algod/api/server/v2/handlers.go | 22 |
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. |