{"name":"bolt07","version":"1.8.0","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.0","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":"931d95c5691f7954e1e8c58fec8b4ced5210f23d","tarball":"http://registry-npm.ywwl.com/bolt07/download/bolt07-1.8.0.tgz","fileCount":40,"integrity":"sha512-UJq+p94UK9QsU3P1npJyWF3r8TuJd6kv6P4m656VQK/m5ifw0bWCkYF0ngcHbFGq3j8u3gP8/tkGtB8WwPPRbQ==","signatures":[{"sig":"MEUCIDqfuebW72gJLm8fXkB0dHEIfnb2TGt0bV6gpxEJQBBGAiEA8XKvN3PjKFRC/A+dRit6ipMLjA2TqONAtG5ORutngMs=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":95514,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhzPYQCRA9TVsSAnZWagAAgi4QAI12sJR+IZk3gdkVlXH4\nfyO588Xgeq+Dm1glSQooKKzvzmZjt5fOh/QZWGpix8PchEbV1QgzE/Bp4NcB\nP5H2kpp2tGBvzrNn1H7vEt5/xeH7kyziGiDORPWs3no2CGAQKoraHqYzzD97\nEStHBsadS3+KPjk94kULGci85zv8MfL2qWX6TK2Q37tsQy3wVMNV6EbZMdk4\nE7GSVm7AunGzCUrJF8BXvN+Z0VS7ZwhMRyz6huXawkXoTWX/pw3dL7rmuIOy\nNYbOLs/ErTF9GJgXbTayV+jhuhiE8RgTKoBsz9kDokxm3wK9Y7X6mzgG8b7a\n3bJVRE+qpqOvjPTCe68tlv/xb0ANIs6klyjz+CgydIQP01vt5iVwulqGG+XT\nUQdE0BFlhrovVvKwOQ4H/sw1LXCNy1N4W//M+Pi7kp58EVTKrGcnzEH0i0V7\n3x4OhEW8vHRPPP16iVDeTY4UKZWqSdxM91POx9zbcAE7lyPFg2c/VzyaeUMD\nVhm0xn3c8wGTGzhtZx5RmAVDANnJLO0aoDK0Ea5b9FBkGKHeRNhU1SCxtC/f\nybQu2nbf7HP7fPOGHD439vpGNN1dALN+71VyfQq9ujLoPj6kfIZkfYM8VxRX\nSDwGGcFlENaok+SY+rCKfTY4yLu2WjMyM8x9V/Vov0+fz/d9zM4grZqF+AKE\ntYkM\r\n=yuSq\r\n-----END PGP SIGNATURE-----\r\n","size":16296,"noattachment":false,"key":"/bolt07/-/bolt07-1.8.0.tgz"},"main":"index.js","gitHead":"519c94a7837e687bf7478a74779d5ea493a76a44","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.1.0","description":"Utilities for working with bolt07 data formats","directories":{},"_nodeVersion":"16.13.0","dependencies":{"bn.js":"5.2.0"},"_hasShrinkwrap":false,"devDependencies":{"@alexbosworth/tap":"15.0.10"},"_npmOperationalInternal":{"tmp":"tmp/bolt07_1.8.0_1640822287993_0.1682525732180986","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":1640822288183,"_cnpm_publish_time":1640822288183,"dist-tags":{"latest":"2.0.0"}}