Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fee estimation to wallet #2291

Merged
merged 32 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
78ca616
Add fee estimation to wallet
someone235 Sep 4, 2024
70bcc31
Add fee rate to kaspawallet parse
someone235 Sep 4, 2024
fc7c5a2
Update go version
someone235 Sep 4, 2024
93726ef
Get rid of golint
someone235 Sep 4, 2024
6901e7d
Add RBF support to wallet
someone235 Sep 5, 2024
2385971
Fix bump_fee UTXO lookup and fix wrong change address
someone235 Sep 11, 2024
fda5557
impl storage mass as per KIP9
michaelsutton Sep 11, 2024
30fcd21
Use CalculateTransactionOverallMass where needed
someone235 Sep 11, 2024
fedbb3b
Some fixes
someone235 Sep 12, 2024
21b515b
Minor typos
michaelsutton Sep 13, 2024
4bb06f5
Fix test
michaelsutton Sep 13, 2024
0c51953
update version
someone235 Sep 13, 2024
8153ec7
BroadcastRBF -> BroadcastReplacement
someone235 Sep 13, 2024
0fcdae6
rc3
someone235 Sep 13, 2024
46ed094
align proto files to only use camel case (fixed on RK as well)
michaelsutton Sep 15, 2024
80d2fdc
Merge branch 'add-wallet-fee-estimation' of https://github.com/someon…
michaelsutton Sep 15, 2024
0beb9ed
Rename to FeePolicy and add MaxFee option + todo
michaelsutton Sep 15, 2024
c0415ea
apply max fee constrains
michaelsutton Sep 15, 2024
d7a7902
increase minChangeTarget to 10kas
michaelsutton Sep 15, 2024
bb8af5d
fmt
michaelsutton Sep 15, 2024
9e659b2
Some fixes
someone235 Sep 15, 2024
0bc5267
fix description: maximum -> minimum
michaelsutton Sep 15, 2024
2b1d3a1
put min feerate check in the correct location
michaelsutton Sep 15, 2024
8e8f7c9
Fix calculateFeeLimits nil handling
someone235 Sep 16, 2024
484c17e
Add validations to CLI flags
someone235 Sep 16, 2024
d233164
Change to rc6
someone235 Sep 16, 2024
89c932d
Add checkTransactionFeeRate
someone235 Sep 18, 2024
af93d5f
Add failed broadcast transactions on send error`
someone235 Sep 18, 2024
2d25c3d
Fix estimateFee change value
someone235 Sep 18, 2024
decbcd8
Estimate fee correctly for --send-all
someone235 Sep 18, 2024
707b3a1
On estimateFee always assume that the recipient has ECDSA address
someone235 Sep 18, 2024
09c6bd0
remove patch version
michaelsutton Oct 22, 2024
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
4 changes: 2 additions & 2 deletions .github/workflows/race.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
strategy:
fail-fast: false
matrix:
branch: [ master, latest ]
branch: [master, latest]
name: Race detection on ${{ matrix.branch }}
steps:
- name: Check out code into the Go module directory
Expand All @@ -22,7 +22,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: 1.19
go-version: 1.23

- name: Set scheduled branch name
shell: bash
Expand Down
14 changes: 4 additions & 10 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,14 @@ on:
types: [opened, synchronize, edited]

jobs:

build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, macos-latest ]
os: [ubuntu-latest, macos-latest]
name: Tests, ${{ matrix.os }}
steps:

- name: Fix CRLF on Windows
if: runner.os == 'Windows'
run: git config --global core.autocrlf false
Expand All @@ -33,8 +31,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: 1.19

go-version: 1.23

# Source: https://github.com/actions/cache/blob/main/examples.md#go---modules
- name: Go Cache
Expand All @@ -49,16 +46,14 @@ jobs:
shell: bash
run: ./build_and_test.sh -v


stability-test-fast:
runs-on: ubuntu-latest
name: Fast stability tests, ${{ github.head_ref }}
steps:

- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: 1.19
go-version: 1.23

- name: Checkout
uses: actions/checkout@v2
Expand All @@ -75,7 +70,6 @@ jobs:
working-directory: stability-tests
run: ./install_and_test.sh


coverage:
runs-on: ubuntu-latest
name: Produce code coverage
Expand All @@ -86,7 +80,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: 1.19
go-version: 1.23

- name: Delete the stability tests from coverage
run: rm -r stability-tests
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Kaspa is an attempt at a proof-of-work cryptocurrency with instant confirmations

## Requirements

Go 1.18 or later.
Go 1.23 or later.

## Installation

Expand Down
8 changes: 8 additions & 0 deletions app/appmessage/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ const (
CmdGetMempoolEntriesByAddressesResponseMessage
CmdGetCoinSupplyRequestMessage
CmdGetCoinSupplyResponseMessage
CmdGetFeeEstimateRequestMessage
CmdGetFeeEstimateResponseMessage
CmdSubmitTransactionReplacementRequestMessage
CmdSubmitTransactionReplacementResponseMessage
)

// ProtocolMessageCommandToString maps all MessageCommands to their string representation
Expand Down Expand Up @@ -300,6 +304,10 @@ var RPCMessageCommandToString = map[MessageCommand]string{
CmdGetMempoolEntriesByAddressesResponseMessage: "GetMempoolEntriesByAddressesResponse",
CmdGetCoinSupplyRequestMessage: "GetCoinSupplyRequest",
CmdGetCoinSupplyResponseMessage: "GetCoinSupplyResponse",
CmdGetFeeEstimateRequestMessage: "GetFeeEstimateRequest",
CmdGetFeeEstimateResponseMessage: "GetFeeEstimateResponse",
CmdSubmitTransactionReplacementRequestMessage: "SubmitTransactionReplacementRequest",
CmdSubmitTransactionReplacementResponseMessage: "SubmitTransactionReplacementResponse",
}

// Message is an interface that describes a kaspa message. A type that
Expand Down
47 changes: 47 additions & 0 deletions app/appmessage/rpc_fee_estimate.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package appmessage

// GetFeeEstimateRequestMessage is an appmessage corresponding to
// its respective RPC message
type GetFeeEstimateRequestMessage struct {
baseMessage
}

// Command returns the protocol command string for the message
func (msg *GetFeeEstimateRequestMessage) Command() MessageCommand {
return CmdGetFeeEstimateRequestMessage
}

// NewGetFeeEstimateRequestMessage returns a instance of the message
func NewGetFeeEstimateRequestMessage() *GetFeeEstimateRequestMessage {
return &GetFeeEstimateRequestMessage{}
}

type RPCFeeRateBucket struct {
Feerate float64
EstimatedSeconds float64
}

type RPCFeeEstimate struct {
PriorityBucket RPCFeeRateBucket
NormalBuckets []RPCFeeRateBucket
LowBuckets []RPCFeeRateBucket
}

// GetCoinSupplyResponseMessage is an appmessage corresponding to
// its respective RPC message
type GetFeeEstimateResponseMessage struct {
baseMessage
Estimate RPCFeeEstimate

Error *RPCError
}

// Command returns the protocol command string for the message
func (msg *GetFeeEstimateResponseMessage) Command() MessageCommand {
return CmdGetFeeEstimateResponseMessage
}

// NewGetFeeEstimateResponseMessage returns a instance of the message
func NewGetFeeEstimateResponseMessage() *GetFeeEstimateResponseMessage {
return &GetFeeEstimateResponseMessage{}
}
41 changes: 41 additions & 0 deletions app/appmessage/rpc_submit_transaction_replacement.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package appmessage

// SubmitTransactionReplacementRequestMessage is an appmessage corresponding to
// its respective RPC message
type SubmitTransactionReplacementRequestMessage struct {
baseMessage
Transaction *RPCTransaction
}

// Command returns the protocol command string for the message
func (msg *SubmitTransactionReplacementRequestMessage) Command() MessageCommand {
return CmdSubmitTransactionReplacementRequestMessage
}

// NewSubmitTransactionReplacementRequestMessage returns a instance of the message
func NewSubmitTransactionReplacementRequestMessage(transaction *RPCTransaction) *SubmitTransactionReplacementRequestMessage {
return &SubmitTransactionReplacementRequestMessage{
Transaction: transaction,
}
}

// SubmitTransactionReplacementResponseMessage is an appmessage corresponding to
// its respective RPC message
type SubmitTransactionReplacementResponseMessage struct {
baseMessage
TransactionID string

Error *RPCError
}

// Command returns the protocol command string for the message
func (msg *SubmitTransactionReplacementResponseMessage) Command() MessageCommand {
return CmdSubmitTransactionReplacementResponseMessage
}

// NewSubmitTransactionReplacementResponseMessage returns a instance of the message
func NewSubmitTransactionReplacementResponseMessage(transactionID string) *SubmitTransactionReplacementResponseMessage {
return &SubmitTransactionReplacementResponseMessage{
TransactionID: transactionID,
}
}
3 changes: 0 additions & 3 deletions build_and_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,10 @@ FLAGS=$@
go version

go get $FLAGS -t -d ./...
GO111MODULE=off go get $FLAGS golang.org/x/lint/golint
go install $FLAGS honnef.co/go/tools/cmd/staticcheck@latest

test -z "$(go fmt ./...)"

golint -set_exit_status ./...

staticcheck -checks SA4006,SA4008,SA4009,SA4010,SA5003,SA1004,SA1014,SA1021,SA1023,SA1024,SA1025,SA1026,SA1027,SA1028,SA2000,SA2001,SA2003,SA4000,SA4001,SA4003,SA4004,SA4011,SA4012,SA4013,SA4014,SA4015,SA4016,SA4017,SA4018,SA4019,SA4020,SA4021,SA4022,SA4023,SA5000,SA5002,SA5004,SA5005,SA5007,SA5008,SA5009,SA5010,SA5011,SA5012,SA6001,SA6002,SA9001,SA9002,SA9003,SA9004,SA9005,SA9006,ST1019 ./...

go build $FLAGS -o kaspad .
Expand Down
4 changes: 2 additions & 2 deletions cmd/kaspactl/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ kaspactl is an RPC client for kaspad

## Requirements

Go 1.19 or later.
Go 1.23 or later.

## Installation

Expand Down Expand Up @@ -50,4 +50,4 @@ For example:
$ kaspactl '{"getBlockDagInfoRequest":{}}'
```

