summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQuentin Kniep <kniepque@hu-berlin.de>2021-12-15 22:53:25 +0100
committerGitHub <noreply@github.com>2021-12-15 16:53:25 -0500
commit8128167892227e5e9d8433ccceb378fe2678e0ff (patch)
treeda5641fd3e7b27d2cf4bbc8c06f139c672ce5781
parent14e889eada8214e6438c8ed91907500630287d8c (diff)
Separate tx and key validity for `goal account renewpartkey` (#3286)
Always use currentRound+proto.MaxTxnLife as last valid round for the transaction when renewing instead of using the partkey validity period. This fixes #3283
-rw-r--r--cmd/goal/account.go14
1 files changed, 8 insertions, 6 deletions
diff --git a/cmd/goal/account.go b/cmd/goal/account.go
index ccc37f227..bae3a73bb 100644
--- a/cmd/goal/account.go
+++ b/cmd/goal/account.go
@@ -938,6 +938,7 @@ var renewParticipationKeyCmd = &cobra.Command{
if roundLastValid <= (currentRound + proto.MaxTxnLife) {
reportErrorf(errLastRoundInvalid, currentRound)
}
+ txRoundLastValid := currentRound + proto.MaxTxnLife
// Make sure we don't already have a partkey valid for (or after) specified roundLastValid
parts, err := client.ListParticipationKeyFiles()
@@ -952,25 +953,25 @@ var renewParticipationKeyCmd = &cobra.Command{
}
}
- err = generateAndRegisterPartKey(accountAddress, currentRound, roundLastValid, transactionFee, scLeaseBytes(cmd), keyDilution, walletName, dataDir, client)
+ err = generateAndRegisterPartKey(accountAddress, currentRound, roundLastValid, txRoundLastValid, transactionFee, scLeaseBytes(cmd), keyDilution, walletName, dataDir, client)
if err != nil {
reportErrorf(err.Error())
}
},
}
-func generateAndRegisterPartKey(address string, currentRound, lastValidRound uint64, fee uint64, leaseBytes [32]byte, dilution uint64, wallet string, dataDir string, client libgoal.Client) error {
+func generateAndRegisterPartKey(address string, currentRound, keyLastValidRound, txLastValidRound uint64, fee uint64, leaseBytes [32]byte, dilution uint64, wallet string, dataDir string, client libgoal.Client) error {
// Generate a participation keys database and install it
- part, keyPath, err := client.GenParticipationKeysTo(address, currentRound, lastValidRound, dilution, "")
+ part, keyPath, err := client.GenParticipationKeysTo(address, currentRound, keyLastValidRound, dilution, "")
if err != nil {
return fmt.Errorf(errorRequestFail, err)
}
- fmt.Printf(" Generated participation key for %s (Valid %d - %d)\n", address, currentRound, lastValidRound)
+ fmt.Printf(" Generated participation key for %s (Valid %d - %d)\n", address, currentRound, keyLastValidRound)
// Now register it as our new online participation key
goOnline := true
txFile := ""
- err = changeAccountOnlineStatus(address, &part, goOnline, txFile, wallet, currentRound, lastValidRound, fee, leaseBytes, dataDir, client)
+ err = changeAccountOnlineStatus(address, &part, goOnline, txFile, wallet, currentRound, txLastValidRound, fee, leaseBytes, dataDir, client)
if err != nil {
os.Remove(keyPath)
fmt.Fprintf(os.Stderr, " Error registering keys - deleting newly-generated key file: %s\n", keyPath)
@@ -1027,6 +1028,7 @@ func renewPartKeysInDir(dataDir string, lastValidRound uint64, fee uint64, lease
if lastValidRound <= (currentRound + proto.MaxTxnLife) {
return fmt.Errorf(errLastRoundInvalid, currentRound)
}
+ txLastValidRound := currentRound + proto.MaxTxnLife
var anyErrors bool
@@ -1046,7 +1048,7 @@ func renewPartKeysInDir(dataDir string, lastValidRound uint64, fee uint64, lease
}
address := renewPart.Address().String()
- err = generateAndRegisterPartKey(address, currentRound, lastValidRound, fee, leaseBytes, dilution, wallet, dataDir, client)
+ err = generateAndRegisterPartKey(address, currentRound, lastValidRound, txLastValidRound, fee, leaseBytes, dilution, wallet, dataDir, client)
if err != nil {
fmt.Fprintf(os.Stderr, " Error renewing part key for account %s: %v\n", address, err)
anyErrors = true