restrict fee rate to int

This commit is contained in:
Alex Bosworth 2024-11-01 07:21:53 -07:00
parent 407511f2bc
commit df785cf22b
No known key found for this signature in database
GPG key ID: E80D2F3F311FD87E
5 changed files with 898 additions and 217 deletions

View file

@ -1,5 +1,9 @@
# Versions
## 19.4.4
- `fund`: Explicitly disallow funding of txs with fractional fee rates
## 19.4.3
- `rebalance`: Correct for new fee buffer on close-to-balance rebalances

2
bos
View file

@ -863,7 +863,7 @@ prog
.argument('<address_amount...>', 'Address and amount to send')
.option('--broadcast', 'Broadcast the signed transaction')
.option('--dryrun', 'Avoid locking up UTXOs')
.option('--fee-rate <fee>', 'Per vbyte fee rate for on-chain tx fee', INT)
.option('--fee-rate <fee>', 'Per vbyte fee rate for on-chain tx fee')
.option('--node <node_name>', 'Node to spend coins')
.option('--select-utxos', 'Specify UTXOs to spend interactively from a list')
.option('--utxo <outpoint>', 'Spend a specific tx_id:vout', REPEATABLE)

View file

@ -26,6 +26,7 @@ const hasMaxAmount = amounts => !!amounts.find(n => !!n && !!/max/gim.test(n));
const {isArray} = Array;
const isOutpoint = n => !!n && /^[0-9A-F]{64}:[0-9]{1,6}$/i.test(n);
const isPublicKey = n => !!n && /^0[2-3][0-9A-F]{64}$/i.test(n);
const isValidFeeRate = n => !n || Number.isInteger(Number(n));
const minConfs = 1;
const sumOf = arr => arr.reduce((sum, n) => sum + n, Number());
const taprootAddressVersion = 1;
@ -85,6 +86,10 @@ module.exports = (args, cbk) => {
return cbk([400, 'ExpectedAskFunctionToFundTransaction']);
}
if (!isValidFeeRate(args.fee_tokens_per_vbyte)) {
return cbk([400, 'ExpectedIntegerFeeRateForFundingTransaction']);
}
if (!!args.is_broadcast && !!args.is_dry_run) {
return cbk([400, 'BroadcastingSignedTxUnsupportedInDryRun']);
}
@ -159,6 +164,7 @@ module.exports = (args, cbk) => {
value: asOutpoint(utxo),
})),
loop: false,
message: 'Select UTXOs to spend',
name: 'inputs',
type: 'checkbox',
validate: input => {

1093
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -25,19 +25,19 @@
"bolt01": "2.0.0",
"bolt03": "1.3.2",
"bolt07": "1.9.4",
"cbor": "9.0.2",
"cbor": "10.0.2",
"colorette": "2.0.20",
"crypto-js": "4.2.0",
"csv-parse": "5.5.6",
"ecpair": "2.1.0",
"goldengate": "14.0.9",
"grammy": "1.30.0",
"grammy": "1.31.0",
"hot-formula-parser": "4.0.0",
"import-lazy": "4.0.0",
"ini": "5.0.0",
"inquirer": "12.0.0",
"inquirer": "12.0.1",
"ln-accounting": "8.0.5",
"ln-service": "57.22.0",
"ln-service": "57.22.2",
"ln-sync": "6.4.0",
"ln-telegram": "6.1.10",
"minimist": "1.2.8",
@ -83,5 +83,5 @@
"postpublish": "docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -t alexbosworth/balanceofsatoshis -t alexbosworth/balanceofsatoshis:$npm_package_version --push .",
"test": "npx nyc@17.0.0 node --experimental-test-coverage --test test/arrays/*.js test/balances/*.js test/chain/*.js test/display/*.js test/encryption/*.js test/lnd/*.js test/network/*.js test/nodes/*.js test/peers/*.js test/responses/*.js test/routing/*.js test/services/*.js test/swaps/*.js test/tags/*.js test/telegram/*.js test/wallets/*.js"
},
"version": "19.4.3"
"version": "19.4.4"
}