mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-11-24 22:45:50 +00:00
Add MinFeePerTx argument to start-daemon
This commit is contained in:
parent
86b89065cf
commit
01c81143ab
@ -1,9 +1,10 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
|
|
||||||
"github.com/kaspanet/kaspad/infrastructure/config"
|
"github.com/kaspanet/kaspad/infrastructure/config"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"os"
|
|
||||||
|
|
||||||
"github.com/jessevdk/go-flags"
|
"github.com/jessevdk/go-flags"
|
||||||
)
|
)
|
||||||
@ -121,6 +122,7 @@ type startDaemonConfig struct {
|
|||||||
Listen string `long:"listen" short:"l" description:"Address to listen on (default: 0.0.0.0:8082)"`
|
Listen string `long:"listen" short:"l" description:"Address to listen on (default: 0.0.0.0:8082)"`
|
||||||
Timeout uint32 `long:"wait-timeout" short:"w" description:"Waiting timeout for RPC calls, seconds (default: 30 s)"`
|
Timeout uint32 `long:"wait-timeout" short:"w" description:"Waiting timeout for RPC calls, seconds (default: 30 s)"`
|
||||||
Profile string `long:"profile" description:"Enable HTTP profiling on given port -- NOTE port must be between 1024 and 65536"`
|
Profile string `long:"profile" description:"Enable HTTP profiling on given port -- NOTE port must be between 1024 and 65536"`
|
||||||
|
MinFeePerTx uint64 `long:"min-fee-per-tx" description:"Minimum fee per transaction (in sompis) (default: 0)"`
|
||||||
config.NetworkFlags
|
config.NetworkFlags
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -126,6 +126,10 @@ func (s *server) selectUTXOs(spendAmount uint64, isSendAll bool, feePerInput uin
|
|||||||
totalValue += utxo.UTXOEntry.Amount()
|
totalValue += utxo.UTXOEntry.Amount()
|
||||||
|
|
||||||
fee := feePerInput * uint64(len(selectedUTXOs))
|
fee := feePerInput * uint64(len(selectedUTXOs))
|
||||||
|
if fee < s.minFeePerTx {
|
||||||
|
fee = s.minFeePerTx
|
||||||
|
}
|
||||||
|
|
||||||
totalSpend := spendAmount + fee
|
totalSpend := spendAmount + fee
|
||||||
// Two break cases (if not send all):
|
// Two break cases (if not send all):
|
||||||
// 1. totalValue == totalSpend, so there's no change needed -> number of outputs = 1, so a single input is sufficient
|
// 1. totalValue == totalSpend, so there's no change needed -> number of outputs = 1, so a single input is sufficient
|
||||||
@ -138,6 +142,10 @@ func (s *server) selectUTXOs(spendAmount uint64, isSendAll bool, feePerInput uin
|
|||||||
}
|
}
|
||||||
|
|
||||||
fee := feePerInput * uint64(len(selectedUTXOs))
|
fee := feePerInput * uint64(len(selectedUTXOs))
|
||||||
|
if fee < s.minFeePerTx {
|
||||||
|
fee = s.minFeePerTx
|
||||||
|
}
|
||||||
|
|
||||||
var totalSpend uint64
|
var totalSpend uint64
|
||||||
if isSendAll {
|
if isSendAll {
|
||||||
totalSpend = totalValue
|
totalSpend = totalValue
|
||||||
|
|||||||
@ -34,6 +34,7 @@ type server struct {
|
|||||||
backgroundRPCClient *rpcclient.RPCClient // RPC client dedicated for address and UTXO background fetching
|
backgroundRPCClient *rpcclient.RPCClient // RPC client dedicated for address and UTXO background fetching
|
||||||
params *dagconfig.Params
|
params *dagconfig.Params
|
||||||
coinbaseMaturity uint64 // Is different from default if we use testnet-11
|
coinbaseMaturity uint64 // Is different from default if we use testnet-11
|
||||||
|
minFeePerTx uint64
|
||||||
|
|
||||||
lock sync.RWMutex
|
lock sync.RWMutex
|
||||||
utxosSortedByAmount []*walletUTXO
|
utxosSortedByAmount []*walletUTXO
|
||||||
@ -57,7 +58,7 @@ type server struct {
|
|||||||
const MaxDaemonSendMsgSize = 100_000_000
|
const MaxDaemonSendMsgSize = 100_000_000
|
||||||
|
|
||||||
// Start starts the kaspawalletd server
|
// Start starts the kaspawalletd server
|
||||||
func Start(params *dagconfig.Params, listen, rpcServer string, keysFilePath string, profile string, timeout uint32) error {
|
func Start(params *dagconfig.Params, listen, rpcServer string, keysFilePath string, profile string, timeout uint32, minFeePerTx uint64) error {
|
||||||
initLog(defaultLogFile, defaultErrLogFile)
|
initLog(defaultLogFile, defaultErrLogFile)
|
||||||
|
|
||||||
defer panics.HandlePanic(log, "MAIN", nil)
|
defer panics.HandlePanic(log, "MAIN", nil)
|
||||||
@ -110,6 +111,7 @@ func Start(params *dagconfig.Params, listen, rpcServer string, keysFilePath stri
|
|||||||
backgroundRPCClient: backgroundRPCClient,
|
backgroundRPCClient: backgroundRPCClient,
|
||||||
params: params,
|
params: params,
|
||||||
coinbaseMaturity: coinbaseMaturity,
|
coinbaseMaturity: coinbaseMaturity,
|
||||||
|
minFeePerTx: minFeePerTx,
|
||||||
utxosSortedByAmount: []*walletUTXO{},
|
utxosSortedByAmount: []*walletUTXO{},
|
||||||
nextSyncStartIndex: 0,
|
nextSyncStartIndex: 0,
|
||||||
keysFile: keysFile,
|
keysFile: keysFile,
|
||||||
|
|||||||
@ -3,5 +3,5 @@ package main
|
|||||||
import "github.com/kaspanet/kaspad/cmd/kaspawallet/daemon/server"
|
import "github.com/kaspanet/kaspad/cmd/kaspawallet/daemon/server"
|
||||||
|
|
||||||
func startDaemon(conf *startDaemonConfig) error {
|
func startDaemon(conf *startDaemonConfig) error {
|
||||||
return server.Start(conf.NetParams(), conf.Listen, conf.RPCServer, conf.KeysFile, conf.Profile, conf.Timeout)
|
return server.Start(conf.NetParams(), conf.Listen, conf.RPCServer, conf.KeysFile, conf.Profile, conf.Timeout, conf.MinFeePerTx)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user