{"name":"bolt07","version":"1.8.3","keywords":["bolt","channel-id","channel-number","lightning","lightning-network","lnd"],"author":{"url":"https://twitter.com/alexbosworth","name":"Alex Bosworth"},"license":"MIT","_id":"bolt07@1.8.3","maintainers":[{"name":"alexbosworth","email":"alex.bosworth+npm@gmail.com"}],"homepage":"https://github.com/alexbosworth/bolt07#readme","bugs":{"url":"https://github.com/alexbosworth/bolt07/issues"},"dist":{"shasum":"1f8e581c715c4289fd16949237f9c4061d06081f","tarball":"http://registry-npm.ywwl.com/bolt07/download/bolt07-1.8.3.tgz","fileCount":41,"integrity":"sha512-NXML2vzFmxRrdWt+wNqphU6f8FmS7tkebqDLIhfc8xKoOcGFv4Kf7WuJbKBqcfFDQVXpCpKAF7FQAgTIN2/30A==","signatures":[{"sig":"MEUCICigxIBWNA9OrQsDS4PRaJmcGKpGrP14bp/3vQ+jPqjPAiEAiKt//AggCFlkyO9oXly65vKUzL2lH5i+HwLwVDO3/l8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":97314,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjt3y6ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmrw4w//cgrHkIZQ0EyEsAOWs7ZZbXHhz/XSuN6OYBfDg9hCYjFWCqzw\r\nyh+sw/8tWxEQIi72s8douWHd5cDXkmW6pMqtyYzt9YCXNLdBoIJBX02nfUKj\r\nydcdqsIL5JOvxce1y1nSnpPdXl+vf3Cn+bYGDlA95OMswwdVGk9Lv9TDKqFK\r\nHZ2VUPsh3C7FKJk+BRSTl6xnhvxbrh44TSl3D/PGkvPdQTPzdU5GDeRn2mKE\r\nm9IMikP/4dnoEgLtxxfYV3aFrAjvuWhVypnEEPFkpNtBTCRYlk1LcDyUN3Ou\r\n5Ck68rXLmlVOK1EHmOjK2bEjiK2Wq56WFvS7fIO9Ueeafvu6BU+3a9xaqbl2\r\nVb0M5lsdUzXpF38GJnHznfUHmm9aLoEyVz1Op5db1Qyp/iSmeWaKbB78Q7mJ\r\njPTgg3sfDiH9MbduGhCDNkUgi5OuH+8jYaO9JpfVv9ySGlq2NyhZsILINwtc\r\n8IlqPQbzoXJbfl+qW8ZaS+/BF83D/EVdgnJxB/1lMI0ZXofOdADDVFDpyYu7\r\n/y3Cor6Tkn/NCQwW2tn0WlKOT7iBl1K7YYeVrA7LzlahxBmeuIJvjiJ3+Tu2\r\ncXRpDVVHWjmxpXJOvLn4+y037ditJBZMbDOIMNL0QP3TITPeCc81rKwOEc06\r\nHLxEQJnE6ja1fX56pGp/YOPMeQzEU0W6Gxs=\r\n=whsJ\r\n-----END PGP SIGNATURE-----\r\n","size":16652,"noattachment":false,"key":"/bolt07/-/bolt07-1.8.3.tgz"},"main":"index.js","gitHead":"d4d867f4949d65ce53863052f08a3c01e9728933","scripts":{"test":"tap --branches=1 --functions=1 --lines=1 --statements=1 test/addresses/*.js test/ids/*.js test/routing/*.js"},"_npmUser":{"name":"alexbosworth","email":"alex.bosworth+npm@gmail.com"},"repository":{"url":"git+https://github.com/alexbosworth/bolt07.git","type":"git"},"_npmVersion":"8.13.1","description":"Utilities for working with bolt07 data formats","directories":{},"_nodeVersion":"18.12.1","dependencies":{"bn.js":"5.2.1"},"_hasShrinkwrap":false,"devDependencies":{"@alexbosworth/tap":"15.0.12"},"_npmOperationalInternal":{"tmp":"tmp/bolt07_1.8.3_1672969402071_0.4932653865248273","host":"s3://npm-registry-packages"},"readme":"# BOLT07\n\nUtilities for working with Lightning Network [BOLT 07](https://github.com/lightningnetwork/lightning-rfc/blob/master/07-routing-gossip.md)\n\n[![npm version](https://badge.fury.io/js/bolt07.svg)](https://badge.fury.io/js/bolt07)\n\n## Methods\n\n- [chanFormat](#chanformat) - convert number or raw bytes format channel id to standard format\n- [chanNumber](#channumber) - convert standard, raw bytes format channel id to number format\n- [decodeChanId](#decodechanid) - decode block height and index components of a channel id\n- [encodeChanId](#encodechanid) - encode block height and index components into a channel id\n- [hopsFromChannels](#hopsfromchannels) - derive policy hops from a list of channels\n- [rawChanId](#rawchanid) - convert numeric or standard channel id into a raw wire form\n- [routeFromChannels](#routefromchannels) - derive a route from a sequence of channels\n- [routeFromHops](#routefromhops) - derive a route from a sequence of policy hops\n\n## Examples\n\nSample code for working with bolt07 utility functions:\n\n### Formats\n\n- Channel: `x` delimited format designed to be readable.\n- Id: The raw channel id format specified by bolt07.\n- Number: Interpreting the raw channel id format as a uint64.\n\n### Chan Format\n\n```node\nconst {chanFormat} = require('bolt07');\n\nconst id = '15fbe70000260000';\nconst number = '1584113681139367936';\n\ntry {\n  const fromNumber = chanFormat({number}).channel;\n  // fromNumber === '1440743x38x0'\n} catch (err) {\n  // valid channel, no error\n}\n\ntry {\n  const fromId = chanFormat({id}).channel;\n  // fromId === '1440743x38x0'\n} catch (err) {\n  // valid id, no error\n}\n```\n\n### Chan Number\n\n```node\nconst {chanNumber} = require('bolt07');\n\nconst channel = '1440743x38x0';\nconst id = '15fbe70000260000';\n\ntry {\n  const fromChannel = chanNumber({channel}).number;\n  // fromChannel === '1584113681139367936'\n} catch (err) {\n  // valid channel, no error\n}\n\ntry {\n  const fromId = chanNumber({id}).number;\n  // fromId === '1584113681139367936'\n} catch (err) {\n  // valid id, no error\n}\n```\n\n### decodeChanId\n\nReturns components of a channel id or channel number.\n\n```node\nconst {decodeChanId} = require('bolt07');\n\nconst channel = '1440743x38x0';\nconst id = '15fbe70000260000';\nconst number = '1584113681139367936';\n\ntry {\n  const fromChannel = decodeChanId({channel});\n  // fromChannel.block_height === 1440743\n  // fromChannel.block_index === 38\n  // fromChannel.output_index === 0\n} catch (err) {\n  // valid channel, no error\n}\n\ntry {\n  const fromId = decodeChanId({id});\n  // fromId.block_height === 1440743\n  // fromId.block_index === 38\n  // fromId.output_index === 0\n} catch (err) {\n  // valid id, no error\n}\n\ntry {\n  const fromNumber = decodeChanId({channel});\n  // fromNumber.block_height === 1440743\n  // fromNumber.block_index === 38\n  // fromNumber.output_index === 0\n} catch (err) {\n  // valid number, no error\n}\n```\n\n### encodeChanId\n\nReturns channel id when components are specified\n\n```node\nconst {encodeChanId} = require('bolt07');\n\ntry {\n  const encoded = encodeChanId({\n    block_height: 1440743,\n    block_index: 38,\n    output_index: 0,\n  });\n\n  // encoded.channel === '1440743x38x0'\n  // encoded.id === '15fbe70000260000'\n  // encoded.number === '1584113681139367936'\n} catch (err) {\n  // valid components, no error\n}\n```\n\n### Raw Chan Id\n\nReturns a raw channel id in numeric format.\n\n```node\nconst {rawChanId} = require('bolt07');\n\nconst channel = '1440743x38x0';\nconst number = '1584113681139367936';\n\ntry {\n  const idFromNumber = rawChanId({number}).id;\n  // idFromNumber === '15fbe70000260000'\n} catch (err) {\n  // valid number, no error\n}\n\ntry {\n  const idFromChannel = rawChanId({channel}).id;\n  // idFromChannel === '15fbe70000260000'\n} catch (err) {\n  // valid channel, no error\n}\n```\n\n## Methods\n\n### chanFormat\n\nGet channel components formatted string\n\n    {\n      [id]: <Raw Channel Id String>\n      [number]: <Number Format Channel Id String>\n    }\n\n    @throws\n    <Error>\n\n    @returns\n    {\n      channel: <Components Channel Format String>\n    }\n\n### chanNumber\n\nChannel id in numeric format\n\n    {\n      [channel]: <Channel Components String>\n      [id]: <Channel Id Hex String>\n    }\n\n    @throws\n    <ExpectedChannelIdOrComponentsToConvertToNumber Error>\n\n    @returns\n    {\n      number: <Channel Id Number String>\n    }\n\n### decodeChanId\n\nDecode a short channel id into components\n\n    {\n      [channel]: <Channel Components String>\n      [id]: <Channel Id Hex String>\n      [number]: <Channel Id Number Format String>\n    }\n\n    @throws\n    <ExpectedShortChannelIdToDecode Error>\n    <UnexpectedErrorDecodingChannelIdNumber Error>\n    <UnexpectedLengthOfShortChannelId Error>\n\n    @returns\n    {\n      block_height: <Channel Funding Transaction Inclusion Block Height Number>\n      block_index: <Channel Funding Transaction Inclusion Block Position Number>\n      output_index: <Channel Funding Transaction Output Index Number>\n    }\n\n### encodeChanId\n\nEncode a short channel id from components\n\n    {\n      block_height: <Channel Funding Transaction Inclusion Block Height Number>\n      block_index: <Channel Funding Transaction Inclusion Block Position Number>\n      output_index: <Channel Funding Transaction Output Index Number>\n    }\n\n    @throws\n    <ExpectedBlockHeightForChannelId Error>\n    <ExpectedBlockIndexForChannelId Error>\n    <ExpectedTransactionOutputIndexForChannelId Error>\n\n    @returns\n    {\n      channel: <Channel Components Format String>\n      id: <Channel Id Hex String>\n      number: <Channel Number String>\n    }\n\n### rawChanId\n\nRaw channel id\n\n    {\n      [channel]: <Channel Components String>\n      [number]: <Channel Id In Number Format String>\n    }\n\n    @throws\n    <Error>\n\n    @returns\n    {\n      id: <Raw Channel Id Hex String>\n    }\n\n### routeFromChannels\n\nGet a route from a sequence of channels\n\nEither next hop destination in channels or final destination is required\n\n    {\n      channels: [{\n        capacity: <Maximum Tokens Number>\n        [destination]: <Next Node Public Key Hex String>\n        id: <Standard Format Channel Id String>\n        policies: [{\n          base_fee_mtokens: <Base Fee Millitokens String>\n          cltv_delta: <Locktime Delta Number>\n          fee_rate: <Fees Charged in Millitokens Per Million Number>\n          is_disabled: <Channel Is Disabled Bool>\n          max_htlc_mtokens: <Maximum HTLC Millitokens Value String>\n          min_htlc_mtokens: <Minimum HTLC Millitokens Value String>\n          public_key: <Node Public Key String>\n        }]\n      }]\n      [cltv_delta]: <Final CLTV Delta Number>\n      [destination]: <Destination Public Key Hex String>\n      height: <Current Block Height Number>\n      [messages]: [{\n        type: <Message Type Number String>\n        value: <Message Raw Value Hex Encoded String>\n      }]\n      mtokens: <Millitokens To Send String>\n      [payment]: <Payment Identification Value Hex String>\n      [total_mtokens]: <Sum of Shards Millitokens String>\n    }\n\n    @throws\n    <Error>\n\n    @returns\n    {\n      route: {\n        fee: <Total Fee Tokens To Pay Number>\n        fee_mtokens: <Total Fee Millitokens To Pay String>\n        hops: [{\n          channel: <Standard Format Channel Id String>\n          channel_capacity: <Channel Capacity Tokens Number>\n          fee: <Fee Number>\n          fee_mtokens: <Fee Millitokens String>\n          forward: <Forward Tokens Number>\n          forward_mtokens: <Forward Millitokens String>\n          [public_key]: <Public Key Hex String>\n          timeout: <Timeout Block Height Number>\n        }]\n        [messages]: [{\n          type: <Message Type Number String>\n          value: <Message Raw Value Hex Encoded String>\n        }]\n        mtokens: <Total Fee-Inclusive Millitokens String>\n        [payment]: <Payment Identification Value Hex String>\n        timeout: <Timeout Block Height Number>\n        tokens: <Total Fee-Inclusive Tokens Number>\n        [total_mtokens]: <Sum of Shards Millitokens String>\n      }\n    }\n\n### routeFromHops\n\nGiven hops to a destination, construct a payable route\n\n    {\n      [cltv_delta]: <Final Cltv Delta Number>\n      height: <Current Block Height Number>\n      hops: [{\n        base_fee_mtokens: <Base Fee Millitokens String>\n        channel: <Standard Format Channel Id String>\n        [channel_capacity]: <Channel Capacity Tokens Number>\n        cltv_delta: <CLTV Delta Number>\n        fee_rate: <Fee Rate In Millitokens Per Million Number>\n        public_key: <Next Hop Public Key Hex String>\n      }]\n      initial_cltv: <Initial CLTV Delta Number>\n      [messages]: [{\n        type: <Message Type Number String>\n        value: <Message Raw Value Hex Encoded String>\n      }]\n      mtokens: <Millitokens To Send String>\n      [payment]: <Payment Identification Value Hex String>\n      [total_mtokens]: <Total Millitokens For Sharded Payments String>\n    }\n\n    @throws\n    <Error>\n\n    @returns\n    {\n      fee: <Route Fee Tokens Number>\n      fee_mtokens: <Route Fee Millitokens String>\n      hops: [{\n        channel: <Standard Format Channel Id String>\n        channel_capacity: <Channel Capacity Tokens Number>\n        fee: <Fee Number>\n        fee_mtokens: <Fee Millitokens String>\n        forward: <Forward Tokens Number>\n        forward_mtokens: <Forward Millitokens String>\n        [public_key]: <Public Key Hex String>\n        timeout: <Timeout Block Height Number>\n      }]\n      [messages]: [{\n        type: <Message Type Number String>\n        value: <Message Raw Value Hex Encoded String>\n      }]\n      mtokens: <Total Fee-Inclusive Millitokens String>\n      [payment]: <Payment Identification Value Hex String>\n      timeout: <Timeout Block Height Number>\n      tokens: <Total Fee-Inclusive Tokens Number>\n      [total_mtokens]: <Sharded Payments Total Millitokens String>\n    }\n","publish_time":1672969402281,"_cnpm_publish_time":1672969402281,"dist-tags":{"latest":"2.0.0"}}