For a list of all available requests check out the [RPC documentation](infrastructure/network/netadapter/server/grpcserver/protowire/rpc.md)
For a list of all available requests check out the [RPC documentation](infrastructure/network/netadapter/server/grpcserver/protowire/rpc.md)
2 changes: 1 addition & 1 deletion cmd/kaspactl/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -- multistage docker build: stage #1: build stage
FROM golang:1.19-alpine AS build
FROM golang:1.23-alpine AS build

RUN mkdir -p /go/src/github.com/kaspanet/kaspad

Expand Down
7 changes: 4 additions & 3 deletions cmd/kaspaminer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Kaspaminer is a CPU-based miner for kaspad

## Requirements

Go 1.19 or later.
Go 1.23 or later.

## Installation

Expand All @@ -30,7 +30,7 @@ $ go install .
- Kapaminer should now be installed in `$(go env GOPATH)/bin`. If you did
not already add the bin directory to your system path during Go installation,
you are encouraged to do so now.

## Usage

The full kaspaminer configuration options can be seen with:
Expand All @@ -40,6 +40,7 @@ $ kaspaminer --help
```

But the minimum configuration needed to run it is:

```bash
$ kaspaminer --miningaddr=<YOUR_MINING_ADDRESS>
```
```
2 changes: 1 addition & 1 deletion cmd/kaspaminer/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -- multistage docker build: stage #1: build stage
FROM golang:1.19-alpine AS build
FROM golang:1.23-alpine AS build

