add strict high fee avoidance

This commit is contained in:
Alex Bosworth 2023-01-25 18:04:43 -08:00
parent d4fad60f13
commit ad775c1524
No known key found for this signature in database
GPG key ID: E80D2F3F311FD87E
5 changed files with 40 additions and 27 deletions

View file

@ -1,5 +1,9 @@
# Versions
## 13.24.0
- `send`: Add option `--avoid-high-fee-routes` to ignore out of range fee paths
## 13.23.0
- `pay`: Add option `--avoid-high-fee-routes` to ignore out of range fee paths

2
bos
View file

@ -1689,6 +1689,7 @@ prog
.argument('<to>', 'Send to public key, zero pay request, lnurl, ln.address')
.option('--amount <amount>', 'Amount to send to destination', STRING, '1')
.option('--avoid <avoid>', 'Avoid forwarding via node/chan/tag', REPEATABLE)
.option('--avoid-high-fee-routes', 'Avoid evaluating too-high fee routes')
.option('--dryrun', 'Avoid actually sending funds')
.option('--in <pubkey_or_alias>', 'Route in through a specific node')
.option('--max-fee <fee>', 'Maximum fee tokens', INT, 1337)
@ -1711,6 +1712,7 @@ prog
in_through: options.in,
is_dry_run: options.dryrun,
is_omitting_message_from: options.messageOmitFromKey,
is_strict_max_fee: !!options.avoidHighFeeRoutes,
lnd: (await lndForNode(logger, options.node)).lnd,
max_fee: options.maxFee,
max_fee_rate: options.maxFeeRate,

View file

