Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions cmd/goal/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,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()
Expand All @@ -949,25 +950,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)
Expand Down Expand Up @@ -1024,6 +1025,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

Expand All @@ -1043,7 +1045,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
Expand Down