RUN mkdir -p /go/src/github.com/kaspanet/kaspad

Expand Down
56 changes: 56 additions & 0 deletions cmd/kaspawallet/broadcast_replacement.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package main

import (
"context"
"fmt"
"io/ioutil"
"strings"

"github.com/kaspanet/kaspad/cmd/kaspawallet/daemon/client"
"github.com/kaspanet/kaspad/cmd/kaspawallet/daemon/pb"
"github.com/pkg/errors"
)

func broadcastReplacement(conf *broadcastConfig) 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 conf.Transactions == "" && conf.TransactionsFile == "" {
return errors.Errorf("Either --transaction or --transaction-file is required")
}
if conf.Transactions != "" && conf.TransactionsFile != "" {
return errors.Errorf("Both --transaction and --transaction-file cannot be passed at the same time")
}

transactionsHex := conf.Transactions
if conf.TransactionsFile != "" {
transactionHexBytes, err := ioutil.ReadFile(conf.TransactionsFile)
if err != nil {
return errors.Wrapf(err, "Could not read hex from %s", conf.TransactionsFile)
}
transactionsHex = strings.TrimSpace(string(transactionHexBytes))
}

transactions, err := decodeTransactionsFromHex(transactionsHex)
if err != nil {
return err
}

response, err := daemonClient.BroadcastRBF(ctx, &pb.BroadcastRequest{Transactions: transactions})
if err != nil {
return err
}
fmt.Println("Transactions were sent successfully")
fmt.Println("Transaction ID(s): ")
for _, txID := range response.TxIDs {
fmt.Printf("\t%s\n", txID)
}

return nil
}
Loading
Loading