{"name":"bolt07","version":"1.5.1","keywords":["bolt","channel-id","channel-number","lightning","lightning-network","lnd"],"author":{"url":"https://twitter.com/alexbosworth","name":"Alex Bosworth"},"license":"MIT","_id":"bolt07@1.5.1","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":"e3a88b594d0740e745f65c4593d1e8870b027cc2","tarball":"http://registry-npm.ywwl.com/bolt07/download/bolt07-1.5.1.tgz","fileCount":33,"integrity":"sha512-pNFpkyu5zW0NUKErTjRNcHsmTjEghvx02t/lscnke9xbJgxE2ZnLMDZFBhgl5xBPCeGGouIuEWd3MXsBLSd6Cg==","signatures":[{"sig":"MEYCIQDrjTGkCdmoYROV1rrV8CutqVUlqhyPjT0bjpYPRQDGMAIhAK2rYl9gJKDFh+xZ9NmvpVnfw8BGITH+6x5ZCTnCdI7p","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":82691,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe2pzyCRA9TVsSAnZWagAAIlAP/RinpAhLSkSAlpXpUmNf\nwENnZCP4pDi0xVK6xzdoi+wbVNi9hSEfneHadZjValf2Ss3nxzVlfDoLfTPz\nLUdqI6JtKJFod3tq8bUkox1I91m8KZ8qHWgYRuBnO/7VqIAF2o/Kk8ZGwd10\nAS5ppaHJErhq6mh3BPAGMMSgxU4Ynp4cabvFbNgVVGnnAjhMCW+vQRJzMAYS\n0xBz1412upU8TupqvBjDKcTZOd3JVDPxmMiQ1F8a7YwPazkhrLw1/7ISo4Nw\nF8fwJhrqnctE3y8/hq+kAzKYYAukqf7YVDP6XFkUTxLuqGYFQXFCy8GDY08q\nzWXhIGlbM1PBijwBpJDJ2evj9M/zK4Hf4JGMkRwDKlLyTaaE8mszrjfC7gcr\nuCXhAEHBm3BaJ2mjN25CJmEfZIar1rqVS41mY77B8KvKXRg42Fry0HUyi5sA\nFW1tJ8cvo3nrv40/F0SA5b3xQBctl1HBlafBuDitUoP44sYRQexlcGxXzQKb\n1FNpBoB/Qr82hG41QxBdW1imxGW+n/j4rxjdY3x1TwoII5jzBqms0SE1S9ua\n5qJwsOFLYQKIv8jdGNda2eTtQPUt42uBaDqDiR572hi0+oEi5wm2FOT22Vdr\nl4hyfQhWxQaLcCbphZnZs9gjY4D2H9rhGRSuR7Gy2mk5foqF7jIgT5msagVH\nOoxh\r\n=tbNj\r\n-----END PGP SIGNATURE-----\r\n","size":13788,"noattachment":false,"key":"/bolt07/-/bolt07-1.5.1.tgz"},"main":"index.js","gitHead":"701382a33f8b094c69d845bafaad88089ce1ca22","scripts":{"test":"tap 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":"6.14.5","description":"Utilities for working with bolt07 data formats","directories":{},"_nodeVersion":"12.16.3","dependencies":{"bn.js":"5.1.2"},"_hasShrinkwrap":false,"devDependencies":{"tap":"14.10.7"},"_npmOperationalInternal":{"tmp":"tmp/bolt07_1.5.1_1591385330065_0.11134068165164246","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":1591385330418,"_cnpm_publish_time":1591385330418,"dist-tags":{"latest":"2.0.0"}}