mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-03-30 15:08:33 +00:00

* Add fee estimation to wallet * Add fee rate to kaspawallet parse * Update go version * Get rid of golint * Add RBF support to wallet * Fix bump_fee UTXO lookup and fix wrong change address * impl storage mass as per KIP9 * Use CalculateTransactionOverallMass where needed * Some fixes * Minor typos * Fix test * update version * BroadcastRBF -> BroadcastReplacement * rc3 * align proto files to only use camel case (fixed on RK as well) * Rename to FeePolicy and add MaxFee option + todo * apply max fee constrains * increase minChangeTarget to 10kas * fmt * Some fixes * fix description: maximum -> minimum * put min feerate check in the correct location * Fix calculateFeeLimits nil handling * Add validations to CLI flags * Change to rc6 * Add checkTransactionFeeRate * Add failed broadcast transactions on send error` * Fix estimateFee change value * Estimate fee correctly for --send-all * On estimateFee always assume that the recipient has ECDSA address * remove patch version --------- Co-authored-by: Michael Sutton <msutton@cs.huji.ac.il>
59 lines
1.3 KiB
Go
59 lines
1.3 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/kaspanet/kaspad/cmd/kaspawallet/daemon/client"
|
|
"github.com/kaspanet/kaspad/cmd/kaspawallet/daemon/pb"
|
|
"github.com/kaspanet/kaspad/cmd/kaspawallet/daemon/server"
|
|
)
|
|
|
|
func bumpFeeUnsigned(conf *bumpFeeUnsignedConfig) error {
|
|
daemonClient, tearDown, err := client.Connect(conf.DaemonAddress)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
defer tearDown()
|
|
|
|
ctx, cancel := context.WithTimeout(context.Background(), daemonTimeout)
|
|
defer cancel()
|
|
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
var feePolicy *pb.FeePolicy
|
|
if conf.FeeRate > 0 {
|
|
feePolicy = &pb.FeePolicy{
|
|
FeePolicy: &pb.FeePolicy_ExactFeeRate{
|
|
ExactFeeRate: conf.FeeRate,
|
|
},
|
|
}
|
|
} else if conf.MaxFeeRate > 0 {
|
|
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{
|
|
TxID: conf.TxID,
|
|
From: conf.FromAddresses,
|
|
UseExistingChangeAddress: conf.UseExistingChangeAddress,
|
|
FeePolicy: feePolicy,
|
|
})
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
fmt.Fprintln(os.Stderr, "Created unsigned transaction")
|
|
fmt.Println(server.EncodeTransactionsToHex(response.Transactions))
|
|
|
|
return nil
|
|
}
|