astra-lightning 1.1.2 → 1.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/unit-test.yml +20 -0
- package/CHANGELOG.md +46 -1
- package/README.md +2 -0
- package/bolt02/ids.json +1 -0
- package/grpc/grpc_services.json +1 -1
- package/grpc/protos/lightning.proto +251 -28
- package/grpc/protos/rfqrpc/rfq.proto +53 -5
- package/grpc/protos/router.proto +9 -4
- package/grpc/protos/routerrpc/router.proto +26 -4
- package/grpc/protos/{tapchannelrpc.proto → tapchannel.proto} +105 -25
- package/grpc/protos/tapcommon.proto +36 -0
- package/grpc/protos/taprootassets.proto +544 -23
- package/grpc/protos/walletkit.proto +78 -6
- package/index.js +162 -160
- package/lnd_methods/generic/get_height.js +1 -1
- package/lnd_methods/index.js +162 -160
- package/lnd_methods/info/constants.json +7 -0
- package/lnd_methods/invoices/create_invoice.js +10 -14
- package/lnd_methods/invoices/subscribe_to_invoice.d.ts +4 -0
- package/lnd_methods/invoices/subscribe_to_invoice.js +21 -21
- package/lnd_methods/macaroon/methods.json +4 -0
- package/lnd_methods/offchain/decode_asset_pay_req.d.ts +69 -28
- package/lnd_methods/offchain/decode_asset_pay_req.js +54 -61
- package/lnd_methods/offchain/get_pending_channels.d.ts +16 -0
- package/lnd_methods/offchain/get_pending_channels.js +6 -0
- package/lnd_methods/offchain/get_routing_fee_estimate.d.ts +32 -0
- package/lnd_methods/offchain/get_routing_fee_estimate.js +86 -0
- package/lnd_methods/offchain/index.d.ts +60 -60
- package/lnd_methods/offchain/index.js +6 -4
- package/lnd_methods/offchain/pay_via_routes.d.ts +4 -0
- package/lnd_methods/onchain/close_channel.d.ts +4 -0
- package/lnd_methods/onchain/close_channel.js +4 -0
- package/lnd_methods/onchain/open_channels.d.ts +1 -0
- package/lnd_methods/onchain/open_channels.js +7 -1
- package/lnd_methods/onchain/request_chain_fee_increase.js +5 -0
- package/lnd_methods/onchain/subscribe_to_blocks.js +1 -1
- package/lnd_responses/confirmed_from_payment_status.js +38 -40
- package/lnd_responses/constants.json +1 -0
- package/lnd_responses/forward_from_htlc_event.js +31 -31
- package/lnd_responses/info_as_wallet_info.js +28 -28
- package/lnd_responses/payment_request_details.js +28 -32
- package/lnd_responses/pending_as_pending_channels.js +8 -0
- package/lnd_responses/pending_from_payment.js +24 -24
- package/lnd_responses/routes_from_query_routes.js +30 -30
- package/lnd_responses/rpc_channel_as_channel.js +10 -9
- package/lnd_responses/rpc_fees_as_channel_fees.js +16 -16
- package/lnd_responses/rpc_forward_as_forward_request.js +27 -27
- package/lnd_responses/rpc_payment_as_payment.js +28 -31
- package/package.json +24 -20
- package/test/lnd_methods/offchain/test_get_routing_fee_estimate.js +82 -0
- package/test/lnd_methods/onchain/test_close_channel.js +5 -0
- package/test/lnd_methods/onchain/test_open_channels.js +5 -1
- package/test/lnd_methods/onchain/test_request_chain_fee_increase.js +13 -0
- package/test/lnd_responses/test_pending_as_pending_channels.js +34 -1
- package/test.js +194 -22
- package/.yarn/cache/@babel-code-frame-npm-7.25.7-40a9f53f43-f235cdf9c5.zip +0 -0
- package/.yarn/cache/@babel-helper-validator-identifier-npm-7.25.7-1c758f0472-062f55208d.zip +0 -0
- package/.yarn/cache/@babel-highlight-npm-7.25.7-308b20da71-b6aa45c5bf.zip +0 -0
- package/.yarn/cache/@grpc-grpc-js-npm-1.12.2-733ec8eabe-ee51317f92.zip +0 -0
- package/.yarn/cache/@grpc-proto-loader-npm-0.7.13-be5b6af1c1-399c1b8a46.zip +0 -0
- package/.yarn/cache/@jest-schemas-npm-29.6.3-292730e442-910040425f.zip +0 -0
- package/.yarn/cache/@js-sdsl-ordered-map-npm-4.4.2-158f6c6b74-a927ae4ff8.zip +0 -0
- package/.yarn/cache/@noble-hashes-npm-1.5.0-87c768d742-9cc031d5c8.zip +0 -0
- package/.yarn/cache/@nodelib-fs.scandir-npm-2.1.5-89c67370dd-a970d595bd.zip +0 -0
- package/.yarn/cache/@nodelib-fs.stat-npm-2.0.5-01f4dd3030-012480b5ca.zip +0 -0
- package/.yarn/cache/@nodelib-fs.walk-npm-1.2.8-b4a89da548-190c643f15.zip +0 -0
- package/.yarn/cache/@protobufjs-aspromise-npm-1.1.2-71d00b938f-011fe7ef08.zip +0 -0
- package/.yarn/cache/@protobufjs-base64-npm-1.1.2-cd8ca6814a-67173ac34d.zip +0 -0
- package/.yarn/cache/@protobufjs-codegen-npm-2.0.4-36e188bbe6-59240c850b.zip +0 -0
- package/.yarn/cache/@protobufjs-eventemitter-npm-1.1.0-029cc7d431-0369163a3d.zip +0 -0
- package/.yarn/cache/@protobufjs-fetch-npm-1.1.0-ca857b7df4-3fce7e09eb.zip +0 -0
- package/.yarn/cache/@protobufjs-float-npm-1.0.2-5678f64d08-5781e12412.zip +0 -0
- package/.yarn/cache/@protobufjs-inquire-npm-1.1.0-3c7759e9ce-ca06f02eaf.zip +0 -0
- package/.yarn/cache/@protobufjs-path-npm-1.1.2-641d08de76-856eeb532b.zip +0 -0
- package/.yarn/cache/@protobufjs-pool-npm-1.1.0-47a76f96a1-d6a34fbbd2.zip +0 -0
- package/.yarn/cache/@protobufjs-utf8-npm-1.1.0-02c590807c-f9bf3163d1.zip +0 -0
- package/.yarn/cache/@sinclair-typebox-npm-0.27.8-23e206d653-00bd7362a3.zip +0 -0
- package/.yarn/cache/@tsd-typescript-npm-5.4.5-31c3b104b3-86498d5e15.zip +0 -0
- package/.yarn/cache/@types-caseless-npm-0.12.5-d7dbdab81c-f6a3628add.zip +0 -0
- package/.yarn/cache/@types-eslint-npm-7.29.0-46534a7300-df13991c55.zip +0 -0
- package/.yarn/cache/@types-estree-npm-1.0.6-b5e23f2ea2-8825d6e729.zip +0 -0
- package/.yarn/cache/@types-json-schema-npm-7.0.15-fd16381786-97ed0cb44d.zip +0 -0
- package/.yarn/cache/@types-minimist-npm-1.2.5-c85664a9d8-477047b606.zip +0 -0
- package/.yarn/cache/@types-node-npm-22.7.5-0428b60a8c-1a8bbb504e.zip +0 -0
- package/.yarn/cache/@types-node-npm-22.7.6-cbb64e0ad4-6afe2a1bd7.zip +0 -0
- package/.yarn/cache/@types-normalize-package-data-npm-2.4.4-676a8ba353-65dff72b54.zip +0 -0
- package/.yarn/cache/@types-request-npm-2.48.12-d921ef35cb-20dfad0a46.zip +0 -0
- package/.yarn/cache/@types-tough-cookie-npm-4.0.5-8c5e2162e1-f19409d019.zip +0 -0
- package/.yarn/cache/@types-ws-npm-8.5.12-90c42288cf-ddefb6ad16.zip +0 -0
- package/.yarn/cache/ansi-escapes-npm-4.3.2-3ad173702f-93111c4218.zip +0 -0
- package/.yarn/cache/ansi-regex-npm-5.0.1-c963a48615-2aa4bb54ca.zip +0 -0
- package/.yarn/cache/ansi-styles-npm-3.2.1-8cb8107983-d85ade01c1.zip +0 -0
- package/.yarn/cache/ansi-styles-npm-4.3.0-245c7d42c7-513b44c3b2.zip +0 -0
- package/.yarn/cache/ansi-styles-npm-5.2.0-72fc7003e3-d7f4e97ce0.zip +0 -0
- package/.yarn/cache/array-union-npm-2.1.0-4e4852b221-5bee12395c.zip +0 -0
- package/.yarn/cache/arrify-npm-1.0.1-affafba9fe-745075dd4a.zip +0 -0
- package/.yarn/cache/async-npm-3.2.4-aba13508f9-43d07459a4.zip +0 -0
- package/.yarn/cache/async-npm-3.2.6-aa4f5aa081-ee6eb8cd8a.zip +0 -0
- package/.yarn/cache/asyncjs-util-npm-1.2.12-f1ef4c2905-55ff005a7f.zip +0 -0
- package/.yarn/cache/asynckit-npm-0.4.0-c718858525-7b78c451df.zip +0 -0
- package/.yarn/cache/base-x-npm-3.0.10-2d05c06792-5230773955.zip +0 -0
- package/.yarn/cache/base-x-npm-4.0.0-64a1f6fa5e-b25db9e07e.zip +0 -0
- package/.yarn/cache/bech32-npm-2.0.0-ad98b7dd79-fa15acb270.zip +0 -0
- package/.yarn/cache/bip174-npm-2.1.1-d9fcaf36f9-bc5b99e7d1.zip +0 -0
- package/.yarn/cache/bip66-npm-1.1.5-e1d2ea7768-956cff6e51.zip +0 -0
- package/.yarn/cache/bitcoin-ops-npm-1.4.1-e1e62763b3-3daa3303d6.zip +0 -0
- package/.yarn/cache/bitcoinjs-lib-npm-6.1.3-8b823f7e69-b1d9ffd999.zip +0 -0
- package/.yarn/cache/bitcoinjs-lib-npm-6.1.6-d063b5a8ff-04370cf699.zip +0 -0
- package/.yarn/cache/bn.js-npm-5.2.1-dc952b1965-3dd8c8d380.zip +0 -0
- package/.yarn/cache/bolt07-npm-1.8.4-297a4ac40d-58cdf15aba.zip +0 -0
- package/.yarn/cache/bolt07-npm-1.9.4-6f74865601-d18efc5f83.zip +0 -0
- package/.yarn/cache/bolt09-npm-1.0.0-b3d5b54cf9-09d53b86f2.zip +0 -0
- package/.yarn/cache/bolt09-npm-2.1.0-1fc0cfcef2-629cd3bdd4.zip +0 -0
- package/.yarn/cache/braces-npm-3.0.3-582c14023c-b95aa0b3bd.zip +0 -0
- package/.yarn/cache/bs58-npm-4.0.1-8d2a7822b1-b3c5365bb9.zip +0 -0
- package/.yarn/cache/bs58-npm-5.0.0-da02537b92-2475cb0684.zip +0 -0
- package/.yarn/cache/bs58check-npm-2.1.2-4e87e40195-43bdf08a5d.zip +0 -0
- package/.yarn/cache/bs58check-npm-3.0.1-be32851e5e-dbbecc7a09.zip +0 -0
- package/.yarn/cache/camelcase-keys-npm-6.2.2-d13777ec12-43c9af1adf.zip +0 -0
- package/.yarn/cache/camelcase-npm-5.3.1-5db8af62c5-e6effce26b.zip +0 -0
- package/.yarn/cache/chalk-npm-2.4.2-3ea16dd91e-ec3661d38f.zip +0 -0
- package/.yarn/cache/chalk-npm-4.1.2-ba8b67ab80-fe75c9d5c7.zip +0 -0
- package/.yarn/cache/cipher-base-npm-1.0.4-2e98b97140-47d3568dbc.zip +0 -0
- package/.yarn/cache/cliui-npm-8.0.1-3b029092cf-79648b3b00.zip +0 -0
- package/.yarn/cache/color-convert-npm-1.9.3-1fe690075e-fd7a64a17c.zip +0 -0
- package/.yarn/cache/color-convert-npm-2.0.1-79730e935b-79e6bdb9fd.zip +0 -0
- package/.yarn/cache/color-name-npm-1.1.3-728b7b5d39-09c5d3e33d.zip +0 -0
- package/.yarn/cache/color-name-npm-1.1.4-025792b0ea-b044585952.zip +0 -0
- package/.yarn/cache/combined-stream-npm-1.0.8-dc14d4a63a-49fa4aeb49.zip +0 -0
- package/.yarn/cache/create-hash-npm-1.2.0-afd048e1ce-02a6ae3bb9.zip +0 -0
- package/.yarn/cache/decamelize-keys-npm-1.1.1-4cfa36ed4b-fc645fe20b.zip +0 -0
- package/.yarn/cache/decamelize-npm-1.2.0-c5a2fdc622-ad8c51a7e7.zip +0 -0
- package/.yarn/cache/delayed-stream-npm-1.0.0-c5a4c4cc02-46fe6e83e2.zip +0 -0
- package/.yarn/cache/diff-sequences-npm-29.6.3-18ab2c9949-f4914158e1.zip +0 -0
- package/.yarn/cache/dir-glob-npm-3.0.1-1aea628b1b-fa05e18324.zip +0 -0
- package/.yarn/cache/ecpair-npm-2.1.0-d034fc21e2-924a776808.zip +0 -0
- package/.yarn/cache/emoji-regex-npm-8.0.0-213764015c-d4c5c39d5a.zip +0 -0
- package/.yarn/cache/error-ex-npm-1.3.2-5654f80c0f-c1c2b8b65f.zip +0 -0
- package/.yarn/cache/escalade-npm-3.2.0-19b50dd48f-47b029c83d.zip +0 -0
- package/.yarn/cache/escape-string-regexp-npm-1.0.5-3284de402f-6092fda75c.zip +0 -0
- package/.yarn/cache/eslint-formatter-pretty-npm-4.1.0-30790f28b4-e8e0cd3843.zip +0 -0
- package/.yarn/cache/eslint-rule-docs-npm-1.1.235-64d33df34f-b163596f9a.zip +0 -0
- package/.yarn/cache/fast-glob-npm-3.3.2-0a8cb4f2ca-900e4979f4.zip +0 -0
- package/.yarn/cache/fastq-npm-1.17.1-56d4554993-a8c5b26788.zip +0 -0
- package/.yarn/cache/fill-range-npm-7.1.1-bf491486db-b4abfbca38.zip +0 -0
- package/.yarn/cache/find-up-npm-4.1.0-c3ccf8d855-4c172680e8.zip +0 -0
- package/.yarn/cache/form-data-npm-2.5.2-f40bcd738c-89ed3d9623.zip +0 -0
- package/.yarn/cache/function-bind-npm-1.1.2-7a55be9b03-2b0ff4ce70.zip +0 -0
- package/.yarn/cache/get-caller-file-npm-2.0.5-80e8a86305-b9769a836d.zip +0 -0
- package/.yarn/cache/glob-parent-npm-5.1.2-021ab32634-f4f2bfe242.zip +0 -0
- package/.yarn/cache/globby-npm-11.1.0-bdcdf20c71-b4be8885e0.zip +0 -0
- package/.yarn/cache/hard-rejection-npm-2.1.0-a80f2a977d-7baaf80a0c.zip +0 -0
- package/.yarn/cache/has-flag-npm-3.0.0-16ac11fe05-4a15638b45.zip +0 -0
- package/.yarn/cache/has-flag-npm-4.0.0-32af9f0536-261a135703.zip +0 -0
- package/.yarn/cache/hash-base-npm-3.1.0-26fc5711dd-26b7e97ac3.zip +0 -0
- package/.yarn/cache/hasown-npm-2.0.2-80fe6c9901-e8516f776a.zip +0 -0
- package/.yarn/cache/hosted-git-info-npm-2.8.9-62c44fa93f-c955394bda.zip +0 -0
- package/.yarn/cache/hosted-git-info-npm-4.1.0-4efcdf8fd3-c3f87b3c2f.zip +0 -0
- package/.yarn/cache/ignore-npm-5.3.2-346d3ba017-2acfd32a57.zip +0 -0
- package/.yarn/cache/indent-string-npm-4.0.0-7b717435b2-824cfb9929.zip +0 -0
- package/.yarn/cache/inherits-npm-2.0.4-c66b3957a0-4a48a73384.zip +0 -0
- package/.yarn/cache/invoices-npm-3.0.0-123907e565-27119b1449.zip +0 -0
- package/.yarn/cache/irregular-plurals-npm-3.5.0-2415613615-5b663091dc.zip +0 -0
- package/.yarn/cache/is-arrayish-npm-0.2.1-23927dfb15-eef4417e3c.zip +0 -0
- package/.yarn/cache/is-core-module-npm-2.15.1-34c73a6cbd-df134c1681.zip +0 -0
- package/.yarn/cache/is-extglob-npm-2.1.1-0870ea68b5-df033653d0.zip +0 -0
- package/.yarn/cache/is-fullwidth-code-point-npm-3.0.0-1ecf4ebee5-44a30c2945.zip +0 -0
- package/.yarn/cache/is-glob-npm-4.0.3-cb87bf1bdb-d381c1319f.zip +0 -0
- package/.yarn/cache/is-number-npm-7.0.0-060086935c-456ac6f8e0.zip +0 -0
- package/.yarn/cache/is-plain-obj-npm-1.1.0-1046f64c0b-0ee0480779.zip +0 -0
- package/.yarn/cache/is-unicode-supported-npm-0.1.0-0833e1bbfb-a2aab86ee7.zip +0 -0
- package/.yarn/cache/jest-diff-npm-29.7.0-0149e01930-08e24a9dd4.zip +0 -0
- package/.yarn/cache/jest-get-type-npm-29.6.3-500477292e-88ac9102d4.zip +0 -0
- package/.yarn/cache/js-tokens-npm-4.0.0-0ac852e9e2-8a95213a5a.zip +0 -0
- package/.yarn/cache/json-parse-even-better-errors-npm-2.3.1-144d62256e-798ed4cf33.zip +0 -0
- package/.yarn/cache/kind-of-npm-6.0.3-ab15f36220-3ab01e7b1d.zip +0 -0
- package/.yarn/cache/lines-and-columns-npm-1.2.4-d6c7cc5799-0c37f9f7fa.zip +0 -0
- package/.yarn/cache/locate-path-npm-5.0.0-46580c43e4-83e51725e6.zip +0 -0
- package/.yarn/cache/lodash.camelcase-npm-4.3.0-bf268e3bf0-cb9227612f.zip +0 -0
- package/.yarn/cache/log-symbols-npm-4.1.0-0a13492d8b-fce1497b31.zip +0 -0
- package/.yarn/cache/long-npm-5.2.3-61dddb7586-885ede7c3d.zip +0 -0
- package/.yarn/cache/lru-cache-npm-6.0.0-b4c8668fe1-f97f499f89.zip +0 -0
- package/.yarn/cache/map-obj-npm-1.0.1-fa55100fac-9949e7baec.zip +0 -0
- package/.yarn/cache/map-obj-npm-4.3.0-d53e32935d-fbc554934d.zip +0 -0
- package/.yarn/cache/md5.js-npm-1.3.5-130901125a-098494d885.zip +0 -0
- package/.yarn/cache/meow-npm-9.0.0-8b2707248e-99799c4724.zip +0 -0
- package/.yarn/cache/merge2-npm-1.4.1-a2507bd06c-7268db63ed.zip +0 -0
- package/.yarn/cache/micromatch-npm-4.0.8-c9570e4aca-79920eb634.zip +0 -0
- package/.yarn/cache/mime-db-npm-1.52.0-b5371d6fd2-0d99a03585.zip +0 -0
- package/.yarn/cache/mime-types-npm-2.1.35-dd9ea9f3e2-89a5b7f1de.zip +0 -0
- package/.yarn/cache/min-indent-npm-1.0.1-77031f50e1-bfc6dd03c5.zip +0 -0
- package/.yarn/cache/minimist-options-npm-4.1.0-64ca250fc1-8c040b3068.zip +0 -0
- package/.yarn/cache/normalize-package-data-npm-2.5.0-af0345deed-7999112efc.zip +0 -0
- package/.yarn/cache/normalize-package-data-npm-3.0.3-1a49056685-bbcee00339.zip +0 -0
- package/.yarn/cache/p-limit-npm-2.3.0-94a0310039-84ff17f1a3.zip +0 -0
- package/.yarn/cache/p-locate-npm-4.1.0-eec6872537-513bd14a45.zip +0 -0
- package/.yarn/cache/p-try-npm-2.2.0-e0390dbaf8-f8a8e9a769.zip +0 -0
- package/.yarn/cache/parse-json-npm-5.2.0-00a63b1199-62085b17d6.zip +0 -0
- package/.yarn/cache/path-exists-npm-4.0.0-e9e4f63eb0-505807199d.zip +0 -0
- package/.yarn/cache/path-parse-npm-1.0.7-09564527b7-49abf3d811.zip +0 -0
- package/.yarn/cache/path-type-npm-4.0.0-10d47fc86a-5b1e2daa24.zip +0 -0
- package/.yarn/cache/picocolors-npm-1.1.1-4fede47cf1-e1cf46bf84.zip +0 -0
- package/.yarn/cache/picomatch-npm-2.3.1-c782cfd986-050c865ce8.zip +0 -0
- package/.yarn/cache/plur-npm-4.0.0-96f2a49c24-fea2e903ef.zip +0 -0
- package/.yarn/cache/pretty-format-npm-29.7.0-7d330b2ea2-032c160238.zip +0 -0
- package/.yarn/cache/protobufjs-npm-7.4.0-12c56a3adc-ba0e6b6054.zip +0 -0
- package/.yarn/cache/psbt-npm-3.0.0-7f3e8059ba-1dddca470a.zip +0 -0
- package/.yarn/cache/pushdata-bitcoin-npm-1.0.1-959a90bb14-8452106d4b.zip +0 -0
- package/.yarn/cache/queue-microtask-npm-1.2.3-fcc98e4e2d-b676f8c040.zip +0 -0
- package/.yarn/cache/quick-lru-npm-4.0.1-ef8aa17c9c-bea46e1abf.zip +0 -0
- package/.yarn/cache/randombytes-npm-2.1.0-e3da76bccf-d779499376.zip +0 -0
- package/.yarn/cache/react-is-npm-18.3.1-370a81e1e9-e20fe84c86.zip +0 -0
- package/.yarn/cache/read-pkg-npm-5.2.0-50426bd8dc-eb696e6052.zip +0 -0
- package/.yarn/cache/read-pkg-up-npm-7.0.1-11895bed9a-e4e93ce70e.zip +0 -0
- package/.yarn/cache/readable-stream-npm-3.6.2-d2a6069158-bdcbe6c22e.zip +0 -0
- package/.yarn/cache/redent-npm-3.0.0-31892f4906-fa1ef20404.zip +0 -0
- package/.yarn/cache/require-directory-npm-2.1.1-8608aee50b-fb47e70bf0.zip +0 -0
- package/.yarn/cache/resolve-npm-1.22.8-098f379dfe-f8a26958aa.zip +0 -0
- package/.yarn/cache/resolve-patch-f6b5304cab-5479b7d431.zip +0 -0
- package/.yarn/cache/reusify-npm-1.0.4-95ac4aec11-c3076ebcc2.zip +0 -0
- package/.yarn/cache/ripemd160-npm-2.0.2-7b1fb8dc76-006accc405.zip +0 -0
- package/.yarn/cache/run-parallel-npm-1.2.0-3f47ff2034-cb4f97ad25.zip +0 -0
- package/.yarn/cache/safe-buffer-npm-5.2.1-3481c8aa9b-b99c4b41fd.zip +0 -0
- package/.yarn/cache/semver-npm-5.7.2-938ee91eaa-fb4ab5e0dd.zip +0 -0
- package/.yarn/cache/semver-npm-7.6.3-57e82c14d5-4110ec5d01.zip +0 -0
- package/.yarn/cache/sha.js-npm-2.4.11-14868df4ca-ebd3f59d4b.zip +0 -0
- package/.yarn/cache/slash-npm-3.0.0-b87de2279a-94a93fff61.zip +0 -0
- package/.yarn/cache/spdx-correct-npm-3.2.0-ffae008484-e9ae98d22f.zip +0 -0
- package/.yarn/cache/spdx-exceptions-npm-2.5.0-718ed4b7d6-bb127d6e25.zip +0 -0
- package/.yarn/cache/spdx-expression-parse-npm-3.0.1-b718cbb35a-a1c6e104a2.zip +0 -0
- package/.yarn/cache/spdx-license-ids-npm-3.0.20-f08e1eabc0-0c57750bed.zip +0 -0
- package/.yarn/cache/string-width-npm-4.2.3-2c27177bae-e52c10dc3f.zip +0 -0
- package/.yarn/cache/string_decoder-npm-1.3.0-2422117fd0-8417646695.zip +0 -0
- package/.yarn/cache/strip-ansi-npm-6.0.1-caddc7cb40-f3cd25890a.zip +0 -0
- package/.yarn/cache/strip-indent-npm-3.0.0-519e75a28d-18f045d57d.zip +0 -0
- package/.yarn/cache/supports-color-npm-5.5.0-183ac537bc-95f6f4ba5a.zip +0 -0
- package/.yarn/cache/supports-color-npm-7.2.0-606bfcf7da-3dda818de0.zip +0 -0
- package/.yarn/cache/supports-hyperlinks-npm-2.3.0-d19176eba2-9ee0de3c8c.zip +0 -0
- package/.yarn/cache/supports-preserve-symlinks-flag-npm-1.0.0-f17c4d0028-53b1e247e6.zip +0 -0
- package/.yarn/cache/tiny-secp256k1-npm-2.2.2-54168b74b6-2b38491186.zip +0 -0
- package/.yarn/cache/tiny-secp256k1-npm-2.2.3-8c5163b5d1-f7a74a1fce.zip +0 -0
- package/.yarn/cache/to-regex-range-npm-5.0.1-f1e8263b00-f76fa01b3d.zip +0 -0
- package/.yarn/cache/trim-newlines-npm-3.0.1-22f1f216de-b530f3fadf.zip +0 -0
- package/.yarn/cache/tsd-npm-0.31.2-07f84c93d0-23bb84f8ba.zip +0 -0
- package/.yarn/cache/type-fest-npm-0.18.1-47b079775d-e96dcee18a.zip +0 -0
- package/.yarn/cache/type-fest-npm-0.21.3-5ff2a9c6fd-e6b32a3b38.zip +0 -0
- package/.yarn/cache/type-fest-npm-0.6.0-76b229965b-b2188e6e4b.zip +0 -0
- package/.yarn/cache/type-fest-npm-0.8.1-351ad028fe-d61c4b2eba.zip +0 -0
- package/.yarn/cache/type-fest-npm-4.26.1-274c31182d-7188db3bca.zip +0 -0
- package/.yarn/cache/typeforce-npm-1.18.0-372e34e2a2-e3b21e27e7.zip +0 -0
- package/.yarn/cache/typescript-npm-5.6.3-cc9b3687b0-ba302f8822.zip +0 -0
- package/.yarn/cache/typescript-patch-be88537122-ade87bce23.zip +0 -0
- package/.yarn/cache/uint8array-tools-npm-0.0.7-96ca58a124-6ffc45c7d2.zip +0 -0
- package/.yarn/cache/undici-types-npm-6.19.8-9f12285b7a-de51f1b447.zip +0 -0
- package/.yarn/cache/util-deprecate-npm-1.0.2-e3fe1a219c-474acf1146.zip +0 -0
- package/.yarn/cache/validate-npm-package-license-npm-3.0.4-7af8adc7a8-35703ac889.zip +0 -0
- package/.yarn/cache/varuint-bitcoin-npm-1.1.2-83f928c112-1c900bf08f.zip +0 -0
- package/.yarn/cache/wif-npm-2.0.6-f351bf025a-8c3147ef98.zip +0 -0
- package/.yarn/cache/wrap-ansi-npm-7.0.0-ad6e1a0554-a790b846fd.zip +0 -0
- package/.yarn/cache/y18n-npm-5.0.8-5f3a0a7e62-54f0fb9562.zip +0 -0
- package/.yarn/cache/yallist-npm-4.0.0-b493d9e907-343617202a.zip +0 -0
- package/.yarn/cache/yargs-npm-17.7.2-80b62638e1-73b572e863.zip +0 -0
- package/.yarn/cache/yargs-parser-npm-20.2.9-a1d19e598d-8bb69015f2.zip +0 -0
- package/.yarn/cache/yargs-parser-npm-21.1.1-8fdc003314-ed2d96a616.zip +0 -0
- package/.yarn/install-state.gz +0 -0
|
@@ -41,6 +41,8 @@ const outpointSeparator = ':';
|
|
|
41
41
|
capacity: <Channel Capacity Tokens Count String>
|
|
42
42
|
channel_point: <Channel Outpoint String>
|
|
43
43
|
commitment_type: <Type of Channel String>
|
|
44
|
+
confirmation_height: <Best Chain Block Height Funding Seen Number>
|
|
45
|
+
confirmations_until_active: <Blocks Remaining to Channel Active Number>
|
|
44
46
|
initiator: <Channel Creator Status String>
|
|
45
47
|
local_balance: <Local Balance Tokens String>
|
|
46
48
|
local_chan_reserve_sat: <Local Side Channel Reserve Tokens String>
|
|
@@ -97,6 +99,8 @@ const outpointSeparator = ':';
|
|
|
97
99
|
is_timelocked: <Channel Local Funds Constrained by Timelock Script Bool>
|
|
98
100
|
local_balance: <Channel Local Tokens Balance Number>
|
|
99
101
|
local_reserve: <Channel Local Reserved Tokens Number>
|
|
102
|
+
[opening_funding_height]: <Funding Seen At Best Block Height Number>
|
|
103
|
+
[opening_waiting_blocks]: <Open Activation Waiting Blocks Count Number>
|
|
100
104
|
partner_public_key: <Channel Peer Public Key String>
|
|
101
105
|
[pending_balance]: <Tokens Pending Recovery Number>
|
|
102
106
|
[pending_payments]: [{
|
|
@@ -247,6 +251,8 @@ module.exports = args => {
|
|
|
247
251
|
|
|
248
252
|
sum[pending.channel.channel_point] = {
|
|
249
253
|
funding_expiry: Number(pending.funding_expiry_blocks) || undefined,
|
|
254
|
+
open_blocks: Number(pending.confirmations_until_active) || undefined,
|
|
255
|
+
open_height: Number(pending.confirmation_height) || undefined,
|
|
250
256
|
transaction_fee: Number(pending.commit_fee),
|
|
251
257
|
transaction_weight: Number(pending.commit_weight),
|
|
252
258
|
};
|
|
@@ -311,6 +317,8 @@ module.exports = args => {
|
|
|
311
317
|
is_timelocked: forced.timelock_blocks !== undefined,
|
|
312
318
|
local_balance: Number(channel.local_balance),
|
|
313
319
|
local_reserve: Number(channel.local_chan_reserve_sat),
|
|
320
|
+
opening_funding_height: !chanOpen ? undefined : chanOpen.open_height,
|
|
321
|
+
opening_waiting_blocks: !chanOpen ? undefined : chanOpen.open_blocks,
|
|
314
322
|
partner_public_key: channel.remote_node_pub,
|
|
315
323
|
pending_balance: pendingTokens || undefined,
|
|
316
324
|
pending_payments: forced.pending_payments || undefined,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
const {
|
|
2
|
-
const rpcAttemptHtlcAsAttempt = require(
|
|
3
|
-
const {
|
|
1
|
+
const {attemptStates} = require('./constants');
|
|
2
|
+
const rpcAttemptHtlcAsAttempt = require('./rpc_attempt_htlc_as_attempt');
|
|
3
|
+
const {safeTokens} = require('./../bolt00');
|
|
4
4
|
|
|
5
|
-
const {
|
|
6
|
-
const is256Hex =
|
|
7
|
-
const {
|
|
8
|
-
const mtokensAsTokens =
|
|
9
|
-
const nsAsDate =
|
|
5
|
+
const {isArray} = Array;
|
|
6
|
+
const is256Hex = n => !!n && /^[0-9A-F]{64}$/i.test(n);
|
|
7
|
+
const {max} = Math;
|
|
8
|
+
const mtokensAsTokens = mtokens => safeTokens({mtokens}).tokens;
|
|
9
|
+
const nsAsDate = ns => new Date(Number(BigInt(ns) / BigInt(1e6)));
|
|
10
10
|
|
|
11
11
|
/** Calculate total payment details from RPC payment HTLC elements
|
|
12
12
|
|
|
@@ -93,43 +93,43 @@ const nsAsDate = (ns) => new Date(Number(BigInt(ns) / BigInt(1e6)));
|
|
|
93
93
|
tokens: <Total Tokens Pending Rounded Down Number>
|
|
94
94
|
}
|
|
95
95
|
*/
|
|
96
|
-
module.exports =
|
|
96
|
+
module.exports = payment => {
|
|
97
97
|
if (!payment) {
|
|
98
|
-
throw new Error(
|
|
98
|
+
throw new Error('ExpectedPendingPaymentToDerivePendingDetails');
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
if (!payment.creation_time_ns) {
|
|
102
|
-
throw new Error(
|
|
102
|
+
throw new Error('ExpectedPaymentCreationDateToDerivePendingDetails');
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
if (!payment.fee_msat) {
|
|
106
|
-
throw new Error(
|
|
106
|
+
throw new Error('ExpectedPaymentFeeMillitokensAmountForPendingPayment');
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
if (!isArray(payment.htlcs)) {
|
|
110
|
-
throw new Error(
|
|
110
|
+
throw new Error('ExpectedArrayOfPaymentHtlcsInPendingPayment');
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
if (!payment.htlcs.find(
|
|
114
|
-
throw new Error(
|
|
113
|
+
if (!payment.htlcs.find(n => n.status === attemptStates.pending)) {
|
|
114
|
+
throw new Error('ExpectedPendingHtlcInPendingPayment');
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
if (!is256Hex(payment.payment_hash)) {
|
|
118
|
-
throw new Error(
|
|
118
|
+
throw new Error('ExpectedPaymentHashForPaymentAsPendingPayment');
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
if (mtokensAsTokens(payment.value_msat) !== Number(payment.value_sat)) {
|
|
122
|
-
throw new Error(
|
|
122
|
+
throw new Error('ExpectedValueOfTokensAndMillitokensToBeConsistent');
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
-
const attempts = payment.htlcs.map(
|
|
125
|
+
const attempts = payment.htlcs.map(htlc => rpcAttemptHtlcAsAttempt(htlc));
|
|
126
126
|
const mtokens = BigInt(payment.value_msat) + BigInt(payment.fee_msat);
|
|
127
127
|
|
|
128
|
-
const pending = attempts.filter(
|
|
128
|
+
const pending = attempts.filter(n => n.is_pending);
|
|
129
129
|
|
|
130
130
|
const [first] = pending;
|
|
131
131
|
|
|
132
|
-
const [destination] = first.route.hops.map(
|
|
132
|
+
const [destination] = first.route.hops.map(n => n.public_key).reverse();
|
|
133
133
|
|
|
134
134
|
return {
|
|
135
135
|
destination,
|
|
@@ -137,10 +137,10 @@ module.exports = (payment) => {
|
|
|
137
137
|
id: payment.payment_hash,
|
|
138
138
|
index: payment.payment_index,
|
|
139
139
|
mtokens: mtokens.toString(),
|
|
140
|
-
paths: pending.map(
|
|
140
|
+
paths: pending.map(n => n.route),
|
|
141
141
|
request: payment.payment_request || undefined,
|
|
142
|
-
safe_tokens: safeTokens({
|
|
143
|
-
timeout: max(...pending.map(
|
|
144
|
-
tokens: safeTokens({
|
|
142
|
+
safe_tokens: safeTokens({mtokens: mtokens.toString()}).safe,
|
|
143
|
+
timeout: max(...pending.map(n => n.route.timeout).filter(n => !!n)),
|
|
144
|
+
tokens: safeTokens({mtokens: mtokens.toString()}).tokens,
|
|
145
145
|
};
|
|
146
146
|
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
const BN = require(
|
|
2
|
-
const {
|
|
1
|
+
const BN = require('bn.js');
|
|
2
|
+
const {chanFormat} = require('bolt07');
|
|
3
3
|
|
|
4
|
-
const {
|
|
4
|
+
const {safeTokens} = require('./../bolt00');
|
|
5
5
|
|
|
6
|
-
const {
|
|
7
|
-
const {
|
|
6
|
+
const {isArray} = Array;
|
|
7
|
+
const {keys} = Object;
|
|
8
8
|
const mtokensPerToken = BigInt(1e3);
|
|
9
|
-
const {
|
|
9
|
+
const {round} = Math;
|
|
10
10
|
const successDenominator = 1e6;
|
|
11
11
|
|
|
12
12
|
/** Routes from raw lnd query routes gRPC response
|
|
@@ -66,29 +66,29 @@ const successDenominator = 1e6;
|
|
|
66
66
|
}]
|
|
67
67
|
}
|
|
68
68
|
*/
|
|
69
|
-
module.exports = ({
|
|
69
|
+
module.exports = ({response}) => {
|
|
70
70
|
if (!response) {
|
|
71
|
-
throw new Error(
|
|
71
|
+
throw new Error('ExpectedResponse');
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
const {
|
|
74
|
+
const {routes} = response;
|
|
75
75
|
|
|
76
76
|
const confidence = round(response.success_prob * successDenominator);
|
|
77
77
|
|
|
78
78
|
if (!isArray(routes)) {
|
|
79
|
-
throw new Error(
|
|
79
|
+
throw new Error('ExpectedRoutes');
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
if (!routes.length) {
|
|
83
|
-
throw new Error(
|
|
83
|
+
throw new Error('ExpectedMultipleRoutes');
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
const invalidRoute = routes.find(
|
|
87
|
-
if (typeof route.total_fees_msat !==
|
|
86
|
+
const invalidRoute = routes.find(route => {
|
|
87
|
+
if (typeof route.total_fees_msat !== 'string') {
|
|
88
88
|
return true;
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
if (typeof route.total_time_lock !==
|
|
91
|
+
if (typeof route.total_time_lock !== 'number') {
|
|
92
92
|
return true;
|
|
93
93
|
}
|
|
94
94
|
|
|
@@ -100,54 +100,54 @@ module.exports = ({ response }) => {
|
|
|
100
100
|
});
|
|
101
101
|
|
|
102
102
|
if (!!invalidRoute) {
|
|
103
|
-
throw new Error(
|
|
103
|
+
throw new Error('ExpectedValidRoutes');
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
try {
|
|
107
|
-
routes.forEach(
|
|
108
|
-
return route.hops.forEach(
|
|
107
|
+
routes.forEach(route => {
|
|
108
|
+
return route.hops.forEach(h => chanFormat({number: h.chan_id}));
|
|
109
109
|
});
|
|
110
110
|
} catch (err) {
|
|
111
|
-
throw new Error(
|
|
111
|
+
throw new Error('ExpectedValidHopChannelIdsInRoutes');
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
return {
|
|
115
|
-
routes: routes.map(
|
|
115
|
+
routes: routes.map(route => {
|
|
116
116
|
const [lastHop] = route.hops.slice().reverse();
|
|
117
117
|
const totalFeesMtok = BigInt(route.total_fees_msat);
|
|
118
118
|
const totalAmtMtok = BigInt(route.total_amt_msat);
|
|
119
119
|
|
|
120
120
|
return {
|
|
121
121
|
confidence: confidence || undefined,
|
|
122
|
-
fee: safeTokens({
|
|
122
|
+
fee: safeTokens({mtokens: route.total_fees_msat}).tokens,
|
|
123
123
|
fee_mtokens: route.total_fees_msat,
|
|
124
|
-
hops: route.hops.map(
|
|
124
|
+
hops: route.hops.map(h => {
|
|
125
125
|
return {
|
|
126
|
-
channel: chanFormat({
|
|
126
|
+
channel: chanFormat({number: h.chan_id}).channel,
|
|
127
127
|
channel_capacity: Number(h.chan_capacity),
|
|
128
|
-
fee: safeTokens({
|
|
128
|
+
fee: safeTokens({mtokens: h.fee_msat}).tokens,
|
|
129
129
|
fee_mtokens: h.fee_msat,
|
|
130
|
-
forward: safeTokens({
|
|
130
|
+
forward: safeTokens({mtokens: h.amt_to_forward_msat}).tokens,
|
|
131
131
|
forward_mtokens: h.amt_to_forward_msat,
|
|
132
132
|
public_key: h.pub_key,
|
|
133
133
|
timeout: h.expiry,
|
|
134
134
|
};
|
|
135
135
|
}),
|
|
136
|
-
messages: keys((lastHop || {}).custom_records || {}).map(
|
|
137
|
-
const rawType = Buffer.from(type,
|
|
136
|
+
messages: keys((lastHop || {}).custom_records || {}).map(type => {
|
|
137
|
+
const rawType = Buffer.from(type, 'ascii').reverse();
|
|
138
138
|
|
|
139
139
|
const typeNumber = new BN(rawType).toString();
|
|
140
140
|
|
|
141
141
|
return {
|
|
142
142
|
type: typeNumber,
|
|
143
|
-
value: lastHop.custom_records[type].toString(
|
|
143
|
+
value: lastHop.custom_records[type].toString('hex'),
|
|
144
144
|
};
|
|
145
145
|
}),
|
|
146
146
|
mtokens: route.total_amt_msat,
|
|
147
|
-
safe_fee: safeTokens({
|
|
148
|
-
safe_tokens: safeTokens({
|
|
147
|
+
safe_fee: safeTokens({mtokens: route.total_fees_msat}).safe,
|
|
148
|
+
safe_tokens: safeTokens({mtokens: route.total_amt_msat}).safe,
|
|
149
149
|
timeout: route.total_time_lock,
|
|
150
|
-
tokens: safeTokens({
|
|
150
|
+
tokens: safeTokens({mtokens: route.total_amt_msat}).tokens,
|
|
151
151
|
};
|
|
152
152
|
}),
|
|
153
153
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
const {
|
|
1
|
+
const {chanFormat} = require('bolt07');
|
|
2
2
|
|
|
3
|
-
const {
|
|
3
|
+
const {channelTypes} = require('./constants');
|
|
4
4
|
const parseThawHeight = require('./parse_thaw_height');
|
|
5
5
|
const rpcHtlcAsPayment = require('./rpc_htlc_as_payment');
|
|
6
6
|
|
|
7
|
-
const {
|
|
7
|
+
const {isArray} = Array;
|
|
8
8
|
const msPerSec = 1e3;
|
|
9
9
|
const outpointDelimiter = ':';
|
|
10
10
|
|
|
@@ -218,7 +218,7 @@ module.exports = args => {
|
|
|
218
218
|
}
|
|
219
219
|
|
|
220
220
|
const commitWeight = Number(args.commit_weight);
|
|
221
|
-
const {
|
|
221
|
+
const {height} = parseThawHeight({id: args.chan_id, thaw: args.thaw_height});
|
|
222
222
|
const own = args.local_constraints;
|
|
223
223
|
const peer = args.remote_constraints;
|
|
224
224
|
const pushAmount = Number(args.push_amount_sat) || Number();
|
|
@@ -231,21 +231,22 @@ module.exports = args => {
|
|
|
231
231
|
|
|
232
232
|
const otherIds = args.alias_scids
|
|
233
233
|
.filter(n => n !== channelId)
|
|
234
|
-
.map(number => chanFormat({
|
|
234
|
+
.map(number => chanFormat({number}));
|
|
235
235
|
|
|
236
236
|
const customChannelData = args.custom_channel_data ?
|
|
237
|
-
|
|
238
|
-
|
|
237
|
+
Buffer.from(args.custom_channel_data, "hex").toString("utf-8")
|
|
238
|
+
: ""
|
|
239
239
|
|
|
240
240
|
return {
|
|
241
241
|
capacity: Number(args.capacity),
|
|
242
|
+
|
|
242
243
|
commit_transaction_fee: Number(args.commit_fee),
|
|
243
244
|
commit_transaction_weight: commitWeight,
|
|
244
245
|
cooperative_close_address: args.close_address || undefined,
|
|
245
246
|
cooperative_close_delay_height: height,
|
|
246
247
|
description: args.memo || undefined,
|
|
247
|
-
id: chanFormat({
|
|
248
|
-
channel_id:
|
|
248
|
+
id: chanFormat({number: channelId}).channel,
|
|
249
|
+
channel_id:channelId,
|
|
249
250
|
is_active: args.active,
|
|
250
251
|
is_closing: false,
|
|
251
252
|
is_opening: false,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
const {
|
|
1
|
+
const {chanFormat} = require('bolt07');
|
|
2
2
|
|
|
3
|
-
const {
|
|
3
|
+
const {safeTokens} = require('./../bolt00');
|
|
4
4
|
|
|
5
|
-
const discount =
|
|
6
|
-
const inverse =
|
|
7
|
-
const isHash =
|
|
5
|
+
const discount = fee => (!fee ? 0 : -fee).toString();
|
|
6
|
+
const inverse = rate => !rate ? 0 : -rate;
|
|
7
|
+
const isHash = n => /^[0-9A-F]{64}$/i.test(n);
|
|
8
8
|
const notFound = -1;
|
|
9
|
-
const outpointDivider =
|
|
9
|
+
const outpointDivider = ':';
|
|
10
10
|
|
|
11
11
|
/** Derive channel fees from RPC fees
|
|
12
12
|
|
|
@@ -31,42 +31,42 @@ const outpointDivider = ":";
|
|
|
31
31
|
transaction_vout: <Funding Outpoint Output Index Number>
|
|
32
32
|
}
|
|
33
33
|
*/
|
|
34
|
-
module.exports =
|
|
34
|
+
module.exports = channel => {
|
|
35
35
|
if (!channel) {
|
|
36
|
-
throw new Error(
|
|
36
|
+
throw new Error('ExpectedRpcChannelPolicyToDeriveChannelFees');
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
if (!channel.channel_point) {
|
|
40
|
-
throw new Error(
|
|
40
|
+
throw new Error('ExpectedChannelPoint');
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
if (channel.channel_point.indexOf(outpointDivider) === notFound) {
|
|
44
|
-
throw new Error(
|
|
44
|
+
throw new Error('UnexpectedChannelPointFormat');
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
const [txId, index] = channel.channel_point.split(outpointDivider);
|
|
48
48
|
|
|
49
49
|
if (!isHash(txId)) {
|
|
50
|
-
throw new Error(
|
|
50
|
+
throw new Error('ExpectedChannelPointTransactionId');
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
if (!index) {
|
|
54
|
-
throw new Error(
|
|
54
|
+
throw new Error('ExpectedChannelPointIndex');
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
if (!channel.base_fee_msat) {
|
|
58
|
-
throw new Error(
|
|
58
|
+
throw new Error('ExpectedBaseFeeForChannel');
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
if (!channel.fee_per_mil) {
|
|
62
|
-
throw new Error(
|
|
62
|
+
throw new Error('ExpectedFeeRatePerMillion');
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
return {
|
|
66
|
-
base_fee: safeTokens({
|
|
66
|
+
base_fee: safeTokens({mtokens: channel.base_fee_msat}).tokens,
|
|
67
67
|
base_fee_mtokens: channel.base_fee_msat,
|
|
68
68
|
fee_rate: Number(channel.fee_per_mil),
|
|
69
|
-
id: chanFormat({
|
|
69
|
+
id: chanFormat({number: channel.chan_id}).channel,
|
|
70
70
|
inbound_base_discount_mtokens: discount(channel.inbound_base_fee_msat),
|
|
71
71
|
inbound_rate_discount: inverse(channel.inbound_fee_per_mil),
|
|
72
72
|
transaction_id: txId,
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
const BN = require(
|
|
2
|
-
const {
|
|
1
|
+
const BN = require('bn.js');
|
|
2
|
+
const {chanFormat} = require('bolt07');
|
|
3
3
|
|
|
4
|
-
const {
|
|
4
|
+
const {safeTokens} = require('./../bolt00');
|
|
5
5
|
|
|
6
|
-
const bufferAsHex =
|
|
7
|
-
const {
|
|
8
|
-
const {
|
|
6
|
+
const bufferAsHex = buffer => buffer.toString('hex');
|
|
7
|
+
const {isBuffer} = Buffer;
|
|
8
|
+
const {keys} = Object;
|
|
9
9
|
|
|
10
|
-
const numberAsChannelId =
|
|
10
|
+
const numberAsChannelId = number => chanFormat({number}).channel;
|
|
11
11
|
|
|
12
12
|
/** Map an RPC forward request to a forward request
|
|
13
13
|
|
|
@@ -50,60 +50,60 @@ const numberAsChannelId = (number) => chanFormat({ number }).channel;
|
|
|
50
50
|
tokens: <Tokens to Forward to Next Peer Rounded Down Number>
|
|
51
51
|
}
|
|
52
52
|
*/
|
|
53
|
-
module.exports =
|
|
53
|
+
module.exports = forward => {
|
|
54
54
|
if (!forward) {
|
|
55
|
-
throw new Error(
|
|
55
|
+
throw new Error('ExpectedRpcForwardRequestToMapToForwardRequest');
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
if (!forward.custom_records) {
|
|
59
|
-
throw new Error(
|
|
59
|
+
throw new Error('ExpectedCustomRecordsInRpcForwardRequest');
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
if (!forward.incoming_amount_msat) {
|
|
63
|
-
throw new Error(
|
|
63
|
+
throw new Error('ExpectedIncomingAmountMillitokensInRpcForwardRequest');
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
if (!forward.incoming_circuit_key) {
|
|
67
|
-
throw new Error(
|
|
67
|
+
throw new Error('ExpectedInboundChannelDetailsInRpcForwardRequest')
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
if (!forward.incoming_circuit_key.chan_id) {
|
|
71
|
-
throw new Error(
|
|
71
|
+
throw new Error('ExpectedInboundChannelIdInRpcForwardRequest');
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
if (forward.incoming_circuit_key.htlc_id === undefined) {
|
|
75
|
-
throw new Error(
|
|
75
|
+
throw new Error('ExpectedInboundChannelHtlcIndexInRpcForwardRequest');
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
if (!forward.incoming_expiry) {
|
|
79
|
-
throw new Error(
|
|
79
|
+
throw new Error('ExpectedCltvTimeoutHeightInRpcForwardRequest');
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
if (!forward.outgoing_amount_msat) {
|
|
83
|
-
throw new Error(
|
|
83
|
+
throw new Error('ExpectedOutgoingAmountMillitokensInRpcForwardRequest');
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
if (!forward.outgoing_expiry) {
|
|
87
|
-
throw new Error(
|
|
87
|
+
throw new Error('ExpectedOutgoingExpiryHeightInRpcForwardRequest');
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
if (forward.outgoing_expiry > forward.incoming_expiry) {
|
|
91
|
-
throw new Error(
|
|
91
|
+
throw new Error('ExpectedIncomingForwardExpiryHigherThanOutgoingExpiry');
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
if (!forward.outgoing_requested_chan_id) {
|
|
95
|
-
throw new Error(
|
|
95
|
+
throw new Error('ExpectedOutgoingRequestedChannelIdInRpcForwardRequest');
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
if (!isBuffer(forward.payment_hash)) {
|
|
99
|
-
throw new Error(
|
|
99
|
+
throw new Error('ExpectedPaymentHashBufferInRpcForwardRequest');
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
const incomingAmount = BigInt(forward.incoming_amount_msat);
|
|
103
103
|
const outgoingAmount = BigInt(forward.outgoing_amount_msat);
|
|
104
104
|
|
|
105
105
|
if (incomingAmount < outgoingAmount) {
|
|
106
|
-
throw new Error(
|
|
106
|
+
throw new Error('UnexpectedNegativeFeeInRpcForwardRequest');
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
const hasOnion = !!forward.onion_blob && !!forward.onion_blob.length;
|
|
@@ -111,23 +111,23 @@ module.exports = (forward) => {
|
|
|
111
111
|
|
|
112
112
|
return {
|
|
113
113
|
cltv_delta: forward.incoming_expiry - forward.outgoing_expiry,
|
|
114
|
-
fee: safeTokens({
|
|
114
|
+
fee: safeTokens({mtokens: totalFeeAmount.toString()}).tokens,
|
|
115
115
|
fee_mtokens: totalFeeAmount.toString(),
|
|
116
116
|
hash: bufferAsHex(forward.payment_hash),
|
|
117
117
|
in_channel: numberAsChannelId(forward.incoming_circuit_key.chan_id),
|
|
118
118
|
in_payment: Number(forward.incoming_circuit_key.htlc_id),
|
|
119
|
-
messages: keys(forward.custom_records).map(
|
|
120
|
-
const rawType = Buffer.from(type,
|
|
119
|
+
messages: keys(forward.custom_records).map(type => {
|
|
120
|
+
const rawType = Buffer.from(type, 'ascii').reverse();
|
|
121
121
|
|
|
122
122
|
return {
|
|
123
123
|
type: new BN(rawType).toString(),
|
|
124
|
-
value: forward.custom_records[type].toString(
|
|
124
|
+
value: forward.custom_records[type].toString('hex'),
|
|
125
125
|
};
|
|
126
126
|
}),
|
|
127
127
|
mtokens: forward.outgoing_amount_msat,
|
|
128
|
-
onion: hasOnion ? forward.onion_blob.toString(
|
|
128
|
+
onion: hasOnion ? forward.onion_blob.toString('hex') : undefined,
|
|
129
129
|
out_channel: numberAsChannelId(forward.outgoing_requested_chan_id),
|
|
130
130
|
timeout: forward.incoming_expiry,
|
|
131
|
-
tokens: safeTokens({
|
|
131
|
+
tokens: safeTokens({mtokens: forward.outgoing_amount_msat}).tokens,
|
|
132
132
|
};
|
|
133
133
|
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
const {
|
|
1
|
+
const {parsePaymentRequest} = require('invoices');
|
|
2
2
|
|
|
3
|
-
const rpcAttemptHtlcAsAttempt = require(
|
|
4
|
-
const {
|
|
3
|
+
const rpcAttemptHtlcAsAttempt = require('./rpc_attempt_htlc_as_attempt');
|
|
4
|
+
const {safeTokens} = require('./../bolt00');
|
|
5
5
|
|
|
6
|
-
const emptyHash = Buffer.alloc(32).toString(
|
|
7
|
-
const {
|
|
6
|
+
const emptyHash = Buffer.alloc(32).toString('hex');
|
|
7
|
+
const {isArray} = Array;
|
|
8
8
|
const msPerSecond = 1e3;
|
|
9
9
|
const nanoSecsPerMillisecond = BigInt(1e6);
|
|
10
|
-
const routePublicKeys =
|
|
10
|
+
const routePublicKeys = route => route.hops.map(n => n.public_key);
|
|
11
11
|
|
|
12
12
|
/** Payment details from RPC payment details
|
|
13
13
|
|
|
@@ -153,33 +153,33 @@ const routePublicKeys = (route) => route.hops.map((n) => n.public_key);
|
|
|
153
153
|
tokens: <Rounded Down Tokens Sent to Destination Number>
|
|
154
154
|
}
|
|
155
155
|
*/
|
|
156
|
-
module.exports =
|
|
156
|
+
module.exports = payment => {
|
|
157
157
|
if (!payment) {
|
|
158
|
-
throw new Error(
|
|
158
|
+
throw new Error('ExpectedPaymentInRpcResponse');
|
|
159
159
|
}
|
|
160
160
|
|
|
161
161
|
if (!payment.creation_date) {
|
|
162
|
-
throw new Error(
|
|
162
|
+
throw new Error('ExpectedCreationDateInRpcPaymentDetails');
|
|
163
163
|
}
|
|
164
164
|
|
|
165
|
-
if (typeof payment.fee_sat !==
|
|
166
|
-
throw new Error(
|
|
165
|
+
if (typeof payment.fee_sat !== 'string') {
|
|
166
|
+
throw new Error('ExpectedPaymentFeeInRpcPaymentDetails');
|
|
167
167
|
}
|
|
168
168
|
|
|
169
169
|
if (!isArray(payment.htlcs)) {
|
|
170
|
-
throw new Error(
|
|
170
|
+
throw new Error('ExpectedHtlcsArrayInRpcPaymentDetails');
|
|
171
171
|
}
|
|
172
172
|
|
|
173
173
|
if (!payment.payment_hash) {
|
|
174
|
-
throw new Error(
|
|
174
|
+
throw new Error('ExpectedPaymentHashInRpcPaymentDetails');
|
|
175
175
|
}
|
|
176
176
|
|
|
177
177
|
if (!payment.payment_preimage) {
|
|
178
|
-
throw new Error(
|
|
178
|
+
throw new Error('ExpectedPaymentPreimageInRpcPaymentDetails');
|
|
179
179
|
}
|
|
180
180
|
|
|
181
|
-
if (typeof payment.value_sat !==
|
|
182
|
-
throw new Error(
|
|
181
|
+
if (typeof payment.value_sat !== 'string') {
|
|
182
|
+
throw new Error('ExpectedPaymentValueInRpcPaymentDetails');
|
|
183
183
|
}
|
|
184
184
|
|
|
185
185
|
const creationDateEpochMs = (() => {
|
|
@@ -191,13 +191,13 @@ module.exports = (payment) => {
|
|
|
191
191
|
return Number(BigInt(payment.creation_time_ns) / nanoSecsPerMillisecond);
|
|
192
192
|
})();
|
|
193
193
|
|
|
194
|
-
const attempts = payment.htlcs.map(
|
|
194
|
+
const attempts = payment.htlcs.map(htlc => rpcAttemptHtlcAsAttempt(htlc));
|
|
195
195
|
const index = Number(payment.payment_index) || undefined;
|
|
196
196
|
const request = payment.payment_request || undefined;
|
|
197
197
|
|
|
198
198
|
// Exit early when there were no attempts
|
|
199
199
|
if (!attempts.length) {
|
|
200
|
-
const {
|
|
200
|
+
const {destination} = !!request ? parsePaymentRequest({request}) : {};
|
|
201
201
|
|
|
202
202
|
return {
|
|
203
203
|
attempts,
|
|
@@ -214,20 +214,17 @@ module.exports = (payment) => {
|
|
|
214
214
|
is_outgoing: true,
|
|
215
215
|
mtokens: payment.value_msat,
|
|
216
216
|
safe_fee: undefined,
|
|
217
|
-
safe_tokens: safeTokens({
|
|
217
|
+
safe_tokens: safeTokens({mtokens: payment.value_msat}).safe,
|
|
218
218
|
secret: undefined,
|
|
219
|
-
tokens: safeTokens({
|
|
219
|
+
tokens: safeTokens({mtokens: payment.value_msat}).tokens,
|
|
220
220
|
};
|
|
221
221
|
}
|
|
222
222
|
|
|
223
223
|
const hasPreimage = payment.payment_preimage !== emptyHash;
|
|
224
224
|
const [attempt] = attempts;
|
|
225
|
-
const successes = attempts.filter(
|
|
225
|
+
const successes = attempts.filter(n => n.is_confirmed);
|
|
226
226
|
|
|
227
|
-
const [confirmedAt] = successes
|
|
228
|
-
.map((n) => n.confirmed_at)
|
|
229
|
-
.sort()
|
|
230
|
-
.reverse();
|
|
227
|
+
const [confirmedAt] = successes.map(n => n.confirmed_at).sort().reverse();
|
|
231
228
|
const path = routePublicKeys(attempt.route);
|
|
232
229
|
|
|
233
230
|
const [destination, ...hops] = path.reverse();
|
|
@@ -249,9 +246,9 @@ module.exports = (payment) => {
|
|
|
249
246
|
is_outgoing: true,
|
|
250
247
|
mtokens: payment.value_msat,
|
|
251
248
|
safe_fee: undefined,
|
|
252
|
-
safe_tokens: safeTokens({
|
|
249
|
+
safe_tokens: safeTokens({mtokens: payment.value_msat}).safe,
|
|
253
250
|
secret: undefined,
|
|
254
|
-
tokens: safeTokens({
|
|
251
|
+
tokens: safeTokens({mtokens: payment.value_msat}).tokens,
|
|
255
252
|
};
|
|
256
253
|
}
|
|
257
254
|
|
|
@@ -262,16 +259,16 @@ module.exports = (payment) => {
|
|
|
262
259
|
request,
|
|
263
260
|
confirmed_at: confirmedAt || undefined,
|
|
264
261
|
created_at: new Date(creationDateEpochMs).toISOString(),
|
|
265
|
-
fee: safeTokens({
|
|
262
|
+
fee: safeTokens({mtokens: payment.fee_msat}).tokens,
|
|
266
263
|
fee_mtokens: payment.fee_msat,
|
|
267
264
|
hops: hops.reverse(),
|
|
268
265
|
id: payment.payment_hash,
|
|
269
266
|
is_confirmed: true,
|
|
270
267
|
is_outgoing: true,
|
|
271
268
|
mtokens: payment.value_msat,
|
|
272
|
-
safe_fee: safeTokens({
|
|
273
|
-
safe_tokens: safeTokens({
|
|
269
|
+
safe_fee: safeTokens({mtokens: payment.fee_msat}).safe,
|
|
270
|
+
safe_tokens: safeTokens({mtokens: payment.value_msat}).safe,
|
|
274
271
|
secret: payment.payment_preimage,
|
|
275
|
-
tokens: safeTokens({
|
|
272
|
+
tokens: safeTokens({mtokens: payment.value_msat}).tokens,
|
|
276
273
|
};
|
|
277
274
|
};
|