Skip to content

Commit

Permalink
Some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
someone235 committed Sep 15, 2024
1 parent bb8af5d commit d573ca1
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 24 deletions.
19 changes: 13 additions & 6 deletions cmd/kaspawallet/bump_fee.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package main
import (
"context"
"fmt"
"math"
"os"
"strings"

Expand Down Expand Up @@ -33,13 +32,21 @@ func bumpFee(conf *bumpFeeConfig) error {
ctx, cancel := context.WithTimeout(context.Background(), daemonTimeout)
defer cancel()

feePolicy := &pb.FeePolicy{
FeePolicy: &pb.FeePolicy_MaxFeeRate{MaxFeeRate: math.MaxFloat64},
}
var feePolicy *pb.FeePolicy
if conf.FeeRate > 0 {
feePolicy.FeePolicy = &pb.FeePolicy_ExactFeeRate{ExactFeeRate: conf.FeeRate}
feePolicy = &pb.FeePolicy{
FeePolicy: &pb.FeePolicy_ExactFeeRate{
ExactFeeRate: conf.FeeRate,
},
}
} else if conf.MaxFeeRate > 0 {
feePolicy.FeePolicy = &pb.FeePolicy_MaxFeeRate{MaxFeeRate: conf.MaxFeeRate}
feePolicy = &pb.FeePolicy{
FeePolicy: &pb.FeePolicy_MaxFeeRate{MaxFeeRate: conf.MaxFeeRate},
}
} else if conf.MaxFee > 0 {
feePolicy = &pb.FeePolicy{
FeePolicy: &pb.FeePolicy_MaxFee{MaxFee: conf.MaxFee},
}
}

createUnsignedTransactionsResponse, err :=
Expand Down
19 changes: 13 additions & 6 deletions cmd/kaspawallet/bump_fee_unsigned.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package main
import (
"context"
"fmt"
"math"
"os"

"github.com/kaspanet/kaspad/cmd/kaspawallet/daemon/client"
Expand All @@ -24,13 +23,21 @@ func bumpFeeUnsigned(conf *bumpFeeUnsignedConfig) error {
return err
}

feePolicy := &pb.FeePolicy{
FeePolicy: &pb.FeePolicy_MaxFeeRate{MaxFeeRate: math.MaxFloat64},
}
var feePolicy *pb.FeePolicy
if conf.FeeRate > 0 {
feePolicy.FeePolicy = &pb.FeePolicy_ExactFeeRate{ExactFeeRate: conf.FeeRate}
feePolicy = &pb.FeePolicy{
FeePolicy: &pb.FeePolicy_ExactFeeRate{
ExactFeeRate: conf.FeeRate,
},
}
} else if conf.MaxFeeRate > 0 {
feePolicy.FeePolicy = &pb.FeePolicy_MaxFeeRate{MaxFeeRate: conf.MaxFeeRate}
feePolicy = &pb.FeePolicy{
FeePolicy: &pb.FeePolicy_MaxFeeRate{MaxFeeRate: conf.MaxFeeRate},
}
} else if conf.MaxFee > 0 {
feePolicy = &pb.FeePolicy{
FeePolicy: &pb.FeePolicy_MaxFee{MaxFee: conf.MaxFee},
}
}

response, err := daemonClient.BumpFee(ctx, &pb.BumpFeeRequest{
Expand Down
4 changes: 4 additions & 0 deletions cmd/kaspawallet/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ type sendConfig struct {
UseExistingChangeAddress bool `long:"use-existing-change-address" short:"u" description:"Will use an existing change address (in case no change address was ever used, it will use a new one)"`
MaxFeeRate float64 `long:"max-fee-rate" short:"m" description:"Maximum fee rate in Sompi/gram to use for the transaction. The wallet will take the maximum between the fee estimate from the connected node and this value."`
FeeRate float64 `long:"fee-rate" short:"r" description:"Fee rate in Sompi/gram to use for the transaction. This option will override any fee estimate from the connected node."`
MaxFee uint64 `long:"max-fee" short:"x" description:"Maximum fee in Sompi (not Sompi/gram) to use for the transaction. The wallet will take the maximum between the fee estimate from the connected node and this value. If no other fee policy is specified, it will set the max fee to 1 KAS"`
Verbose bool `long:"show-serialized" short:"s" description:"Show a list of hex encoded sent transactions"`
config.NetworkFlags
}
Expand All @@ -87,6 +88,7 @@ type createUnsignedTransactionConfig struct {
UseExistingChangeAddress bool `long:"use-existing-change-address" short:"u" description:"Will use an existing change address (in case no change address was ever used, it will use a new one)"`
MaxFeeRate float64 `long:"max-fee-rate" short:"m" description:"Maximum fee rate in Sompi/gram to use for the transaction. The wallet will take the maximum between the fee estimate from the connected node and this value."`
FeeRate float64 `long:"fee-rate" short:"r" description:"Fee rate in Sompi/gram to use for the transaction. This option will override any fee estimate from the connected node."`
MaxFee uint64 `long:"max-fee" short:"x" description:"Maximum fee in Sompi (not Sompi/gram) to use for the transaction. The wallet will take the maximum between the fee estimate from the connected node and this value. If no other fee policy is specified, it will set the max fee to 1 KAS"`
config.NetworkFlags
}

Expand Down Expand Up @@ -147,6 +149,7 @@ type bumpFeeUnsignedConfig struct {
UseExistingChangeAddress bool `long:"use-existing-change-address" short:"u" description:"Will use an existing change address (in case no change address was ever used, it will use a new one)"`
MaxFeeRate float64 `long:"max-fee-rate" short:"m" description:"Maximum fee rate in Sompi/gram to use for the transaction. The wallet will take the maximum between the fee estimate from the connected node and this value."`
FeeRate float64 `long:"fee-rate" short:"r" description:"Fee rate in Sompi/gram to use for the transaction. This option will override any fee estimate from the connected node."`
MaxFee uint64 `long:"max-fee" short:"x" description:"Maximum fee in Sompi (not Sompi/gram) to use for the transaction. The wallet will take the maximum between the fee estimate from the connected node and this value. If no other fee policy is specified, it will set the max fee to 1 KAS"`
config.NetworkFlags
}

Expand All @@ -159,6 +162,7 @@ type bumpFeeConfig struct {
UseExistingChangeAddress bool `long:"use-existing-change-address" short:"u" description:"Will use an existing change address (in case no change address was ever used, it will use a new one)"`
MaxFeeRate float64 `long:"max-fee-rate" short:"m" description:"Maximum fee rate in Sompi/gram to use for the transaction. The wallet will take the maximum between the fee estimate from the connected node and this value."`
FeeRate float64 `long:"fee-rate" short:"r" description:"Fee rate in Sompi/gram to use for the transaction. This option will override any fee estimate from the connected node."`
MaxFee uint64 `long:"max-fee" short:"x" description:"Maximum fee in Sompi (not Sompi/gram) to use for the transaction. The wallet will take the maximum between the fee estimate from the connected node and this value. If no other fee policy is specified, it will set the max fee to 1 KAS"`
Verbose bool `long:"show-serialized" short:"s" description:"Show a list of hex encoded sent transactions"`
config.NetworkFlags
}
Expand Down
19 changes: 13 additions & 6 deletions cmd/kaspawallet/create_unsigned_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package main
import (
"context"
"fmt"
"math"
"os"

"github.com/kaspanet/kaspad/cmd/kaspawallet/daemon/client"
Expand All @@ -30,13 +29,21 @@ func createUnsignedTransaction(conf *createUnsignedTransactionConfig) error {
}
}

feePolicy := &pb.FeePolicy{
FeePolicy: &pb.FeePolicy_MaxFeeRate{MaxFeeRate: math.MaxFloat64},
}
var feePolicy *pb.FeePolicy
if conf.FeeRate > 0 {
feePolicy.FeePolicy = &pb.FeePolicy_ExactFeeRate{ExactFeeRate: conf.FeeRate}
feePolicy = &pb.FeePolicy{
FeePolicy: &pb.FeePolicy_ExactFeeRate{
ExactFeeRate: conf.FeeRate,
},
}
} else if conf.MaxFeeRate > 0 {
feePolicy.FeePolicy = &pb.FeePolicy_MaxFeeRate{MaxFeeRate: conf.MaxFeeRate}
feePolicy = &pb.FeePolicy{
FeePolicy: &pb.FeePolicy_MaxFeeRate{MaxFeeRate: conf.MaxFeeRate},
}
} else if conf.MaxFee > 0 {
feePolicy = &pb.FeePolicy{
FeePolicy: &pb.FeePolicy_MaxFee{MaxFee: conf.MaxFee},
}
}

response, err := daemonClient.CreateUnsignedTransactions(ctx, &pb.CreateUnsignedTransactionsRequest{
Expand Down
19 changes: 13 additions & 6 deletions cmd/kaspawallet/send.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package main
import (
"context"
"fmt"
"math"
"os"
"strings"

Expand Down Expand Up @@ -43,13 +42,21 @@ func send(conf *sendConfig) error {
}
}

feePolicy := &pb.FeePolicy{
FeePolicy: &pb.FeePolicy_MaxFeeRate{MaxFeeRate: math.MaxFloat64},
}
var feePolicy *pb.FeePolicy
if conf.FeeRate > 0 {
feePolicy.FeePolicy = &pb.FeePolicy_ExactFeeRate{ExactFeeRate: conf.FeeRate}
feePolicy = &pb.FeePolicy{
FeePolicy: &pb.FeePolicy_ExactFeeRate{
ExactFeeRate: conf.FeeRate,
},
}
} else if conf.MaxFeeRate > 0 {
feePolicy.FeePolicy = &pb.FeePolicy_MaxFeeRate{MaxFeeRate: conf.MaxFeeRate}
feePolicy = &pb.FeePolicy{
FeePolicy: &pb.FeePolicy_MaxFeeRate{MaxFeeRate: conf.MaxFeeRate},
}
} else if conf.MaxFee > 0 {
feePolicy = &pb.FeePolicy{
FeePolicy: &pb.FeePolicy_MaxFee{MaxFee: conf.MaxFee},
}
}

createUnsignedTransactionsResponse, err :=
Expand Down

0 comments on commit d573ca1

Please sign in to comment.