multi: fix overflow on feerate

As we multiply the feerate by 1000, if the uint16 feerate is set higher
than 66 we would encounter an overflow and as such we could never
have a higher feerate than 65.
pull/70/head
sputn1ck 12 months ago
parent 2c2de636a8
commit 4b804f7024
No known key found for this signature in database
GPG Key ID: 671103D881A5F0E4

@ -42,7 +42,7 @@ type closePoolAccountCommand struct {
AuctioneerKey string AuctioneerKey string
Publish bool Publish bool
SweepAddr string SweepAddr string
FeeRate uint16 FeeRate uint32
MinExpiry uint32 MinExpiry uint32
MaxNumBlocks uint32 MaxNumBlocks uint32
@ -91,7 +91,7 @@ obtained by running 'pool accounts list' `,
cc.cmd.Flags().StringVar( cc.cmd.Flags().StringVar(
&cc.SweepAddr, "sweepaddr", "", "address to sweep the funds to", &cc.SweepAddr, "sweepaddr", "", "address to sweep the funds to",
) )
cc.cmd.Flags().Uint16Var( cc.cmd.Flags().Uint32Var(
&cc.FeeRate, "feerate", defaultFeeSatPerVByte, "fee rate to "+ &cc.FeeRate, "feerate", defaultFeeSatPerVByte, "fee rate to "+
"use for the sweep transaction in sat/vByte", "use for the sweep transaction in sat/vByte",
) )
@ -158,7 +158,7 @@ func (c *closePoolAccountCommand) Execute(_ *cobra.Command, _ []string) error {
func closePoolAccount(extendedKey *hdkeychain.ExtendedKey, apiURL string, func closePoolAccount(extendedKey *hdkeychain.ExtendedKey, apiURL string,
outpoint *wire.OutPoint, auctioneerKey *btcec.PublicKey, outpoint *wire.OutPoint, auctioneerKey *btcec.PublicKey,
sweepAddr string, publish bool, feeRate uint16, minExpiry, sweepAddr string, publish bool, feeRate uint32, minExpiry,
maxNumBlocks, maxNumAccounts, maxNumBatchKeys uint32) error { maxNumBlocks, maxNumAccounts, maxNumBatchKeys uint32) error {
signer := &lnd.Signer{ signer := &lnd.Signer{

@ -25,7 +25,7 @@ type recoverLoopInCommand struct {
Vout uint32 Vout uint32
SwapHash string SwapHash string
SweepAddr string SweepAddr string
FeeRate uint16 FeeRate uint32
StartKeyIndex int StartKeyIndex int
NumTries int NumTries int
@ -73,7 +73,7 @@ func newRecoverLoopInCommand() *cobra.Command {
&cc.SweepAddr, "sweep_addr", "", "address to recover "+ &cc.SweepAddr, "sweep_addr", "", "address to recover "+
"the funds to", "the funds to",
) )
cc.cmd.Flags().Uint16Var( cc.cmd.Flags().Uint32Var(
&cc.FeeRate, "feerate", 0, "fee rate to "+ &cc.FeeRate, "feerate", 0, "fee rate to "+
"use for the sweep transaction in sat/vByte", "use for the sweep transaction in sat/vByte",
) )

@ -45,7 +45,7 @@ type rescueFundingCommand struct {
RemotePubKey string RemotePubKey string
SweepAddr string SweepAddr string
FeeRate uint16 FeeRate uint32
APIURL string APIURL string
rootKey *rootKey rootKey *rootKey
@ -115,7 +115,7 @@ chantools rescuefunding \
cc.cmd.Flags().StringVar( cc.cmd.Flags().StringVar(
&cc.SweepAddr, "sweepaddr", "", "address to sweep the funds to", &cc.SweepAddr, "sweepaddr", "", "address to sweep the funds to",
) )
cc.cmd.Flags().Uint16Var( cc.cmd.Flags().Uint32Var(
&cc.FeeRate, "feerate", defaultFeeSatPerVByte, "fee rate to "+ &cc.FeeRate, "feerate", defaultFeeSatPerVByte, "fee rate to "+
"use for the sweep transaction in sat/vByte", "use for the sweep transaction in sat/vByte",
) )

@ -29,7 +29,7 @@ type sweepRemoteClosedCommand struct {
APIURL string APIURL string
Publish bool Publish bool
SweepAddr string SweepAddr string
FeeRate uint16 FeeRate uint32
rootKey *rootKey rootKey *rootKey
cmd *cobra.Command cmd *cobra.Command
@ -77,7 +77,7 @@ Supported remote force-closed channel types are:
cc.cmd.Flags().StringVar( cc.cmd.Flags().StringVar(
&cc.SweepAddr, "sweepaddr", "", "address to sweep the funds to", &cc.SweepAddr, "sweepaddr", "", "address to sweep the funds to",
) )
cc.cmd.Flags().Uint16Var( cc.cmd.Flags().Uint32Var(
&cc.FeeRate, "feerate", defaultFeeSatPerVByte, "fee rate to "+ &cc.FeeRate, "feerate", defaultFeeSatPerVByte, "fee rate to "+
"use for the sweep transaction in sat/vByte", "use for the sweep transaction in sat/vByte",
) )
@ -122,7 +122,7 @@ type targetAddr struct {
} }
func sweepRemoteClosed(extendedKey *hdkeychain.ExtendedKey, apiURL, func sweepRemoteClosed(extendedKey *hdkeychain.ExtendedKey, apiURL,
sweepAddr string, recoveryWindow uint32, feeRate uint16, sweepAddr string, recoveryWindow uint32, feeRate uint32,
publish bool) error { publish bool) error {
var ( var (

@ -29,7 +29,7 @@ type sweepTimeLockCommand struct {
Publish bool Publish bool
SweepAddr string SweepAddr string
MaxCsvLimit uint16 MaxCsvLimit uint16
FeeRate uint16 FeeRate uint32
rootKey *rootKey rootKey *rootKey
inputs *inputFlags inputs *inputFlags
@ -71,7 +71,7 @@ parameter to 144.`,
&cc.MaxCsvLimit, "maxcsvlimit", defaultCsvLimit, "maximum CSV "+ &cc.MaxCsvLimit, "maxcsvlimit", defaultCsvLimit, "maximum CSV "+
"limit to use", "limit to use",
) )
cc.cmd.Flags().Uint16Var( cc.cmd.Flags().Uint32Var(
&cc.FeeRate, "feerate", defaultFeeSatPerVByte, "fee rate to "+ &cc.FeeRate, "feerate", defaultFeeSatPerVByte, "fee rate to "+
"use for the sweep transaction in sat/vByte", "use for the sweep transaction in sat/vByte",
) )
@ -125,7 +125,7 @@ type sweepTarget struct {
func sweepTimeLockFromSummary(extendedKey *hdkeychain.ExtendedKey, apiURL string, func sweepTimeLockFromSummary(extendedKey *hdkeychain.ExtendedKey, apiURL string,
entries []*dataformat.SummaryEntry, sweepAddr string, entries []*dataformat.SummaryEntry, sweepAddr string,
maxCsvTimeout uint16, publish bool, feeRate uint16) error { maxCsvTimeout uint16, publish bool, feeRate uint32) error {
targets := make([]*sweepTarget, 0, len(entries)) targets := make([]*sweepTarget, 0, len(entries))
for _, entry := range entries { for _, entry := range entries {
@ -213,7 +213,7 @@ func sweepTimeLockFromSummary(extendedKey *hdkeychain.ExtendedKey, apiURL string
func sweepTimeLock(extendedKey *hdkeychain.ExtendedKey, apiURL string, func sweepTimeLock(extendedKey *hdkeychain.ExtendedKey, apiURL string,
targets []*sweepTarget, sweepAddr string, maxCsvTimeout uint16, targets []*sweepTarget, sweepAddr string, maxCsvTimeout uint16,
publish bool, feeRate uint16) error { publish bool, feeRate uint32) error {
// Create signer and transaction template. // Create signer and transaction template.
signer := &lnd.Signer{ signer := &lnd.Signer{

@ -30,7 +30,7 @@ type sweepTimeLockManualCommand struct {
Publish bool Publish bool
SweepAddr string SweepAddr string
MaxCsvLimit uint16 MaxCsvLimit uint16
FeeRate uint16 FeeRate uint32
TimeLockAddr string TimeLockAddr string
RemoteRevocationBasePoint string RemoteRevocationBasePoint string
@ -92,7 +92,7 @@ address is always the one that's longer (because it's P2WSH and not P2PKH).`,
"maximum number of channel updates to try, set to maximum "+ "maximum number of channel updates to try, set to maximum "+
"number of times the channel was used", "number of times the channel was used",
) )
cc.cmd.Flags().Uint16Var( cc.cmd.Flags().Uint32Var(
&cc.FeeRate, "feerate", defaultFeeSatPerVByte, "fee rate to "+ &cc.FeeRate, "feerate", defaultFeeSatPerVByte, "fee rate to "+
"use for the sweep transaction in sat/vByte", "use for the sweep transaction in sat/vByte",
) )
@ -144,7 +144,7 @@ func (c *sweepTimeLockManualCommand) Execute(_ *cobra.Command, _ []string) error
func sweepTimeLockManual(extendedKey *hdkeychain.ExtendedKey, apiURL string, func sweepTimeLockManual(extendedKey *hdkeychain.ExtendedKey, apiURL string,
sweepAddr, timeLockAddr string, remoteRevPoint *btcec.PublicKey, sweepAddr, timeLockAddr string, remoteRevPoint *btcec.PublicKey,
maxCsvTimeout, maxNumChannels uint16, maxNumChanUpdates uint64, maxCsvTimeout, maxNumChannels uint16, maxNumChanUpdates uint64,
publish bool, feeRate uint16) error { publish bool, feeRate uint32) error {
// First of all, we need to parse the lock addr and make sure we can // First of all, we need to parse the lock addr and make sure we can
// brute force the script with the information we have. If not, we can't // brute force the script with the information we have. If not, we can't

@ -26,7 +26,7 @@ import (
type zombieRecoveryMakeOfferCommand struct { type zombieRecoveryMakeOfferCommand struct {
Node1 string Node1 string
Node2 string Node2 string
FeeRate uint16 FeeRate uint32
rootKey *rootKey rootKey *rootKey
cmd *cobra.Command cmd *cobra.Command
@ -60,7 +60,7 @@ a counter offer.`,
&cc.Node2, "node2_keys", "", "the JSON file generated in the"+ &cc.Node2, "node2_keys", "", "the JSON file generated in the"+
"previous step ('preparekeys') command of node 2", "previous step ('preparekeys') command of node 2",
) )
cc.cmd.Flags().Uint16Var( cc.cmd.Flags().Uint32Var(
&cc.FeeRate, "feerate", defaultFeeSatPerVByte, "fee rate to "+ &cc.FeeRate, "feerate", defaultFeeSatPerVByte, "fee rate to "+
"use for the sweep transaction in sat/vByte", "use for the sweep transaction in sat/vByte",
) )

@ -32,7 +32,7 @@ chantools closepoolaccount \
--apiurl string API URL to use (must be esplora compatible) (default "https://blockstream.info/api") --apiurl string API URL to use (must be esplora compatible) (default "https://blockstream.info/api")
--auctioneerkey string the auctioneer's static public key (default "028e87bdd134238f8347f845d9ecc827b843d0d1e27cdcb46da704d916613f4fce") --auctioneerkey string the auctioneer's static public key (default "028e87bdd134238f8347f845d9ecc827b843d0d1e27cdcb46da704d916613f4fce")
--bip39 read a classic BIP39 seed and passphrase from the terminal instead of asking for lnd seed format or providing the --rootkey flag --bip39 read a classic BIP39 seed and passphrase from the terminal instead of asking for lnd seed format or providing the --rootkey flag
--feerate uint16 fee rate to use for the sweep transaction in sat/vByte (default 30) --feerate uint32 fee rate to use for the sweep transaction in sat/vByte (default 30)
-h, --help help for closepoolaccount -h, --help help for closepoolaccount
--maxnumaccounts uint32 the number of account indices to try at most (default 20) --maxnumaccounts uint32 the number of account indices to try at most (default 20)
--maxnumbatchkeys uint32 the number of batch keys to try at most (default 500) --maxnumbatchkeys uint32 the number of batch keys to try at most (default 500)

@ -23,7 +23,7 @@ chantools recoverloopin \
``` ```
--apiurl string API URL to use (must be esplora compatible) (default "https://blockstream.info/api") --apiurl string API URL to use (must be esplora compatible) (default "https://blockstream.info/api")
--bip39 read a classic BIP39 seed and passphrase from the terminal instead of asking for lnd seed format or providing the --rootkey flag --bip39 read a classic BIP39 seed and passphrase from the terminal instead of asking for lnd seed format or providing the --rootkey flag
--feerate uint16 fee rate to use for the sweep transaction in sat/vByte --feerate uint32 fee rate to use for the sweep transaction in sat/vByte
-h, --help help for recoverloopin -h, --help help for recoverloopin
--loop_db_path string path to the loop database file --loop_db_path string path to the loop database file
--num_tries int number of tries to try to find the correct key index (default 1000) --num_tries int number of tries to try to find the correct key index (default 1000)

@ -44,7 +44,7 @@ chantools rescuefunding \
--channeldb string lnd channel.db file to rescue a channel from; must contain the pending channel specified with --channelpoint --channeldb string lnd channel.db file to rescue a channel from; must contain the pending channel specified with --channelpoint
--confirmedchannelpoint string channel outpoint that got confirmed on chain (<txid>:<txindex>); normally this is the same as the --dbchannelpoint so it will be set to that value ifthis is left empty --confirmedchannelpoint string channel outpoint that got confirmed on chain (<txid>:<txindex>); normally this is the same as the --dbchannelpoint so it will be set to that value ifthis is left empty
--dbchannelpoint string funding transaction outpoint of the channel to rescue (<txid>:<txindex>) as it is recorded in the DB --dbchannelpoint string funding transaction outpoint of the channel to rescue (<txid>:<txindex>) as it is recorded in the DB
--feerate uint16 fee rate to use for the sweep transaction in sat/vByte (default 30) --feerate uint32 fee rate to use for the sweep transaction in sat/vByte (default 30)
-h, --help help for rescuefunding -h, --help help for rescuefunding
--localkeyindex uint32 in case a channel DB is not available (but perhaps a channel backup file), the derivation index of the local multisig public key can be specified manually --localkeyindex uint32 in case a channel DB is not available (but perhaps a channel backup file), the derivation index of the local multisig public key can be specified manually
--remotepubkey string in case a channel DB is not available (but perhaps a channel backup file), the remote multisig public key can be specified manually --remotepubkey string in case a channel DB is not available (but perhaps a channel backup file), the remote multisig public key can be specified manually

@ -34,7 +34,7 @@ chantools sweepremoteclosed \
``` ```
--apiurl string API URL to use (must be esplora compatible) (default "https://blockstream.info/api") --apiurl string API URL to use (must be esplora compatible) (default "https://blockstream.info/api")
--bip39 read a classic BIP39 seed and passphrase from the terminal instead of asking for lnd seed format or providing the --rootkey flag --bip39 read a classic BIP39 seed and passphrase from the terminal instead of asking for lnd seed format or providing the --rootkey flag
--feerate uint16 fee rate to use for the sweep transaction in sat/vByte (default 30) --feerate uint32 fee rate to use for the sweep transaction in sat/vByte (default 30)
-h, --help help for sweepremoteclosed -h, --help help for sweepremoteclosed
--publish publish sweep TX to the chain API instead of just printing the TX --publish publish sweep TX to the chain API instead of just printing the TX
--recoverywindow uint32 number of keys to scan per derivation path (default 200) --recoverywindow uint32 number of keys to scan per derivation path (default 200)

@ -31,7 +31,7 @@ chantools sweeptimelock \
``` ```
--apiurl string API URL to use (must be esplora compatible) (default "https://blockstream.info/api") --apiurl string API URL to use (must be esplora compatible) (default "https://blockstream.info/api")
--bip39 read a classic BIP39 seed and passphrase from the terminal instead of asking for lnd seed format or providing the --rootkey flag --bip39 read a classic BIP39 seed and passphrase from the terminal instead of asking for lnd seed format or providing the --rootkey flag
--feerate uint16 fee rate to use for the sweep transaction in sat/vByte (default 30) --feerate uint32 fee rate to use for the sweep transaction in sat/vByte (default 30)
--fromchanneldb string channel input is in the format of an lnd channel.db file --fromchanneldb string channel input is in the format of an lnd channel.db file
--fromsummary string channel input is in the format of chantool's channel summary; specify '-' to read from stdin --fromsummary string channel input is in the format of chantool's channel summary; specify '-' to read from stdin
-h, --help help for sweeptimelock -h, --help help for sweeptimelock

@ -36,7 +36,7 @@ chantools sweeptimelockmanual \
``` ```
--apiurl string API URL to use (must be esplora compatible) (default "https://blockstream.info/api") --apiurl string API URL to use (must be esplora compatible) (default "https://blockstream.info/api")
--bip39 read a classic BIP39 seed and passphrase from the terminal instead of asking for lnd seed format or providing the --rootkey flag --bip39 read a classic BIP39 seed and passphrase from the terminal instead of asking for lnd seed format or providing the --rootkey flag
--feerate uint16 fee rate to use for the sweep transaction in sat/vByte (default 30) --feerate uint32 fee rate to use for the sweep transaction in sat/vByte (default 30)
--fromchanneldb string channel input is in the format of an lnd channel.db file --fromchanneldb string channel input is in the format of an lnd channel.db file
--fromsummary string channel input is in the format of chantool's channel summary; specify '-' to read from stdin --fromsummary string channel input is in the format of chantool's channel summary; specify '-' to read from stdin
-h, --help help for sweeptimelockmanual -h, --help help for sweeptimelockmanual

@ -29,7 +29,7 @@ chantools zombierecovery makeoffer \
``` ```
--bip39 read a classic BIP39 seed and passphrase from the terminal instead of asking for lnd seed format or providing the --rootkey flag --bip39 read a classic BIP39 seed and passphrase from the terminal instead of asking for lnd seed format or providing the --rootkey flag
--feerate uint16 fee rate to use for the sweep transaction in sat/vByte (default 30) --feerate uint32 fee rate to use for the sweep transaction in sat/vByte (default 30)
-h, --help help for makeoffer -h, --help help for makeoffer
--node1_keys string the JSON file generated in theprevious step ('preparekeys') command of node 1 --node1_keys string the JSON file generated in theprevious step ('preparekeys') command of node 1
--node2_keys string the JSON file generated in theprevious step ('preparekeys') command of node 2 --node2_keys string the JSON file generated in theprevious step ('preparekeys') command of node 2

Loading…
Cancel
Save