@ -46,6 +46,7 @@ const utf8AsHex = n => Buffer.from(n, 'utf8').toString('hex');
[in_through]: <Pay In Through Peer String>
[is_dry_run]: <Do Not Push Payment Bool>
[is_omitting_message_from]: <Do Not Include From Key In Message Bool>
[is_strict_max_fee]: <Avoid Probing Too-High Fee Routes Bool>
lnd: <Authenticated LND API Object>
logger: <Winston Logger Object>
max_fee: <Maximum Fee Tokens Number>
@ -450,6 +451,7 @@ module.exports = (args, cbk) => {
is_omitting_message_from: args.is_omitting_message_from,
is_push: send.is_push,
is_real_payment: true,
is_strict_max_fee: args.is_strict_max_fee,
max_fee: send.max_fee,
message: args.message,
messages: args.quiz_answers.map((answer, i) => ({
@ -466,6 +468,11 @@ module.exports = (args, cbk) => {
// Get adjusted outbound liquidity after push
getAdjustedOutbound: ['push', ({push}, cbk) => {
// Exit early when there was no path
if (!push.attempted_paths && !!push.is_failed) {
return cbk([503, 'NoRouteToDestination']);
}
// Exit early when the payment failed
if (!push.preimage) {
return cbk([503, 'UnexpectedSendPaymentFailure']);

52
package-lock.json generated
View file

@ -1,12 +1,12 @@
{
"name": "balanceofsatoshis",
"version": "13.23.0",
"version": "13.24.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "balanceofsatoshis",
"version": "13.23.0",
"version": "13.24.0",
"license": "MIT",
"dependencies": {
"@alexbosworth/caporal": "1.4.4",
@ -2912,9 +2912,9 @@
}
},
"node_modules/@types/express-serve-static-core": {
"version": "4.17.32",
"resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.17.32.tgz",
"integrity": "sha512-aI5h/VOkxOF2Z1saPy0Zsxs5avets/iaiAJYznQFm5By/pamU31xWKL//epiF4OfUA2qTOc9PV6tCUjhO8wlZA==",
"version": "4.17.33",
"resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.17.33.tgz",
"integrity": "sha512-TPBqmR/HRYI3eC2E5hmiivIzv+bidAfXofM+sbonAGvyDhySGw9/PQZFt2BLOrjUUR++4eJVpx6KnLQK1Fk9tA==",
"dependencies": {
"@types/node": "*",
"@types/qs": "*",
@ -3637,9 +3637,9 @@
}
},
"node_modules/caniuse-lite": {
"version": "1.0.30001446",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001446.tgz",
"integrity": "sha512-fEoga4PrImGcwUUGEol/PoFCSBnSkA9drgdkxXkJLsUBOnJ8rs3zDv6ApqYXGQFOyMPsjh79naWhF4DAxbF8rw==",
"version": "1.0.30001448",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001448.tgz",
"integrity": "sha512-tq2YI+MJnooG96XpbTRYkBxLxklZPOdLmNIOdIhvf7SNJan6u5vCKum8iT7ZfCt70m1GPkuC7P3TtX6UuhupuA==",
"dev": true,
"funding": [
{
@ -6629,9 +6629,9 @@
}
},
"node_modules/protobufjs": {
"version": "7.1.2",
"resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-7.1.2.tgz",
"integrity": "sha512-4ZPTPkXCdel3+L81yw3dG6+Kq3umdWKh7Dc7GW/CpNk4SX3hK58iPCWeCyhVTDrbkNeKrYNZ7EojM5WDaEWTLQ==",
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-7.2.0.tgz",
"integrity": "sha512-hYCqTDuII4iJ4stZqiuGCSU8xxWl5JeXYpwARGtn/tWcKCAro6h3WQz+xpsNbXW0UYqpmTQFEyFWO0G0Kjt64g==",
"hasInstallScript": true,
"dependencies": {
"@protobufjs/aspromise": "^1.1.2",
@ -8215,9 +8215,9 @@
}
},
"node_modules/wrap-ansi": {
"version": "8.0.1",
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.0.1.tgz",
"integrity": "sha512-QFF+ufAqhoYHvoHdajT/Po7KoXVBPXS2bgjIam5isfWJPfIOnQZ50JtUiVvCv/sjgacf3yRrt2ZKUZ/V4itN4g==",
"version": "8.1.0",
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz",
"integrity": "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==",
"dependencies": {
"ansi-styles": "^6.1.0",
"string-width": "^5.0.1",
@ -10433,9 +10433,9 @@
}
},
"@types/express-serve-static-core": {
"version": "4.17.32",
"resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.17.32.tgz",
"integrity": "sha512-aI5h/VOkxOF2Z1saPy0Zsxs5avets/iaiAJYznQFm5By/pamU31xWKL//epiF4OfUA2qTOc9PV6tCUjhO8wlZA==",
"version": "4.17.33",
"resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.17.33.tgz",
"integrity": "sha512-TPBqmR/HRYI3eC2E5hmiivIzv+bidAfXofM+sbonAGvyDhySGw9/PQZFt2BLOrjUUR++4eJVpx6KnLQK1Fk9tA==",
"requires": {
"@types/node": "*",
"@types/qs": "*",
@ -11015,9 +11015,9 @@
"dev": true
},
"caniuse-lite": {
"version": "1.0.30001446",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001446.tgz",
"integrity": "sha512-fEoga4PrImGcwUUGEol/PoFCSBnSkA9drgdkxXkJLsUBOnJ8rs3zDv6ApqYXGQFOyMPsjh79naWhF4DAxbF8rw==",
"version": "1.0.30001448",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001448.tgz",
"integrity": "sha512-tq2YI+MJnooG96XpbTRYkBxLxklZPOdLmNIOdIhvf7SNJan6u5vCKum8iT7ZfCt70m1GPkuC7P3TtX6UuhupuA==",
"dev": true
},
"cbor": {
@ -13333,9 +13333,9 @@
}
},
"protobufjs": {
"version": "7.1.2",
"resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-7.1.2.tgz",
"integrity": "sha512-4ZPTPkXCdel3+L81yw3dG6+Kq3umdWKh7Dc7GW/CpNk4SX3hK58iPCWeCyhVTDrbkNeKrYNZ7EojM5WDaEWTLQ==",
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-7.2.0.tgz",
"integrity": "sha512-hYCqTDuII4iJ4stZqiuGCSU8xxWl5JeXYpwARGtn/tWcKCAro6h3WQz+xpsNbXW0UYqpmTQFEyFWO0G0Kjt64g==",
"requires": {
"@protobufjs/aspromise": "^1.1.2",
"@protobufjs/base64": "^1.1.2",
@ -14575,9 +14575,9 @@
}
},
"wrap-ansi": {
"version": "8.0.1",
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.0.1.tgz",
"integrity": "sha512-QFF+ufAqhoYHvoHdajT/Po7KoXVBPXS2bgjIam5isfWJPfIOnQZ50JtUiVvCv/sjgacf3yRrt2ZKUZ/V4itN4g==",
"version": "8.1.0",
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz",
"integrity": "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==",
"requires": {
"ansi-styles": "^6.1.0",
"string-width": "^5.0.1",

View file

@ -83,5 +83,5 @@
"postpublish": "docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -t alexbosworth/balanceofsatoshis --push .",
"test": "tap --branches=1 --functions=1 --lines=1 --statements=1 -t 60 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": "13.23.0"
"version": "13.24.0"
}