Skip to content

Commit

Permalink
Merge pull request #67 from renproject/release/3.0.11
Browse files Browse the repository at this point in the history
Fix gas price for withdrawing ETH from the darknode
  • Loading branch information
Yunshi Sun committed May 27, 2020
2 parents 1fbbbca + 1ade641 commit 730376d
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 3.0.11
- Use suggest gas price for withdrawing ETH.

## 3.0.10
- Improve `update` command to support suffix tags #61
- Show darknodes versions when from the `list` command.
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0.10
3.0.11
15 changes: 11 additions & 4 deletions cmd/down.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ func destroyNode(ctx *cli.Context) error {

// Withdraw ETH and REN in the darknode address to the provided receiver address
func withdraw(ctx *cli.Context) error {
// Create a context for the entire withdraw process
c, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()

// Parse the input parameters
name := ctx.Args().First()
if err := util.ValidateNodeName(name); err != nil {
return err
Expand All @@ -122,11 +127,13 @@ func withdraw(ctx *cli.Context) error {
}

// Create a transactor for ethereum tx
gasPrice, err := client.EthClient().SuggestGasPrice(c)
if err != nil {
return err
}
ethAddr := crypto.PubkeyToAddress(config.Keystore.Ecdsa.PublicKey)
c, cancel := context.WithTimeout(context.Background(), time.Minute)
defer cancel()
auth := bind.NewKeyedTransactor(config.Keystore.Ecdsa.PrivateKey)
auth.GasPrice = big.NewInt(5000000000) // Set GasPrise to 5 Gwei
auth.GasPrice = gasPrice
auth.Context = c

// Check REN balance first
Expand Down Expand Up @@ -164,7 +171,7 @@ func withdraw(ctx *cli.Context) error {
if err != nil {
return err
}
gas := ethtypes.Gwei(5 * 21000)
gas := ethtypes.Wei(gasPrice.Uint64() * 21000)
zero := ethtypes.Wei(0)
if balance.Gt(zero) {
if balance.Gt(gas) {
Expand Down
2 changes: 1 addition & 1 deletion cmd/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ systemctl --user restart darknode`, url, ver)
}

func validateVersion(version string) error {
ctx, cancel := context.WithTimeout(context.Background(), 5 *time.Second)
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()

client := github.NewClient(nil)
Expand Down
2 changes: 1 addition & 1 deletion util/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ func ValidateTags(have, required string) bool {
// LatestStableRelease checks the darknode release repo and return the version
// of the latest release.
func LatestStableRelease() (string, error) {
ctx, cancel := context.WithTimeout(context.Background(), 5 *time.Second)
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()

client := github.NewClient(nil)
Expand Down

0 comments on commit 730376d

Please sign in to comment.