mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-11-24 06:25:55 +00:00
Merge 1ad8b2d3cb78427f13d2aa1f068adc20bdb84f23 into 5a3b8a00669a85f467c49e9913db7cc6092b41c1
This commit is contained in:
commit
a7119061e5
@ -113,12 +113,13 @@ type newAddressConfig struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type startDaemonConfig struct {
|
type startDaemonConfig struct {
|
||||||
KeysFile string `long:"keys-file" short:"f" description:"Keys file location (default: ~/.kaspawallet/keys.json (*nix), %USERPROFILE%\\AppData\\Local\\Kaspawallet\\key.json (Windows))"`
|
KeysFile string `long:"keys-file" short:"f" description:"Keys file location (default: ~/.kaspawallet/keys.json (*nix), %USERPROFILE%\\AppData\\Local\\Kaspawallet\\key.json (Windows))"`
|
||||||
Password string `long:"password" short:"p" description:"Wallet password"`
|
Password string `long:"password" short:"p" description:"Wallet password"`
|
||||||
RPCServer string `long:"rpcserver" short:"s" description:"RPC server to connect to"`
|
RPCServer string `long:"rpcserver" short:"s" description:"RPC server to connect to"`
|
||||||
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"`
|
||||||
|
ValidUsedOutpointsTime uint32 `long:"valid-used-outpoints-time" short:"t" description:"Used outpoints will be valid after seconds (default: 60)"`
|
||||||
config.NetworkFlags
|
config.NetworkFlags
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,8 +182,9 @@ func parseCommandLine() (subCommand string, config interface{}) {
|
|||||||
"the funds. Use only on safe environment.", dumpUnencryptedDataConf)
|
"the funds. Use only on safe environment.", dumpUnencryptedDataConf)
|
||||||
|
|
||||||
startDaemonConf := &startDaemonConfig{
|
startDaemonConf := &startDaemonConfig{
|
||||||
RPCServer: defaultRPCServer,
|
RPCServer: defaultRPCServer,
|
||||||
Listen: defaultListen,
|
Listen: defaultListen,
|
||||||
|
ValidUsedOutpointsTime: uint32(60),
|
||||||
}
|
}
|
||||||
parser.AddCommand(startDaemonSubCmd, "Start the wallet daemon", "Start the wallet daemon", startDaemonConf)
|
parser.AddCommand(startDaemonSubCmd, "Start the wallet daemon", "Start the wallet daemon", startDaemonConf)
|
||||||
|
|
||||||
|
|||||||
@ -118,7 +118,7 @@ func (s *server) selectUTXOs(spendAmount uint64, isSendAll bool, feePerInput uin
|
|||||||
}
|
}
|
||||||
|
|
||||||
if broadcastTime, ok := s.usedOutpoints[*utxo.Outpoint]; ok {
|
if broadcastTime, ok := s.usedOutpoints[*utxo.Outpoint]; ok {
|
||||||
if time.Since(broadcastTime) > time.Minute {
|
if time.Since(broadcastTime) > s.validUsedOutpointsTime {
|
||||||
delete(s.usedOutpoints, *utxo.Outpoint)
|
delete(s.usedOutpoints, *utxo.Outpoint)
|
||||||
} else {
|
} else {
|
||||||
continue
|
continue
|
||||||
|
|||||||
@ -42,6 +42,7 @@ type server struct {
|
|||||||
isLogFinalProgressLineShown bool
|
isLogFinalProgressLineShown bool
|
||||||
maxUsedAddressesForLog uint32
|
maxUsedAddressesForLog uint32
|
||||||
maxProcessedAddressesForLog uint32
|
maxProcessedAddressesForLog uint32
|
||||||
|
validUsedOutpointsTime time.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
// MaxDaemonSendMsgSize is the max send message size used for the daemon server.
|
// MaxDaemonSendMsgSize is the max send message size used for the daemon server.
|
||||||
@ -49,7 +50,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, validUsedOutpointsTime uint32) error {
|
||||||
initLog(defaultLogFile, defaultErrLogFile)
|
initLog(defaultLogFile, defaultErrLogFile)
|
||||||
|
|
||||||
defer panics.HandlePanic(log, "MAIN", nil)
|
defer panics.HandlePanic(log, "MAIN", nil)
|
||||||
@ -95,6 +96,7 @@ func Start(params *dagconfig.Params, listen, rpcServer string, keysFilePath stri
|
|||||||
isLogFinalProgressLineShown: false,
|
isLogFinalProgressLineShown: false,
|
||||||
maxUsedAddressesForLog: 0,
|
maxUsedAddressesForLog: 0,
|
||||||
maxProcessedAddressesForLog: 0,
|
maxProcessedAddressesForLog: 0,
|
||||||
|
validUsedOutpointsTime: time.Duration(validUsedOutpointsTime) * time.Second,
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Infof("Read, syncing the wallet...")
|
log.Infof("Read, syncing the wallet...")
|
||||||
|
|||||||
@ -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.ValidUsedOutpointsTime)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user