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
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add validations to CLI flags
someone235 committed Sep 16, 2024
commit 484c17ebb12dd4884cbf233946b8266df8ea51e4
12 changes: 5 additions & 7 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
name: Build and upload assets
on:
release:
types: [ published ]
types: [published]

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]
os: [ubuntu-latest, windows-latest, macos-latest]
name: Building, ${{ matrix.os }}
steps:
- name: Fix CRLF on Windows
@@ -19,7 +19,6 @@ jobs:
- name: Check out code into the Go module directory
uses: actions/checkout@v2


- name: Setup Go
uses: actions/setup-go@v2
with:
@@ -31,7 +30,7 @@ jobs:
# `-tags netgo,osusergo` means use pure go replacements for "os/user" and "net"
# `-s -w` strips the binary to produce smaller size binaries
run: |
go build -v -ldflags="-s -w -extldflags=-static" -tags netgo,osusergo -o ./bin/ . ./cmd/...
go build -v -ldflags="-s -w -extldflags=-static" -tags netgo,osusergo -o ./bin/ ./cmd/...
archive="bin/kaspad-${{ github.event.release.tag_name }}-linux.zip"
asset_name="kaspad-${{ github.event.release.tag_name }}-linux.zip"
zip -r "${archive}" ./bin/*
@@ -42,7 +41,7 @@ jobs:
if: runner.os == 'Windows'
shell: bash
run: |
go build -v -ldflags="-s -w" -o bin/ . ./cmd/...
go build -v -ldflags="-s -w" -o bin/ ./cmd/...
archive="bin/kaspad-${{ github.event.release.tag_name }}-win64.zip"
asset_name="kaspad-${{ github.event.release.tag_name }}-win64.zip"
powershell "Compress-Archive bin/* \"${archive}\""
@@ -52,14 +51,13 @@ jobs:
- name: Build on MacOS
if: runner.os == 'macOS'
run: |
go build -v -ldflags="-s -w" -o ./bin/ . ./cmd/...
go build -v -ldflags="-s -w" -o ./bin/ ./cmd/...
archive="bin/kaspad-${{ github.event.release.tag_name }}-osx.zip"
asset_name="kaspad-${{ github.event.release.tag_name }}-osx.zip"
zip -r "${archive}" ./bin/*
echo "archive=${archive}" >> $GITHUB_ENV
echo "asset_name=${asset_name}" >> $GITHUB_ENV


- name: Upload release asset
uses: actions/upload-release-asset@v1
env:
63 changes: 57 additions & 6 deletions cmd/kaspawallet/config.go
Original file line number Diff line number Diff line change
@@ -360,13 +360,25 @@ func parseCommandLine() (subCommand string, config interface{}) {
if err != nil {
printErrorAndExit(err)
}

err = validateBumpFeeConfig(bumpFeeConf)
if err != nil {
printErrorAndExit(err)
}

config = bumpFeeConf
case bumpFeeUnsignedSubCmd:
combineNetworkFlags(&bumpFeeConf.NetworkFlags, &cfg.NetworkFlags)
err := bumpFeeConf.ResolveNetwork(parser)
combineNetworkFlags(&bumpFeeUnsignedConf.NetworkFlags, &cfg.NetworkFlags)
err := bumpFeeUnsignedConf.ResolveNetwork(parser)
if err != nil {
printErrorAndExit(err)
}

err = validateBumpFeeUnsignedConfig(bumpFeeUnsignedConf)
if err != nil {
printErrorAndExit(err)
}

config = bumpFeeUnsignedConf
}

@@ -388,8 +400,8 @@ func validateCreateUnsignedTransactionConf(conf *createUnsignedTransactionConfig
return errors.New("--fee-rate must be a positive number")
}

if conf.MaxFeeRate > 0 && conf.FeeRate > 0 {
return errors.New("at most one of '--max-fee-rate' or '--fee-rate' can be specified")
if boolToUint8(conf.MaxFeeRate > 0)+boolToUint8(conf.FeeRate > 0)+boolToUint8(conf.MaxFee > 0) > 1 {
return errors.New("at most one of '--max-fee-rate', '--fee-rate' or '--max-fee' can be specified")
}

return nil
@@ -410,13 +422,52 @@ func validateSendConfig(conf *sendConfig) error {
return errors.New("--fee-rate must be a positive number")
}

if conf.MaxFeeRate > 0 && conf.FeeRate > 0 {
return errors.New("at most one of '--max-fee-rate' or '--fee-rate' can be specified")
if boolToUint8(conf.MaxFeeRate > 0)+boolToUint8(conf.FeeRate > 0)+boolToUint8(conf.MaxFee > 0) > 1 {
return errors.New("at most one of '--max-fee-rate', '--fee-rate' or '--max-fee' can be specified")
}

return nil
}

func validateBumpFeeConfig(conf *bumpFeeConfig) error {
if conf.MaxFeeRate < 0 {
return errors.New("--max-fee-rate must be a positive number")
}

if conf.FeeRate < 0 {
return errors.New("--fee-rate must be a positive number")
}

if boolToUint8(conf.MaxFeeRate > 0)+boolToUint8(conf.FeeRate > 0)+boolToUint8(conf.MaxFee > 0) > 1 {
return errors.New("at most one of '--max-fee-rate', '--fee-rate' or '--max-fee' can be specified")
}

return nil
}

func validateBumpFeeUnsignedConfig(conf *bumpFeeUnsignedConfig) error {
if conf.MaxFeeRate < 0 {
return errors.New("--max-fee-rate must be a positive number")
}

if conf.FeeRate < 0 {
return errors.New("--fee-rate must be a positive number")
}

if boolToUint8(conf.MaxFeeRate > 0)+boolToUint8(conf.FeeRate > 0)+boolToUint8(conf.MaxFee > 0) > 1 {
return errors.New("at most one of '--max-fee-rate', '--fee-rate' or '--max-fee' can be specified")
}

return nil
}

func boolToUint8(b bool) uint8 {
if b {
return 1
}
return 0
}

func combineNetworkFlags(dst, src *config.NetworkFlags) {
dst.Testnet = dst.Testnet || src.Testnet
dst.Simnet = dst.Simnet || src.Simnet