├── .eslintignore ├── .eslintrc.js ├── .gitignore ├── .prettierrc.js ├── LICENSE ├── README.md ├── example ├── .eslintignore ├── .eslintrc.js ├── .prettierrc.js ├── index.ts ├── package.json ├── tsconfig.json └── yarn.lock ├── lib ├── index.js ├── index.js.map ├── obdapi.js ├── obdapi.js.map ├── pojo.js ├── pojo.js.map ├── result.js ├── result.js.map ├── shapes.js ├── shapes.js.map ├── types.js ├── types.js.map ├── types │ ├── index.d.ts │ ├── obdapi.d.ts │ ├── pojo.d.ts │ ├── result.d.ts │ ├── shapes.d.ts │ ├── types.d.ts │ └── utils │ │ ├── browser-or-node.d.ts │ │ ├── index.d.ts │ │ └── networks.d.ts └── utils │ ├── browser-or-node.js │ ├── browser-or-node.js.map │ ├── index.js │ ├── index.js.map │ ├── networks.js │ └── networks.js.map ├── package.json ├── src ├── index.ts ├── obdapi.ts ├── pojo.ts ├── result.ts ├── shapes.ts ├── types.ts └── utils │ ├── browser-or-node.ts │ ├── index.ts │ └── networks.ts ├── tests ├── constants.ts ├── omnibolt.test.ts └── utils.test.ts ├── tsconfig.json └── yarn.lock /.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | !.eslintrc.js 3 | lib/* 4 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | parser: '@typescript-eslint/parser', 4 | plugins: ['@typescript-eslint'], 5 | globals: { 6 | localStorage: false, 7 | }, 8 | rules: { 9 | semi: 'off', 10 | '@typescript-eslint/semi': ['error'], 11 | 'no-shadow': 'off', 12 | '@typescript-eslint/no-shadow': 'error', 13 | '@typescript-eslint/no-unused-vars': 'error', 14 | 'no-console': 0, 15 | 'no-empty': ['error', { allowEmptyCatch: true }], 16 | 'no-buffer-constructor': 0, 17 | 'no-case-declarations': 0, 18 | 'no-useless-escape': 0, 19 | indent: [ 20 | 2, 21 | 'tab', 22 | { SwitchCase: 1, ignoredNodes: ['ConditionalExpression'] }, 23 | ], 24 | 'object-curly-spacing': [ 25 | 'error', 26 | 'always', 27 | { 28 | objectsInObjects: true, 29 | }, 30 | ], 31 | 'no-undef': 0, 32 | 'require-atomic-updates': 0, 33 | 'no-async-promise-executor': 0, 34 | 'brace-style': [2, '1tbs', { allowSingleLine: true }], 35 | '@typescript-eslint/explicit-function-return-type': 'warn', 36 | }, 37 | }; 38 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /.prettierrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | bracketSpacing: true, 3 | jsxBracketSameLine: true, 4 | singleQuote: true, 5 | trailingComma: 'all', 6 | useTabs: true, 7 | tabWidth: 2, 8 | semi: true, 9 | }; 10 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Synonym 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # omnibolt-js 2 | 3 | ## ⚠️ Warning 4 | This is pre-alpha software and only intended for use on Bitcoin Testnet. Please use at your own risk. Expect breaking changes. 5 | 6 | - [⚙️ Installation](#%EF%B8%8F-installation) 7 | - [⚡️ Setup & Connect](#%EF%B8%8F-setup--connect) 8 | - [🧰 Methods](#-methods) 9 | * [Get Connection Info (obdapi.getInfo)](#get-connection-info) 10 | * [Get Funding Address (obdapi.getFundingAddress)](#get-funding-address) 11 | * [Get Connect URI (obdapi.getConnectUri)](#get-connect-uri) 12 | * [Parse Connect URI (parseOmniboltUri)](#parse-connect-uri) 13 | * [Create Channel (obdapi.createChannel)](#create-channel) 14 | * [Get Omnibolt Channels (obdapi.getMyChannels)](#get-omnibolt-channels) 15 | * [Send Asset (obdapi.sendOmniAsset)](#send-asset) 16 | * [Close Channel (obdapi.closeChannel)](#close-channel) 17 | * [Get Asset Info By ID (obdapi.getProperty)](#get-asset-info-by-id) 18 | - [📖 API Documentation](#-api-documentation) 19 | - [🤖 Debugging Tool](#-debugging-tool) 20 | - [📝️ License [MIT]](#%EF%B8%8F-license-mit) 21 | 22 | 23 | ## ⚙️ Installation 24 | 25 | ``` 26 | yarn add https://github.com/synonymdev/omnibolt-js.git 27 | 28 | or 29 | 30 | npm i -S https://github.com/synonymdev/omnibolt-js.git 31 | ``` 32 | 33 | ## ⚡️ Setup & Connect 34 | 35 | ``` 36 | import { ObdApi } from "omnibolt-js"; 37 | import { defaultDataShape } from "omnibolt-js/lib/shapes.js"; 38 | import { parseOmniboltUri } from "omnibolt-js/src/utils"; 39 | 40 | import storage from 'node-persist'; 41 | import WebSocket from 'ws'; 42 | 43 | await storage.init(); 44 | 45 | // This is the passphrase used to login to the omnibolt server. 46 | const loginPhrase = 'snow evidence basic rally wing flock room mountain monitor page sail betray steel major fall pioneer summer tenant pact bargain lucky joy lab parrot'; 47 | 48 | /* 49 | This is the mnemonic phrase used for signing and transferring 50 | assets and should be stored securely and separately 51 | from the other data. 52 | */ 53 | const mnemonic = 'table panda praise oyster benefit ticket bonus capital silly burger fatal use oyster cream feel wine trap focus planet sail atom approve album valid'; 54 | 55 | // Omnibolt server to connect to. 56 | const url = '62.234.216.108:60020/wstest'; 57 | 58 | const selectedNetwork = 'bitcoinTestnet'; //'bitcoin' | 'bitcoinTestnet' 59 | 60 | /* 61 | This is used to save the address signing data. 62 | It keeps track of funds and the next available 63 | addresses for signing. 64 | */ 65 | const saveData = async (data) => { 66 | await storage.setItem('omnibolt', JSON.stringify(data)); 67 | console.log('Data saved...', data); 68 | }; 69 | 70 | /* 71 | This method is used to retrieve the previously stored 72 | data from the "saveData" method in your application. 73 | If no data is available, just pass in an empty object {} or the defaultDataShape object. 74 | */ 75 | const getData = async (key = 'omnibolt') => { 76 | try { 77 | return JSON.parse(await storage.getItem(key)) ?? { ...defaultDataShape }; 78 | } catch { 79 | return { ...defaultDataShape }; 80 | } 81 | } 82 | 83 | // Retrieve data, if any. 84 | const data = await getData(); 85 | 86 | // Create OBD instance. 87 | const obdapi = new ObdApi({ websocket: WebSocket }); 88 | 89 | // Connect to the specified server and setup env params. 90 | const connectResponse = await obdapi.connect({ 91 | loginPhrase, 92 | mnemonic, 93 | url, 94 | selectedNetwork, 95 | saveData, 96 | data, 97 | }); 98 | if (connectResponse.isErr()) { 99 | console.log(connectResponse.error.message); 100 | return; 101 | } 102 | ``` 103 | 104 | ## 🧰 Methods 105 | 106 | ##### Get Connection Info 107 | ``` 108 | const info = obdapi.getInfo(); 109 | ``` 110 | 111 | ##### Get Funding Address 112 | This is the address used to fund a given channel with Bitcoin and Omni assets. 113 | ``` 114 | const fundingAddress = await obdapi.getFundingAddress({ index: 0 }); 115 | ``` 116 | 117 | ##### Get Connect URI 118 | This method returns a string that provides the information necessary for others to connect and open channels to you. 119 | ``` 120 | const connectUri = obdapi.getConnectUri(); 121 | if (connectUri.isErr()) { 122 | console.log(connectUri.error.message); 123 | return; 124 | } 125 | console.log(connectUri.value); 126 | ``` 127 | 128 | ##### Parse Connect URI 129 | This helper method parses a provided omnibolt uri. In this case, we're parsing the connect uri string where it will provide us with the given action ("connect") along with the embedded data that's expected with a connect action ("remote_node_address" & "recipient_user_peer_id"). 130 | ``` 131 | const parsedConnectUri = parseOmniboltUri(connectUri); 132 | if (parsedConnectUri.isErr()) { 133 | console.log(parsedConnectUri.error.message); 134 | return; 135 | } 136 | const { action } = parsedConnectUri.value; 137 | const { remote_node_address, recipient_user_peer_id } = parsedConnectUri.value.data; 138 | ``` 139 | 140 | ##### Create Channel 141 | There are three pre-requisites to successfully create, fund and open an omnibolt channel: 142 | 1. The peer you're attempting to open a channel with must be online. 143 | 2. The funding address must have a sufficient Bitcoin balance in order to cover the fees for channel opening (amount_to_fund + miner_fee) * 3. 144 | 3. The funding address must have a balance of the specified omni asset (`asset_id`) greater than the amount you intend to create a channel with (`asset_amount`). 145 | 146 | In the following example, we're assuming that the `fundingAddressIndex` of 0 has a Bitcoin balance greater than (0.0001 + 0.00005) * 3 and an omni asset balance >= 5. 147 | ``` 148 | const createChannelResponse = await obdapi.createChannel({ 149 | remote_node_address, 150 | recipient_user_peer_id, 151 | info: { 152 | fundingAddressIndex: 0, 153 | asset_id: 137, 154 | asset_amount: 5, 155 | amount_to_fund: 0.0001, 156 | miner_fee: 0.00005, 157 | }, 158 | }); 159 | if (createChannelResponse.isErr()) { 160 | console.log(createChannelResponse.error.message); 161 | } else { 162 | console.log(createChannelResponse.value); 163 | } 164 | ``` 165 | 166 | ##### Get Omnibolt Channels 167 | ``` 168 | const channelResponse = await obdapi.getMyChannels(); 169 | ``` 170 | 171 | ##### Send Asset 172 | ``` 173 | await obdapi.sendOmniAsset({ 174 | channelId, 175 | amount, 176 | recipient_node_peer_id, 177 | recipient_user_peer_id, 178 | }); 179 | ``` 180 | 181 | ##### Close Channel 182 | ``` 183 | await obdapi.closeChannel( 184 | recipient_node_peer_id, 185 | recipient_user_peer_id, 186 | channelId, 187 | ); 188 | ``` 189 | 190 | ##### Get Asset Info By ID 191 | ``` 192 | const id = '137'; 193 | const assetInfo = await obdapi.getProperty(id); 194 | ``` 195 | 196 | ### 📖 API Documentation 197 | 198 | - https://api.omnilab.online/ 199 | 200 | ### 🤖 Debugging Tool 201 | 202 | - https://github.com/omnilaboratory/DebuggingTool/ 203 | 204 | ### 📝️ License [MIT](https://github.com/synonymdev/omnibolt-js/blob/master/LICENSE) 205 | -------------------------------------------------------------------------------- /example/.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | !.eslintrc.js 3 | lib/* 4 | -------------------------------------------------------------------------------- /example/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | parser: '@typescript-eslint/parser', 4 | plugins: ['@typescript-eslint'], 5 | globals: { 6 | localStorage: false, 7 | }, 8 | rules: { 9 | semi: 'off', 10 | '@typescript-eslint/semi': ['error'], 11 | 'no-shadow': 'off', 12 | '@typescript-eslint/no-shadow': 'error', 13 | '@typescript-eslint/no-unused-vars': 'error', 14 | 'no-console': 0, 15 | 'no-empty': ['error', { allowEmptyCatch: true }], 16 | 'no-buffer-constructor': 0, 17 | 'no-case-declarations': 0, 18 | 'no-useless-escape': 0, 19 | indent: [ 20 | 2, 21 | 'tab', 22 | { SwitchCase: 1, ignoredNodes: ['ConditionalExpression'] }, 23 | ], 24 | 'object-curly-spacing': [ 25 | 'error', 26 | 'always', 27 | { 28 | objectsInObjects: true, 29 | }, 30 | ], 31 | 'no-undef': 0, 32 | 'require-atomic-updates': 0, 33 | 'no-async-promise-executor': 0, 34 | 'brace-style': [2, '1tbs', { allowSingleLine: true }], 35 | '@typescript-eslint/explicit-function-return-type': 'warn', 36 | }, 37 | }; 38 | -------------------------------------------------------------------------------- /example/.prettierrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | bracketSpacing: true, 3 | jsxBracketSameLine: true, 4 | singleQuote: true, 5 | trailingComma: 'all', 6 | useTabs: true, 7 | tabWidth: 2, 8 | semi: true, 9 | }; 10 | -------------------------------------------------------------------------------- /example/index.ts: -------------------------------------------------------------------------------- 1 | import { ObdApi } from '../src'; 2 | import { defaultDataShape } from '../src/shapes'; 3 | import storage from 'node-persist'; 4 | import WebSocket from 'ws'; 5 | import { ISaveData } from '../lib/types/types'; 6 | import { parseOmniboltUri } from '../src/utils'; 7 | 8 | storage.init().then(async (): Promise => { 9 | // This is the passphrase used to login to the omnibolt server. 10 | const loginPhrase = 'snow evidence basic rally wing flock room mountain monitor page sail betray steel major fall pioneer summer tenant pact bargain lucky joy lab parrot'; 11 | 12 | /* 13 | This is the mnemonic phrase used for signing and transferring 14 | assets and should be stored securely and separately 15 | from the other data. 16 | */ 17 | const mnemonic = 'table panda praise oyster benefit ticket bonus capital silly burger fatal use oyster cream feel wine trap focus planet sail atom approve album valid'; 18 | 19 | // Omnibolt server to connect to. 20 | const url = '62.234.216.108:60020/wstest'; 21 | 22 | const selectedNetwork: 'bitcoin' | 'bitcoinTestnet' = 'bitcoinTestnet'; 23 | 24 | /* 25 | This is used to save the address signing data. 26 | It keeps track of funds and the next available 27 | addresses for signing. 28 | */ 29 | const saveData = async (data: ISaveData): Promise => { 30 | await storage.setItem('omnibolt', JSON.stringify(data)); 31 | console.log('Data saved...', data); 32 | }; 33 | 34 | /* 35 | This method is used to retrieve the previously stored 36 | data from the "saveData" method in your application. 37 | If no data is available, just pass in an empty object {} 38 | */ 39 | const getData = async (key = 'omnibolt'): Promise => { 40 | try { 41 | return JSON.parse(await storage.getItem(key)) ?? { ...defaultDataShape }; 42 | } catch { 43 | return { ...defaultDataShape }; 44 | } 45 | }; 46 | 47 | // Retrieve data, if any. 48 | const data = await getData(); 49 | 50 | const obdapi: ObdApi = new ObdApi({ websocket: WebSocket }); 51 | const connectResponse = await obdapi.connect({ 52 | loginPhrase, 53 | mnemonic, 54 | url, 55 | selectedNetwork, 56 | saveData, 57 | data, 58 | }); 59 | if (connectResponse.isErr()) { 60 | console.log('connectResponse error', connectResponse.error.message); 61 | return; 62 | } 63 | console.log('connectResponse', connectResponse.value); 64 | console.log('\n'); 65 | 66 | // Get connection info 67 | const getInfoResponse = obdapi.getInfo(); 68 | console.log('getInfoResponse', getInfoResponse); 69 | console.log('\n'); 70 | 71 | // Retrieve omnibolt funding address 72 | const fundingAddress = await obdapi.getFundingAddress({}); 73 | if (fundingAddress.isErr()) { 74 | console.log('fundingAddress error', fundingAddress.error.message); 75 | return; 76 | } 77 | console.log('fundingAddress', fundingAddress); 78 | console.log('\n'); 79 | 80 | // Get available channels 81 | const channelResponse = await obdapi.getMyChannels(); 82 | if (channelResponse.isErr()) { 83 | console.log('channelResponse error', channelResponse.error.message); 84 | return; 85 | } 86 | console.log('channelResponse', channelResponse.value); 87 | console.log('\n'); 88 | 89 | // Get asset info 90 | const id = '137'; 91 | const assetInfoResponse = await obdapi.getProperty(id); 92 | if (assetInfoResponse.isErr()) { 93 | console.log('assetInfoResponse error', assetInfoResponse.error.message); 94 | return; 95 | } 96 | console.log('assetInfoResponse', assetInfoResponse.value); 97 | console.log('\n'); 98 | 99 | const getConnectUriResponse = obdapi.getConnectUri(); 100 | if (getConnectUriResponse.isErr()) { 101 | console.log('getConnectStringResponse error', getConnectUriResponse.error.message); 102 | return; 103 | } 104 | console.log('getConnectStringResponse', getConnectUriResponse.value); 105 | console.log('\n'); 106 | 107 | const parseOmniboltUriResponse = parseOmniboltUri(getConnectUriResponse.value); 108 | if (parseOmniboltUriResponse.isErr()) { 109 | console.log('parseOmniboltUriResponse error', parseOmniboltUriResponse.error.message); 110 | return; 111 | } 112 | console.log('parseOmniboltUriResponse', parseOmniboltUriResponse.value); 113 | console.log('\n'); 114 | 115 | const getAllBalancesForAddressResponse = await obdapi.getAllBalancesForAddress(fundingAddress.value.address); 116 | if (getAllBalancesForAddressResponse.isErr()) { 117 | console.log('getAllBalancesForAddressResponse error', getAllBalancesForAddressResponse.error.message); 118 | return; 119 | } 120 | console.log('getAllBalancesForAddressResponse', getAllBalancesForAddressResponse.value); 121 | console.log('\n'); 122 | 123 | const getTransactionResponse = await obdapi.getTransaction('a04a7a285e636ebf013ceec94748ee9dbe8d3d72f64a53cc12fcbc36d45fce2f'); 124 | if (getTransactionResponse.isErr()) { 125 | console.log('getTransactionResponse error', getTransactionResponse.error.message); 126 | return; 127 | } 128 | console.log('getTransactionResponse', getTransactionResponse.value); 129 | console.log('\n'); 130 | }); 131 | -------------------------------------------------------------------------------- /example/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "omnibolt-js-example", 3 | "version": "1.0.0", 4 | "description": "", 5 | "types": "lib/types/index.d.ts", 6 | "files": [ 7 | "lib/**/*" 8 | ], 9 | "author": "Synonym", 10 | "license": "MIT", 11 | "devDependencies": { 12 | "@typescript-eslint/eslint-plugin": "^5.10.0", 13 | "@typescript-eslint/parser": "^5.10.0", 14 | "eslint": "^8.7.0", 15 | "prettier": "^2.5.1", 16 | "typescript": "^3.9.7" 17 | }, 18 | "dependencies": { 19 | "node-persist": "^3.1.0", 20 | "ws": "^8.4.2" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /example/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2017", 4 | "module": "commonjs", 5 | "outDir": "./lib", 6 | "declarationDir": "./lib/types", 7 | "sourceMap": true, 8 | "removeComments": true, 9 | "allowSyntheticDefaultImports": true, 10 | "esModuleInterop": true, 11 | "isolatedModules": false, 12 | "resolveJsonModule": true, 13 | "noImplicitAny": false, 14 | "moduleResolution": "node", 15 | "declaration": true, 16 | "strict": true, 17 | "allowJs": true, 18 | "strictNullChecks": true, 19 | "strictFunctionTypes": true, 20 | "strictPropertyInitialization": true, 21 | "noImplicitThis": true, 22 | "alwaysStrict": true, 23 | "noUnusedLocals": true, 24 | "skipLibCheck": true 25 | //"noUnusedParameters": true 26 | }, 27 | "include": [ 28 | "*/*.ts" 29 | ], 30 | "exclude": ["node_modules"] 31 | } 32 | -------------------------------------------------------------------------------- /lib/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __importDefault = (this && this.__importDefault) || function (mod) { 3 | return (mod && mod.__esModule) ? mod : { "default": mod }; 4 | }; 5 | Object.defineProperty(exports, "__esModule", { value: true }); 6 | exports.ObdApi = void 0; 7 | const obdapi_1 = __importDefault(require("./obdapi")); 8 | exports.ObdApi = obdapi_1.default; 9 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /lib/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,sDAA8B;AAErB,iBAFF,gBAAM,CAEE"} -------------------------------------------------------------------------------- /lib/pojo.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.MessageType = exports.P2PPeer = exports.AtomicSwapAccepted = exports.AtomicSwapRequest = exports.CloseChannelSign = exports.OmniSendRevoke = exports.OmniSendGrant = exports.IssueFixedAmountInfo = exports.IssueManagedAmoutInfo = exports.CloseHtlcTxInfoSigned = exports.CloseHtlcTxInfo = exports.SignRInfo = exports.ForwardRInfo = exports.HtlcRequestOpen = exports.SignGetHInfo = exports.HtlcSignedInfo = exports.addHTLCInfo = exports.HTLCFindPathInfo = exports.InvoiceInfo = exports.CommitmentTxSigned = exports.CommitmentTx = exports.SignedInfo100114 = exports.SignedInfo100113 = exports.SignedInfo100112 = exports.SignedInfo100111 = exports.SignedInfo100110 = exports.SignedInfo100106 = exports.SignedInfo100105 = exports.SignedInfo100104 = exports.SignedInfo100103 = exports.SignedInfo100102 = exports.SignedInfo100101 = exports.SignedInfo100100 = exports.SignedInfo100364 = exports.SignedInfo100363 = exports.SignedInfo100362 = exports.SignedInfo100361 = exports.SignedInfo100360 = exports.SignedInfo101134 = exports.SignedInfo101035 = exports.AssetFundingSignedInfo = exports.AssetFundingCreatedInfo = exports.AcceptChannelInfo = exports.OpenChannelInfo = exports.OmniSendAssetInfo = exports.OmniFundingAssetInfo = exports.FundingBtcSigned = exports.FundingBtcCreated = exports.BtcFundingInfo = exports.Message = void 0; 4 | class Message { 5 | constructor() { 6 | this.type = 0; 7 | this.data = {}; 8 | this.recipient_user_peer_id = ''; 9 | this.recipient_node_peer_id = ''; 10 | } 11 | } 12 | exports.Message = Message; 13 | class BtcFundingInfo { 14 | constructor() { 15 | this.from_address = ''; 16 | this.to_address = ''; 17 | this.amount = 0.0; 18 | this.miner_fee = 0.0; 19 | } 20 | } 21 | exports.BtcFundingInfo = BtcFundingInfo; 22 | class FundingBtcCreated { 23 | constructor() { 24 | this.temporary_channel_id = ''; 25 | this.funding_tx_hex = ''; 26 | } 27 | } 28 | exports.FundingBtcCreated = FundingBtcCreated; 29 | class FundingBtcSigned { 30 | constructor() { 31 | this.temporary_channel_id = ''; 32 | this.funding_txid = ''; 33 | this.signed_miner_redeem_transaction_hex = ''; 34 | this.approval = false; 35 | } 36 | } 37 | exports.FundingBtcSigned = FundingBtcSigned; 38 | class OmniFundingAssetInfo { 39 | constructor() { 40 | this.from_address = ''; 41 | this.to_address = ''; 42 | this.property_id = 0; 43 | this.amount = 0; 44 | this.miner_fee = 0.0; 45 | } 46 | } 47 | exports.OmniFundingAssetInfo = OmniFundingAssetInfo; 48 | class OmniSendAssetInfo { 49 | constructor() { 50 | this.from_address = ''; 51 | this.to_address = ''; 52 | this.property_id = 0; 53 | this.amount = 0; 54 | } 55 | } 56 | exports.OmniSendAssetInfo = OmniSendAssetInfo; 57 | class OpenChannelInfo { 58 | constructor() { 59 | this.funding_pubkey = ''; 60 | this.is_private = false; 61 | } 62 | } 63 | exports.OpenChannelInfo = OpenChannelInfo; 64 | class AcceptChannelInfo { 65 | constructor() { 66 | this.temporary_channel_id = ''; 67 | this.funding_pubkey = ''; 68 | this.approval = false; 69 | } 70 | } 71 | exports.AcceptChannelInfo = AcceptChannelInfo; 72 | class AssetFundingCreatedInfo { 73 | constructor() { 74 | this.temporary_channel_id = ''; 75 | this.funding_tx_hex = ''; 76 | this.temp_address_pub_key = ''; 77 | this.temp_address_index = 0; 78 | } 79 | } 80 | exports.AssetFundingCreatedInfo = AssetFundingCreatedInfo; 81 | class AssetFundingSignedInfo { 82 | constructor() { 83 | this.temporary_channel_id = ''; 84 | this.signed_alice_rsmc_hex = ''; 85 | } 86 | } 87 | exports.AssetFundingSignedInfo = AssetFundingSignedInfo; 88 | class SignedInfo101035 { 89 | constructor() { 90 | this.temporary_channel_id = ''; 91 | this.rd_signed_hex = ''; 92 | this.br_signed_hex = ''; 93 | this.br_id = 0; 94 | } 95 | } 96 | exports.SignedInfo101035 = SignedInfo101035; 97 | class SignedInfo101134 { 98 | constructor() { 99 | this.channel_id = ''; 100 | this.rd_signed_hex = ''; 101 | } 102 | } 103 | exports.SignedInfo101134 = SignedInfo101134; 104 | class SignedInfo100360 { 105 | constructor() { 106 | this.channel_id = ''; 107 | this.rsmc_signed_hex = ''; 108 | this.counterparty_signed_hex = ''; 109 | } 110 | } 111 | exports.SignedInfo100360 = SignedInfo100360; 112 | class SignedInfo100361 { 113 | constructor() { 114 | this.channel_id = ''; 115 | this.c2b_rsmc_signed_hex = ''; 116 | this.c2b_counterparty_signed_hex = ''; 117 | this.c2a_rd_signed_hex = ''; 118 | this.c2a_br_signed_hex = ''; 119 | this.c2a_br_id = 0; 120 | } 121 | } 122 | exports.SignedInfo100361 = SignedInfo100361; 123 | class SignedInfo100362 { 124 | constructor() { 125 | this.channel_id = ''; 126 | this.c2b_rsmc_signed_hex = ''; 127 | this.c2b_counterparty_signed_hex = ''; 128 | this.c2a_rd_signed_hex = ''; 129 | } 130 | } 131 | exports.SignedInfo100362 = SignedInfo100362; 132 | class SignedInfo100363 { 133 | constructor() { 134 | this.channel_id = ''; 135 | this.c2b_rd_signed_hex = ''; 136 | this.c2b_br_signed_hex = ''; 137 | this.c2b_br_id = 0; 138 | } 139 | } 140 | exports.SignedInfo100363 = SignedInfo100363; 141 | class SignedInfo100364 { 142 | constructor() { 143 | this.channel_id = ''; 144 | this.c2b_rd_signed_hex = ''; 145 | } 146 | } 147 | exports.SignedInfo100364 = SignedInfo100364; 148 | class SignedInfo100100 { 149 | constructor() { 150 | this.channel_id = ''; 151 | this.c3a_counterparty_partial_signed_hex = ''; 152 | this.c3a_htlc_partial_signed_hex = ''; 153 | this.c3a_rsmc_partial_signed_hex = ''; 154 | } 155 | } 156 | exports.SignedInfo100100 = SignedInfo100100; 157 | class SignedInfo100101 { 158 | constructor() { 159 | this.channel_id = ''; 160 | this.c3a_rsmc_rd_partial_signed_hex = ''; 161 | this.c3a_rsmc_br_partial_signed_hex = ''; 162 | this.c3a_htlc_ht_partial_signed_hex = ''; 163 | this.c3a_htlc_hlock_partial_signed_hex = ''; 164 | this.c3a_htlc_br_partial_signed_hex = ''; 165 | this.c3b_rsmc_partial_signed_hex = ''; 166 | this.c3b_counterparty_partial_signed_hex = ''; 167 | this.c3b_htlc_partial_signed_hex = ''; 168 | } 169 | } 170 | exports.SignedInfo100101 = SignedInfo100101; 171 | class SignedInfo100102 { 172 | constructor() { 173 | this.channel_id = ''; 174 | this.c3a_rsmc_rd_complete_signed_hex = ''; 175 | this.c3a_htlc_ht_complete_signed_hex = ''; 176 | this.c3a_htlc_hlock_complete_signed_hex = ''; 177 | this.c3b_rsmc_complete_signed_hex = ''; 178 | this.c3b_counterparty_complete_signed_hex = ''; 179 | this.c3b_htlc_complete_signed_hex = ''; 180 | } 181 | } 182 | exports.SignedInfo100102 = SignedInfo100102; 183 | class SignedInfo100103 { 184 | constructor() { 185 | this.channel_id = ''; 186 | this.c3a_htlc_htrd_partial_signed_hex = ''; 187 | this.c3b_rsmc_rd_partial_signed_hex = ''; 188 | this.c3b_rsmc_br_partial_signed_hex = ''; 189 | this.c3b_htlc_htd_partial_signed_hex = ''; 190 | this.c3b_htlc_hlock_partial_signed_hex = ''; 191 | this.c3b_htlc_br_partial_signed_hex = ''; 192 | } 193 | } 194 | exports.SignedInfo100103 = SignedInfo100103; 195 | class SignedInfo100104 { 196 | constructor() { 197 | this.channel_id = ''; 198 | this.curr_htlc_temp_address_for_he_pub_key = ''; 199 | this.curr_htlc_temp_address_for_he_index = 0; 200 | this.c3a_htlc_htrd_complete_signed_hex = ''; 201 | this.c3a_htlc_htbr_partial_signed_hex = ''; 202 | this.c3a_htlc_hed_partial_signed_hex = ''; 203 | this.c3b_rsmc_rd_complete_signed_hex = ''; 204 | this.c3b_htlc_htd_complete_signed_hex = ''; 205 | this.c3b_htlc_hlock_complete_signed_hex = ''; 206 | } 207 | } 208 | exports.SignedInfo100104 = SignedInfo100104; 209 | class SignedInfo100105 { 210 | constructor() { 211 | this.channel_id = ''; 212 | this.c3b_htlc_hlock_he_partial_signed_hex = ''; 213 | } 214 | } 215 | exports.SignedInfo100105 = SignedInfo100105; 216 | class SignedInfo100106 { 217 | constructor() { 218 | this.channel_id = ''; 219 | this.c3b_htlc_herd_partial_signed_hex = ''; 220 | } 221 | } 222 | exports.SignedInfo100106 = SignedInfo100106; 223 | class SignedInfo100110 { 224 | constructor() { 225 | this.channel_id = ''; 226 | this.counterparty_partial_signed_hex = ''; 227 | this.rsmc_partial_signed_hex = ''; 228 | } 229 | } 230 | exports.SignedInfo100110 = SignedInfo100110; 231 | class SignedInfo100111 { 232 | constructor() { 233 | this.channel_id = ''; 234 | this.c4a_rd_signed_hex = ''; 235 | this.c4a_br_signed_hex = ''; 236 | this.c4a_br_id = ''; 237 | this.c4b_rsmc_signed_hex = ''; 238 | this.c4b_counterparty_signed_hex = ''; 239 | } 240 | } 241 | exports.SignedInfo100111 = SignedInfo100111; 242 | class SignedInfo100112 { 243 | constructor() { 244 | this.channel_id = ''; 245 | this.c4a_rd_complete_signed_hex = ''; 246 | this.c4b_rsmc_complete_signed_hex = ''; 247 | this.c4b_counterparty_complete_signed_hex = ''; 248 | } 249 | } 250 | exports.SignedInfo100112 = SignedInfo100112; 251 | class SignedInfo100113 { 252 | constructor() { 253 | this.channel_id = ''; 254 | this.c4b_rd_partial_signed_hex = ''; 255 | this.c4b_br_partial_signed_hex = ''; 256 | this.c4b_br_id = ''; 257 | } 258 | } 259 | exports.SignedInfo100113 = SignedInfo100113; 260 | class SignedInfo100114 { 261 | constructor() { 262 | this.channel_id = ''; 263 | this.c4b_rd_complete_signed_hex = ''; 264 | } 265 | } 266 | exports.SignedInfo100114 = SignedInfo100114; 267 | class CommitmentTx { 268 | constructor() { 269 | this.channel_id = ''; 270 | this.amount = 0; 271 | this.curr_temp_address_pub_key = ''; 272 | this.curr_temp_address_index = 0; 273 | this.last_temp_address_private_key = ''; 274 | } 275 | } 276 | exports.CommitmentTx = CommitmentTx; 277 | class CommitmentTxSigned { 278 | constructor() { 279 | this.channel_id = ''; 280 | this.msg_hash = ''; 281 | this.c2a_rsmc_signed_hex = ''; 282 | this.c2a_counterparty_signed_hex = ''; 283 | this.curr_temp_address_pub_key = ''; 284 | this.curr_temp_address_index = 0; 285 | this.last_temp_address_private_key = ''; 286 | this.approval = false; 287 | } 288 | } 289 | exports.CommitmentTxSigned = CommitmentTxSigned; 290 | class InvoiceInfo { 291 | constructor() { 292 | this.property_id = 0; 293 | this.amount = 0; 294 | this.h = ''; 295 | this.expiry_time = ''; 296 | this.description = ''; 297 | this.is_private = false; 298 | } 299 | } 300 | exports.InvoiceInfo = InvoiceInfo; 301 | class HTLCFindPathInfo extends InvoiceInfo { 302 | constructor() { 303 | super(...arguments); 304 | this.invoice = ''; 305 | this.recipient_node_peer_id = ''; 306 | this.recipient_user_peer_id = ''; 307 | this.is_inv_pay = false; 308 | } 309 | } 310 | exports.HTLCFindPathInfo = HTLCFindPathInfo; 311 | class addHTLCInfo { 312 | constructor() { 313 | this.recipient_user_peer_id = ''; 314 | this.property_id = 0; 315 | this.amount = 0; 316 | this.memo = ''; 317 | this.h = ''; 318 | this.routing_packet = ''; 319 | this.cltv_expiry = 0; 320 | this.last_temp_address_private_key = ''; 321 | this.curr_rsmc_temp_address_pub_key = ''; 322 | this.curr_rsmc_temp_address_index = 0; 323 | this.curr_htlc_temp_address_pub_key = ''; 324 | this.curr_htlc_temp_address_index = 0; 325 | this.curr_htlc_temp_address_for_ht1a_pub_key = ''; 326 | this.curr_htlc_temp_address_for_ht1a_index = 0; 327 | } 328 | } 329 | exports.addHTLCInfo = addHTLCInfo; 330 | class HtlcSignedInfo { 331 | constructor() { 332 | this.payer_commitment_tx_hash = ''; 333 | this.curr_rsmc_temp_address_pub_key = ''; 334 | this.curr_rsmc_temp_address_index = 0; 335 | this.curr_htlc_temp_address_pub_key = ''; 336 | this.curr_htlc_temp_address_index = 0; 337 | this.last_temp_address_private_key = ''; 338 | this.c3a_complete_signed_rsmc_hex = ''; 339 | this.c3a_complete_signed_counterparty_hex = ''; 340 | this.c3a_complete_signed_htlc_hex = ''; 341 | } 342 | } 343 | exports.HtlcSignedInfo = HtlcSignedInfo; 344 | class SignGetHInfo { 345 | constructor() { 346 | this.request_hash = ''; 347 | this.channel_address_private_key = ''; 348 | this.last_temp_address_private_key = ''; 349 | this.curr_rsmc_temp_address_pub_key = ''; 350 | this.curr_rsmc_temp_address_private_key = ''; 351 | this.curr_htlc_temp_address_pub_key = ''; 352 | this.curr_htlc_temp_address_private_key = ''; 353 | this.approval = false; 354 | } 355 | } 356 | exports.SignGetHInfo = SignGetHInfo; 357 | class HtlcRequestOpen { 358 | constructor() { 359 | this.request_hash = ''; 360 | this.channel_address_private_key = ''; 361 | this.last_temp_address_private_key = ''; 362 | this.curr_rsmc_temp_address_pub_key = ''; 363 | this.curr_rsmc_temp_address_private_key = ''; 364 | this.curr_htlc_temp_address_pub_key = ''; 365 | this.curr_htlc_temp_address_private_key = ''; 366 | this.curr_htlc_temp_address_for_ht1a_pub_key = ''; 367 | this.curr_htlc_temp_address_for_ht1a_private_key = ''; 368 | } 369 | } 370 | exports.HtlcRequestOpen = HtlcRequestOpen; 371 | class ForwardRInfo { 372 | constructor() { 373 | this.channel_id = ''; 374 | this.r = ''; 375 | } 376 | } 377 | exports.ForwardRInfo = ForwardRInfo; 378 | class SignRInfo { 379 | constructor() { 380 | this.channel_id = ''; 381 | this.c3b_htlc_herd_complete_signed_hex = ''; 382 | this.c3b_htlc_hebr_partial_signed_hex = ''; 383 | } 384 | } 385 | exports.SignRInfo = SignRInfo; 386 | class CloseHtlcTxInfo { 387 | constructor() { 388 | this.channel_id = ''; 389 | this.last_rsmc_temp_address_private_key = ''; 390 | this.last_htlc_temp_address_private_key = ''; 391 | this.last_htlc_temp_address_for_htnx_private_key = ''; 392 | this.curr_temp_address_pub_key = ''; 393 | this.curr_temp_address_index = 0; 394 | } 395 | } 396 | exports.CloseHtlcTxInfo = CloseHtlcTxInfo; 397 | class CloseHtlcTxInfoSigned { 398 | constructor() { 399 | this.msg_hash = ''; 400 | this.last_rsmc_temp_address_private_key = ''; 401 | this.last_htlc_temp_address_private_key = ''; 402 | this.last_htlc_temp_address_for_htnx_private_key = ''; 403 | this.curr_temp_address_pub_key = ''; 404 | this.curr_temp_address_index = 0; 405 | } 406 | } 407 | exports.CloseHtlcTxInfoSigned = CloseHtlcTxInfoSigned; 408 | class IssueManagedAmoutInfo { 409 | constructor() { 410 | this.from_address = ''; 411 | this.name = ''; 412 | this.ecosystem = 0; 413 | this.divisible_type = 0; 414 | this.data = ''; 415 | } 416 | } 417 | exports.IssueManagedAmoutInfo = IssueManagedAmoutInfo; 418 | class IssueFixedAmountInfo extends IssueManagedAmoutInfo { 419 | constructor() { 420 | super(...arguments); 421 | this.amount = 0; 422 | } 423 | } 424 | exports.IssueFixedAmountInfo = IssueFixedAmountInfo; 425 | class OmniSendGrant { 426 | constructor() { 427 | this.from_address = ''; 428 | this.property_id = 0; 429 | this.amount = 0; 430 | this.memo = ''; 431 | } 432 | } 433 | exports.OmniSendGrant = OmniSendGrant; 434 | class OmniSendRevoke extends OmniSendGrant { 435 | } 436 | exports.OmniSendRevoke = OmniSendRevoke; 437 | class CloseChannelSign { 438 | constructor() { 439 | this.channel_id = ''; 440 | this.request_close_channel_hash = ''; 441 | this.approval = false; 442 | } 443 | } 444 | exports.CloseChannelSign = CloseChannelSign; 445 | class AtomicSwapRequest { 446 | constructor() { 447 | this.channel_id_from = ''; 448 | this.channel_id_to = ''; 449 | this.recipient_user_peer_id = ''; 450 | this.property_sent = 0; 451 | this.amount = 0; 452 | this.exchange_rate = 0; 453 | this.property_received = 0; 454 | this.transaction_id = ''; 455 | this.time_locker = 0; 456 | } 457 | } 458 | exports.AtomicSwapRequest = AtomicSwapRequest; 459 | class AtomicSwapAccepted extends AtomicSwapRequest { 460 | constructor() { 461 | super(...arguments); 462 | this.target_transaction_id = ''; 463 | } 464 | } 465 | exports.AtomicSwapAccepted = AtomicSwapAccepted; 466 | class P2PPeer { 467 | constructor() { 468 | this.remote_node_address = ''; 469 | } 470 | } 471 | exports.P2PPeer = P2PPeer; 472 | class MessageType { 473 | constructor() { 474 | this.MsgType_Error_0 = 0; 475 | this.MsgType_UserLogin_2001 = -102001; 476 | this.MsgType_UserLogout_2002 = -102002; 477 | this.MsgType_p2p_ConnectPeer_2003 = -102003; 478 | this.MsgType_GetMnemonic_2004 = -102004; 479 | this.MsgType_GetMiniBtcFundAmount_2006 = -102006; 480 | this.MsgType_Core_GetNewAddress_2101 = -102101; 481 | this.MsgType_Core_GetMiningInfo_2102 = -102102; 482 | this.MsgType_Core_GetNetworkInfo_2103 = -102103; 483 | this.MsgType_Core_SignMessageWithPrivKey_2104 = -102104; 484 | this.MsgType_Core_VerifyMessage_2105 = -102105; 485 | this.MsgType_Core_DumpPrivKey_2106 = -102106; 486 | this.MsgType_Core_ListUnspent_2107 = -102107; 487 | this.MsgType_Core_BalanceByAddress_2108 = -102108; 488 | this.MsgType_Core_FundingBTC_2109 = -102109; 489 | this.MsgType_Core_BtcCreateMultiSig_2110 = -102110; 490 | this.MsgType_Core_Btc_ImportPrivKey_2111 = -102111; 491 | this.MsgType_Core_Omni_Getbalance_2112 = -102112; 492 | this.MsgType_Core_Omni_CreateNewTokenFixed_2113 = -102113; 493 | this.MsgType_Core_Omni_CreateNewTokenManaged_2114 = -102114; 494 | this.MsgType_Core_Omni_GrantNewUnitsOfManagedToken_2115 = -102115; 495 | this.MsgType_Core_Omni_RevokeUnitsOfManagedToken_2116 = -102116; 496 | this.MsgType_Core_Omni_ListProperties_2117 = -102117; 497 | this.MsgType_Core_Omni_GetTransaction_2118 = -102118; 498 | this.MsgType_Core_Omni_GetProperty_2119 = -102119; 499 | this.MsgType_Core_Omni_FundingAsset_2120 = -102120; 500 | this.MsgType_Core_Omni_Send_2121 = -102121; 501 | this.MsgType_Mnemonic_CreateAddress_3000 = -103000; 502 | this.MsgType_Mnemonic_GetAddressByIndex_3001 = -103001; 503 | this.MsgType_FundingCreate_Asset_AllItem_3100 = -103100; 504 | this.MsgType_FundingCreate_Asset_ItemById_3101 = -103101; 505 | this.MsgType_FundingCreate_Asset_ItemByChannelId_3102 = -103102; 506 | this.MsgType_FundingCreate_Asset_Count_3103 = -103103; 507 | this.MsgType_SendChannelOpen_32 = -100032; 508 | this.MsgType_RecvChannelOpen_32 = -110032; 509 | this.MsgType_SendChannelAccept_33 = -100033; 510 | this.MsgType_RecvChannelAccept_33 = -110033; 511 | this.MsgType_FundingCreate_SendAssetFundingCreated_34 = -100034; 512 | this.MsgType_FundingCreate_RecvAssetFundingCreated_34 = -110034; 513 | this.MsgType_FundingSign_SendAssetFundingSigned_35 = -100035; 514 | this.MsgType_FundingSign_RecvAssetFundingSigned_35 = -110035; 515 | this.MsgType_ClientSign_AssetFunding_AliceSignC1a_1034 = -101034; 516 | this.MsgType_ClientSign_AssetFunding_AliceSignRD_1134 = -101134; 517 | this.MsgType_ClientSign_Duplex_AssetFunding_RdAndBr_1035 = -101035; 518 | this.MsgType_FundingCreate_SendBtcFundingCreated_340 = -100340; 519 | this.MsgType_FundingCreate_BtcFundingMinerRDTxToClient_341 = -100341; 520 | this.MsgType_FundingCreate_RecvBtcFundingCreated_340 = -110340; 521 | this.MsgType_FundingSign_SendBtcSign_350 = -100350; 522 | this.MsgType_FundingSign_RecvBtcSign_350 = -110350; 523 | this.MsgType_CommitmentTx_SendCommitmentTransactionCreated_351 = -100351; 524 | this.MsgType_CommitmentTx_RecvCommitmentTransactionCreated_351 = -110351; 525 | this.MsgType_CommitmentTxSigned_SendRevokeAndAcknowledgeCommitmentTransaction_352 = -100352; 526 | this.MsgType_CommitmentTxSigned_RecvRevokeAndAcknowledgeCommitmentTransaction_352 = -110352; 527 | this.MsgType_ClientSign_BobC2b_Rd_353 = -110353; 528 | this.MsgType_ClientSign_CommitmentTx_AliceSignC2a_360 = -100360; 529 | this.MsgType_ClientSign_CommitmentTx_BobSignC2b_361 = -100361; 530 | this.MsgType_ClientSign_CommitmentTx_AliceSignC2b_362 = -100362; 531 | this.MsgType_ClientSign_CommitmentTx_AliceSignC2b_Rd_363 = -100363; 532 | this.MsgType_ClientSign_CommitmentTx_BobSignC2b_Rd_364 = -100364; 533 | this.MsgType_ChannelOpen_AllItem_3150 = -103150; 534 | this.MsgType_ChannelOpen_ItemByTempId_3151 = -103151; 535 | this.MsgType_ChannelOpen_Count_3152 = -103152; 536 | this.MsgType_ChannelOpen_DelItemByTempId_3153 = -103153; 537 | this.MsgType_GetChannelInfoByChannelId_3154 = -103154; 538 | this.MsgType_GetChannelInfoByDbId_3155 = -103155; 539 | this.MsgType_CheckChannelAddessExist_3156 = -103156; 540 | this.MsgType_CommitmentTx_ItemsByChanId_3200 = -103200; 541 | this.MsgType_CommitmentTx_ItemById_3201 = -103201; 542 | this.MsgType_CommitmentTx_Count_3202 = -103202; 543 | this.MsgType_CommitmentTx_LatestCommitmentTxByChanId_3203 = -103203; 544 | this.MsgType_CommitmentTx_LatestRDByChanId_3204 = -103204; 545 | this.MsgType_CommitmentTx_LatestBRByChanId_3205 = -103205; 546 | this.MsgType_CommitmentTx_SendSomeCommitmentById_3206 = -103206; 547 | this.MsgType_CommitmentTx_AllRDByChanId_3207 = -103207; 548 | this.MsgType_CommitmentTx_AllBRByChanId_3208 = -103208; 549 | this.MsgType_SendCloseChannelRequest_38 = -100038; 550 | this.MsgType_RecvCloseChannelRequest_38 = -110038; 551 | this.MsgType_SendCloseChannelSign_39 = -100039; 552 | this.MsgType_RecvCloseChannelSign_39 = -110039; 553 | this.MsgType_HTLC_FindPath_401 = -100401; 554 | this.MsgType_HTLC_Invoice_402 = -100402; 555 | this.MsgType_HTLC_SendAddHTLC_40 = -100040; 556 | this.MsgType_HTLC_RecvAddHTLC_40 = -110040; 557 | this.MsgType_HTLC_SendAddHTLCSigned_41 = -100041; 558 | this.MsgType_HTLC_RecvAddHTLCSigned_41 = -110041; 559 | this.MsgType_HTLC_BobSignC3bSubTx_42 = -110042; 560 | this.MsgType_HTLC_FinishTransferH_43 = -110043; 561 | this.MsgType_HTLC_SendVerifyR_45 = -100045; 562 | this.MsgType_HTLC_RecvVerifyR_45 = -110045; 563 | this.MsgType_HTLC_SendSignVerifyR_46 = -100046; 564 | this.MsgType_HTLC_RecvSignVerifyR_46 = -110046; 565 | this.MsgType_HTLC_SendRequestCloseCurrTx_49 = -100049; 566 | this.MsgType_HTLC_RecvRequestCloseCurrTx_49 = -110049; 567 | this.MsgType_HTLC_SendCloseSigned_50 = -100050; 568 | this.MsgType_HTLC_RecvCloseSigned_50 = -110050; 569 | this.MsgType_HTLC_Close_ClientSign_Bob_C4bSub_51 = -110051; 570 | this.MsgType_HTLC_ClientSign_Alice_C3a_100 = -100100; 571 | this.MsgType_HTLC_ClientSign_Bob_C3b_101 = -100101; 572 | this.MsgType_HTLC_ClientSign_Alice_C3b_102 = -100102; 573 | this.MsgType_HTLC_ClientSign_Alice_C3bSub_103 = -100103; 574 | this.MsgType_HTLC_ClientSign_Bob_C3bSub_104 = -100104; 575 | this.MsgType_HTLC_ClientSign_Alice_He_105 = -100105; 576 | this.MsgType_HTLC_ClientSign_Bob_HeSub_106 = -100106; 577 | this.MsgType_HTLC_ClientSign_Alice_HeSub_107 = -100107; 578 | this.MsgType_HTLC_Close_ClientSign_Alice_C4a_110 = -100110; 579 | this.MsgType_HTLC_Close_ClientSign_Bob_C4b_111 = -100111; 580 | this.MsgType_HTLC_Close_ClientSign_Alice_C4b_112 = -100112; 581 | this.MsgType_HTLC_Close_ClientSign_Alice_C4bSub_113 = -100113; 582 | this.MsgType_HTLC_Close_ClientSign_Bob_C4bSubResult_114 = -100114; 583 | this.MsgType_Atomic_SendSwap_80 = -100080; 584 | this.MsgType_Atomic_RecvSwap_80 = -110080; 585 | this.MsgType_Atomic_SendSwapAccept_81 = -100081; 586 | this.MsgType_Atomic_RecvSwapAccept_81 = -110081; 587 | } 588 | } 589 | exports.MessageType = MessageType; 590 | //# sourceMappingURL=pojo.js.map -------------------------------------------------------------------------------- /lib/pojo.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"pojo.js","sourceRoot":"","sources":["../src/pojo.ts"],"names":[],"mappings":";;;AAAA,MAAa,OAAO;IAApB;QACC,SAAI,GAAW,CAAC,CAAC;QACjB,SAAI,GAA6B,EAAE,CAAC;QACpC,2BAAsB,GAAW,EAAE,CAAC;QACpC,2BAAsB,GAAW,EAAE,CAAC;IACrC,CAAC;CAAA;AALD,0BAKC;AAED,MAAa,cAAc;IAA3B;QACC,iBAAY,GAAW,EAAE,CAAC;QAC1B,eAAU,GAAW,EAAE,CAAC;QACxB,WAAM,GAAW,GAAG,CAAC;QACrB,cAAS,GAAW,GAAG,CAAC;IACzB,CAAC;CAAA;AALD,wCAKC;AAED,MAAa,iBAAiB;IAA9B;QACC,yBAAoB,GAAW,EAAE,CAAC;QAClC,mBAAc,GAAW,EAAE,CAAC;IAC7B,CAAC;CAAA;AAHD,8CAGC;AAED,MAAa,gBAAgB;IAA7B;QACC,yBAAoB,GAAW,EAAE,CAAC;QAClC,iBAAY,GAAW,EAAE,CAAC;QAC1B,wCAAmC,GAAW,EAAE,CAAC;QACjD,aAAQ,GAAY,KAAK,CAAC;IAC3B,CAAC;CAAA;AALD,4CAKC;AAED,MAAa,oBAAoB;IAAjC;QACC,iBAAY,GAAW,EAAE,CAAC;QAC1B,eAAU,GAAW,EAAE,CAAC;QACxB,gBAAW,GAAW,CAAC,CAAC;QACxB,WA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;AAnID,kCAmIC"} -------------------------------------------------------------------------------- /lib/result.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.err = exports.ok = exports.Err = exports.Ok = void 0; 4 | class Ok { 5 | constructor(value) { 6 | this.value = value; 7 | } 8 | isOk() { 9 | return true; 10 | } 11 | isErr() { 12 | return false; 13 | } 14 | } 15 | exports.Ok = Ok; 16 | class Err { 17 | constructor(error) { 18 | this.error = error; 19 | if (error) 20 | console.info(error); 21 | } 22 | isOk() { 23 | return false; 24 | } 25 | isErr() { 26 | return true; 27 | } 28 | } 29 | exports.Err = Err; 30 | exports.ok = (value) => new Ok(value); 31 | exports.err = (error) => { 32 | if (typeof error === 'string') { 33 | return new Err(new Error(error)); 34 | } 35 | return new Err(error); 36 | }; 37 | //# sourceMappingURL=result.js.map -------------------------------------------------------------------------------- /lib/result.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"result.js","sourceRoot":"","sources":["../src/result.ts"],"names":[],"mappings":";;;AAEA,MAAa,EAAE;IACd,YAAmC,KAAQ;QAAR,UAAK,GAAL,KAAK,CAAG;IAAG,CAAC;IAExC,IAAI;QACV,OAAO,IAAI,CAAC;IACb,CAAC;IAEM,KAAK;QACX,OAAO,KAAK,CAAC;IACd,CAAC;CACD;AAVD,gBAUC;AAED,MAAa,GAAG;IACf,YAAmC,KAAY;QAAZ,UAAK,GAAL,KAAK,CAAO;QAC9C,IAAI,KAAK;YAAE,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAChC,CAAC;IAEM,IAAI;QACV,OAAO,KAAK,CAAC;IACd,CAAC;IAEM,KAAK;QACX,OAAO,IAAI,CAAC;IACb,CAAC;CACD;AAZD,kBAYC;AAKY,QAAA,EAAE,GAAG,CAAI,KAAQ,EAAS,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC;AAK3C,QAAA,GAAG,GAAG,CAAI,KAAqB,EAAU,EAAE;IACvD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC9B,OAAO,IAAI,GAAG,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;KACjC;IAED,OAAO,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC,CAAC"} -------------------------------------------------------------------------------- /lib/shapes.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.channelSigningData = exports.defaultDataShape = exports.addressContent = void 0; 4 | exports.addressContent = { 5 | index: 0, 6 | path: '', 7 | address: '', 8 | scriptHash: '', 9 | publicKey: '', 10 | }; 11 | exports.defaultDataShape = { 12 | nextAddressIndex: { 13 | index: 0, 14 | path: '', 15 | address: '', 16 | scriptHash: '', 17 | publicKey: '', 18 | }, 19 | signingData: {}, 20 | checkpoints: {}, 21 | fundingAddresses: {}, 22 | }; 23 | exports.channelSigningData = { 24 | fundingAddress: { ...exports.addressContent }, 25 | addressIndex: { ...exports.addressContent }, 26 | last_temp_address: { ...exports.addressContent }, 27 | rsmc_temp_address: { ...exports.addressContent }, 28 | htlc_temp_address: { ...exports.addressContent }, 29 | htlc_temp_address_for_he1b: { ...exports.addressContent }, 30 | kTbSignedHex: '', 31 | funding_txid: '', 32 | kTempPrivKey: '', 33 | kTbSignedHexCR110351: '', 34 | kTbSignedHexRR110351: '', 35 | kTbTempData: '', 36 | }; 37 | //# sourceMappingURL=shapes.js.map -------------------------------------------------------------------------------- /lib/shapes.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"shapes.js","sourceRoot":"","sources":["../src/shapes.ts"],"names":[],"mappings":";;;AAEa,QAAA,cAAc,GAAG;IAC7B,KAAK,EAAE,CAAC;IACR,IAAI,EAAE,EAAE;IACR,OAAO,EAAE,EAAE;IACX,UAAU,EAAE,EAAE;IACd,SAAS,EAAE,EAAE;CACb,CAAC;AAEW,QAAA,gBAAgB,GAAU;IACtC,gBAAgB,EAAE;QACjB,KAAK,EAAE,CAAC;QACR,IAAI,EAAE,EAAE;QACR,OAAO,EAAE,EAAE;QACX,UAAU,EAAE,EAAE;QACd,SAAS,EAAE,EAAE;KACb;IACD,WAAW,EAAE,EAAE;IACf,WAAW,EAAE,EAAE;IACf,gBAAgB,EAAE,EAAE;CACpB,CAAC;AAEW,QAAA,kBAAkB,GAAwB;IACtD,cAAc,EAAE,EAAE,GAAG,sBAAc,EAAE;IACrC,YAAY,EAAE,EAAE,GAAG,sBAAc,EAAE;IACnC,iBAAiB,EAAE,EAAE,GAAG,sBAAc,EAAE;IACxC,iBAAiB,EAAE,EAAE,GAAG,sBAAc,EAAE;IACxC,iBAAiB,EAAE,EAAE,GAAG,sBAAc,EAAE;IACxC,0BAA0B,EAAE,EAAE,GAAG,sBAAc,EAAE;IACjD,YAAY,EAAE,EAAE;IAChB,YAAY,EAAE,EAAE;IAChB,YAAY,EAAE,EAAE;IAChB,oBAAoB,EAAE,EAAE;IACxB,oBAAoB,EAAE,EAAE;IACxB,WAAW,EAAE,EAAE;CACf,CAAC"} -------------------------------------------------------------------------------- /lib/types.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | //# sourceMappingURL=types.js.map -------------------------------------------------------------------------------- /lib/types.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""} -------------------------------------------------------------------------------- /lib/types/index.d.ts: -------------------------------------------------------------------------------- 1 | import ObdApi from './obdapi'; 2 | export { ObdApi }; 3 | -------------------------------------------------------------------------------- /lib/types/obdapi.d.ts: -------------------------------------------------------------------------------- 1 | import { MessageType, Message, P2PPeer, BtcFundingInfo, FundingBtcCreated, FundingBtcSigned, OmniFundingAssetInfo, OmniSendAssetInfo, OpenChannelInfo, AcceptChannelInfo, AssetFundingCreatedInfo, AssetFundingSignedInfo, SignedInfo100100, SignedInfo100101, SignedInfo100102, SignedInfo100103, SignedInfo100104, SignedInfo100105, SignedInfo100106, SignedInfo100110, SignedInfo100111, SignedInfo100112, SignedInfo100113, SignedInfo100114, SignedInfo100360, SignedInfo100361, SignedInfo100362, SignedInfo100363, SignedInfo100364, SignedInfo101035, SignedInfo101134, CommitmentTx, CommitmentTxSigned, InvoiceInfo, HTLCFindPathInfo, addHTLCInfo, HtlcSignedInfo, ForwardRInfo, SignRInfo, CloseHtlcTxInfo, CloseHtlcTxInfoSigned, IssueFixedAmountInfo, IssueManagedAmoutInfo, OmniSendGrant, OmniSendRevoke, CloseChannelSign, AtomicSwapAccepted, AtomicSwapRequest } from './pojo'; 2 | import { Result } from './result'; 3 | import { IAcceptChannel, IGetMyChannels, ILogin, IFundingBitcoin, IBitcoinFundingCreated, ISendSignedHex100341, TOnBitcoinFundingCreated, TOnChannelOpenAttempt, IBitcoinFundingSigned, TOnAssetFundingCreated, IAssetFundingSigned, TSendSignedHex101035, TOnCommitmentTransactionCreated, ICommitmentTransactionAcceptedResponse, ISendSignedHex100361Response, TOnAcceptChannel, TOn110353, ICommitmentTransactionCreated, TOn110352, ISendSignedHex100364Response, ISendSignedHex100362Response, ISendSignedHex100363Response, IGetProperty, ICloseChannel, ISaveData, TAvailableNetworks, ISendSignedHex101035, TOmniboltCheckpoints, ISendSignedHex100363, ICommitmentTransactionAcceptedCheckpointData, IListeners, IAddressContent, IOpenChannel, IOmniboltResponse, IFundAssetResponse, IConnectResponse, ISendSignedHex101034, ISendSignedHex101134, ICreateChannel, IFundTempChannel, IGetTransactionResponse, IGetAllBalancesForAddressResponse } from './types'; 4 | export default class ObdApi { 5 | constructor({ websocket, verbose, }?: { 6 | websocket?: WebSocket; 7 | verbose?: boolean; 8 | }); 9 | isConnectedToOBD: boolean; 10 | isLoggedIn: boolean; 11 | messageType: MessageType; 12 | websocket: WebSocket | any; 13 | ws: WebSocket | any; 14 | defaultUrl: string; 15 | loginPhrase?: string; 16 | mnemonic: string; 17 | data: ISaveData; 18 | pendingPeerResponses: {}; 19 | saveData: (data: ISaveData) => any; 20 | listeners?: IListeners | {}; 21 | selectedNetwork: TAvailableNetworks; 22 | globalCallback: Function | undefined; 23 | callbackMap: Map; 24 | onOpen: (data: string) => any; 25 | onError: (data: any) => any; 26 | onClose: (code: number, reason: string) => any; 27 | onMessage: Function | undefined; 28 | onChannelCloseAttempt: ((data: any) => any) | undefined; 29 | onChannelClose: Function | undefined; 30 | loginData: ILogin; 31 | verbose: boolean; 32 | connect({ url, data, saveData, loginPhrase, mnemonic, listeners, selectedNetwork, onMessage, onChannelCloseAttempt, onChannelClose, onOpen, onError, onClose, onAddHTLC, onForwardR, onSignR, onCloseHTLC, }: { 33 | url: string | undefined; 34 | data: ISaveData | undefined; 35 | saveData: (data: ISaveData) => void; 36 | loginPhrase: string; 37 | mnemonic: string; 38 | listeners?: IListeners; 39 | selectedNetwork: TAvailableNetworks; 40 | onMessage?: (data: any) => any; 41 | onChannelCloseAttempt?: (data: any) => any; 42 | onAcceptChannel?: (data: TOnAcceptChannel) => any; 43 | onChannelClose?: (data: any) => any; 44 | onOpen?: (data: string) => any; 45 | onError?: (e: string | object) => any; 46 | onClose?: (code: number, reason: string) => any; 47 | onAddHTLC?: (data: any) => any; 48 | onForwardR?: (data: any) => any; 49 | onSignR?: (data: any) => any; 50 | onCloseHTLC?: (data: any) => any; 51 | }): Promise>; 52 | registerEvent(msgType: number, callback: Function): void; 53 | removeEvent(msgType: number): void; 54 | sendJsonData(msg: string, type: number, callback: Function): void; 55 | connectToServer(url: string, callback: Function, globalCallback: Function): import("./result").Err | undefined; 56 | sendData(msg: Message, callback: Function): Result; 57 | getDataFromServer(jsonData: any): any; 58 | logIn(mnemonic?: string): Promise>; 59 | userPeerId: string; 60 | onLogIn(resultData: any): void; 61 | disconnect(): void; 62 | logout(): Promise; 63 | onLogout(jsonData: any): void; 64 | connectPeer(info: P2PPeer): Promise>; 65 | fundingBitcoin(info: BtcFundingInfo): Promise>; 66 | onFundingBitcoin(jsonData: any): void; 67 | bitcoinFundingCreated(recipient_node_peer_id: string, recipient_user_peer_id: string, info: FundingBtcCreated): Promise>; 68 | sendSignedHex100341(recipient_node_peer_id: string, recipient_user_peer_id: string, signed_hex: string): Promise>; 69 | bitcoinFundingSigned(recipient_node_peer_id: string, recipient_user_peer_id: string, info: FundingBtcSigned): Promise>; 70 | listProperties(): Promise>; 71 | onListProperties(jsonData: any): void; 72 | fundingAsset(info: OmniFundingAssetInfo): Promise>; 73 | onFundingAsset(jsonData: any): void; 74 | sendAsset(info: OmniSendAssetInfo): Promise>; 75 | onSendAsset(jsonData: any): void; 76 | genAddressFromMnemonic(): Promise>; 77 | onGenAddressFromMnemonic(jsonData: any): void; 78 | getAddressInfo(index: number): Promise>; 79 | onGetAddressInfo(jsonData: any): void; 80 | createChannel({ remote_node_address, recipient_user_peer_id, info: { fundingAddressIndex, amount_to_fund, miner_fee, asset_id, asset_amount, }, }: ICreateChannel): Promise>; 81 | waitForPeer(methodType: number, timeout?: number): Promise>; 82 | fundLoop: ({ info, temporary_channel_id, recipient_node_peer_id, recipient_user_peer_id, privkey, times_to_fund, }: { 83 | info: BtcFundingInfo; 84 | temporary_channel_id: string; 85 | recipient_node_peer_id: string; 86 | recipient_user_peer_id: string; 87 | privkey: string; 88 | times_to_fund: number; 89 | }) => Promise>; 90 | fundTempChannel({ recipient_node_peer_id, recipient_user_peer_id, temporary_channel_id, info: { fundingAddressIndex, amount_to_fund, miner_fee, asset_id, asset_amount, }, }: IFundTempChannel): Promise>; 91 | getFundingAddress({ index, }: { 92 | index?: number; 93 | }): Promise>; 94 | saveSigningData(channel_id: any, data: any): void; 95 | openChannel(recipient_node_peer_id: string, recipient_user_peer_id: string, info: OpenChannelInfo): Promise>; 96 | onOpenChannel(jsonData: IOmniboltResponse): void; 97 | acceptChannel(recipient_node_peer_id: string, recipient_user_peer_id: string, info: AcceptChannelInfo): Promise>; 98 | onChannelOpenAttempt(data: TOnChannelOpenAttempt): Promise; 99 | onAcceptChannel(data: TOnAcceptChannel): Promise; 100 | onBitcoinFundingCreated(data: TOnBitcoinFundingCreated): Promise>; 101 | listening110340(e: any): Promise>; 107 | onAssetFundingCreated(data: TOnAssetFundingCreated): Promise>; 108 | listening110035(e: any): Promise>; 109 | onCommitmentTransactionCreated(data: TOnCommitmentTransactionCreated): Promise>; 110 | handleCommitmentTransactionAccepted({ info, userID, nodeID, }: ICommitmentTransactionAcceptedCheckpointData): Promise>; 111 | on110352(data: TOn110352): Promise>; 112 | handleSendSignedHex100363({ data, privkey, channelId, nodeID, userID, }: ISendSignedHex100363): Promise>; 113 | on110353(data: TOn110353): Promise>; 114 | checkChannelAddessExist(recipient_node_peer_id: string, recipient_user_peer_id: string, info: AcceptChannelInfo): Promise>; 115 | onCheckChannelAddessExist(jsonData: any): void; 116 | assetFundingCreated(recipient_node_peer_id: string, recipient_user_peer_id: string, info: AssetFundingCreatedInfo): Promise>; 117 | sendSignedHex101034(recipient_node_peer_id: string, recipient_user_peer_id: string, signed_hex: string): Promise>; 118 | sendSignedHex101134(info: SignedInfo101134): Promise>; 119 | assetFundingSigned(recipient_node_peer_id: string, recipient_user_peer_id: string, info: AssetFundingSignedInfo): Promise>; 120 | onAssetFundingSigned(jsonData: any): void; 121 | sendSignedHex101035({ data, channelId, recipient_node_peer_id, recipient_user_peer_id, }: { 122 | data: IAssetFundingSigned; 123 | channelId: string; 124 | recipient_node_peer_id: string; 125 | recipient_user_peer_id: string; 126 | }): Promise>; 127 | handleSendSignedHex101035(recipient_node_peer_id: string, recipient_user_peer_id: string, info: SignedInfo101035): Promise>; 128 | commitmentTransactionCreated(recipient_node_peer_id: string, recipient_user_peer_id: string, info: CommitmentTx): Promise>; 129 | sendSignedHex100360(recipient_node_peer_id: string, recipient_user_peer_id: string, info: SignedInfo100360): Promise>; 130 | commitmentTransactionAccepted(recipient_node_peer_id: string, recipient_user_peer_id: string, info: CommitmentTxSigned): Promise>; 131 | onCommitmentTransactionAccepted(jsonData: any): void; 132 | sendSignedHex100361(recipient_node_peer_id: string, recipient_user_peer_id: string, info: SignedInfo100361): Promise>; 133 | sendSignedHex100362(recipient_node_peer_id: string, recipient_user_peer_id: string, info: SignedInfo100362): Promise>; 134 | sendSignedHex100363(recipient_node_peer_id: string, recipient_user_peer_id: string, info: SignedInfo100363): Promise>; 135 | sendSignedHex100364(info: SignedInfo100364): Promise>; 136 | addInvoice(info: InvoiceInfo): Promise>; 137 | onAddInvoice(jsonData: any): void; 138 | HTLCFindPath(info: HTLCFindPathInfo): Promise>; 139 | onHTLCFindPath(jsonData: any): void; 140 | addHTLC(recipient_node_peer_id: string, recipient_user_peer_id: string, info: addHTLCInfo): Promise>; 141 | onAddHTLC(jsonData: any): void; 142 | sendSignedHex100100(recipient_node_peer_id: string, recipient_user_peer_id: string, info: SignedInfo100100): Promise>; 143 | sendSignedHex100101(recipient_node_peer_id: string, recipient_user_peer_id: string, info: SignedInfo100101): Promise>; 144 | sendSignedHex100102(info: SignedInfo100102): Promise>; 145 | sendSignedHex100103(recipient_node_peer_id: string, recipient_user_peer_id: string, info: SignedInfo100103): Promise>; 146 | sendSignedHex100104(info: SignedInfo100104): Promise>; 147 | sendSignedHex100105(recipient_node_peer_id: string, recipient_user_peer_id: string, info: SignedInfo100105): Promise>; 148 | sendSignedHex100106(recipient_node_peer_id: string, recipient_user_peer_id: string, info: SignedInfo100106): Promise>; 149 | sendSignedHex100110(recipient_node_peer_id: string, recipient_user_peer_id: string, info: SignedInfo100110): Promise>; 150 | sendSignedHex100111(recipient_node_peer_id: string, recipient_user_peer_id: string, info: SignedInfo100111): Promise>; 151 | sendSignedHex100112(info: SignedInfo100112): Promise>; 152 | sendSignedHex100113(recipient_node_peer_id: string, recipient_user_peer_id: string, info: SignedInfo100113): Promise>; 153 | sendSignedHex100114(info: SignedInfo100114): Promise>; 154 | htlcSigned(recipient_node_peer_id: string, recipient_user_peer_id: string, info: HtlcSignedInfo): Promise>; 155 | onHtlcSigned(jsonData: any): void; 156 | forwardR(recipient_node_peer_id: string, recipient_user_peer_id: string, info: ForwardRInfo): Promise>; 157 | onForwardR(jsonData: any): void; 158 | signR(recipient_node_peer_id: string, recipient_user_peer_id: string, info: SignRInfo): Promise>; 159 | onSignR(jsonData: any): void; 160 | closeHTLC(recipient_node_peer_id: string, recipient_user_peer_id: string, info: CloseHtlcTxInfo): Promise>; 161 | onCloseHTLC(jsonData: any): void; 162 | closeHTLCSigned(recipient_node_peer_id: string, recipient_user_peer_id: string, info: CloseHtlcTxInfoSigned): Promise>; 163 | onCloseHTLCSigned(jsonData: any): void; 164 | getTransaction(txid: string): Promise>; 165 | onGetTransaction(jsonData: any): void; 166 | issueFixedAmount(info: IssueFixedAmountInfo): Promise>; 167 | onIssueFixedAmount(jsonData: any): void; 168 | issueManagedAmout(info: IssueManagedAmoutInfo): Promise>; 169 | onIssueManagedAmout(jsonData: any): void; 170 | sendGrant(info: OmniSendGrant): Promise>; 171 | onSendGrant(jsonData: any): void; 172 | sendRevoke(info: OmniSendRevoke): Promise>; 173 | onSendRevoke(jsonData: any): void; 174 | getAllBalancesForAddress(address: string): Promise>; 175 | onGetAllBalancesForAddress(jsonData: any): void; 176 | getProperty(propertyId: string): Promise>; 177 | onGetProperty(jsonData: any): void; 178 | getBtcBalanceByAddress(address: string): Promise>; 179 | onGetBtcBalanceByAddress(jsonData: any): void; 180 | importPrivKey(privkey: string): Promise>; 181 | onImportPrivKey(jsonData: any): void; 182 | getAddHTLCRandHInfoList(): Promise>; 183 | onGetAddHTLCRandHInfoList(jsonData: any): void; 184 | getHtlcSignedRandHInfoList(): Promise>; 185 | onGetHtlcSignedRandHInfoList(jsonData: any): void; 186 | getRFromCommitmentTx(channel_id: string): Promise>; 187 | onGetRFromCommitmentTx(jsonData: any): void; 188 | getPathInfoByH(h: string): Promise>; 189 | onGetPathInfoByH(jsonData: any): void; 190 | getRByHOfReceiver(h: string): Promise>; 191 | onGetRByHOfReceiver(jsonData: any): void; 192 | getLatestCommitmentTransaction(channel_id: string): Promise>; 193 | onGetLatestCommitmentTransaction(jsonData: any): void; 194 | getItemsByChannelId(channel_id: string): Promise>; 195 | onGetItemsByChannelId(jsonData: any): void; 196 | getMyChannels(page_size?: Number, page_index?: Number): Promise>; 197 | onGetMyChannels(jsonData: any): void; 198 | getAmountOfRechargeBTC(): Promise>; 199 | onGetAmountOfRechargeBTC(jsonData: any): void; 200 | getChannelDetailFromChannelID(channel_id: string): Promise>; 201 | onGetChannelDetailFromChannelID(jsonData: any): void; 202 | getChannelDetailFromDatabaseID(id: number): Promise>; 203 | onGetChannelDetailFromDatabaseID(jsonData: any): void; 204 | getAllBreachRemedyTransactions(channel_id: string): Promise>; 205 | onGetAllBreachRemedyTransactions(jsonData: any): void; 206 | getAllCommitmentTx(channel_id: string): Promise>; 207 | onGetAllCommitmentTx(jsonData: any): void; 208 | getLatestRevockableDeliveryTransaction(channel_id: string): Promise>; 209 | onGetLatestRevockableDeliveryTransaction(jsonData: any): void; 210 | getLatestBreachRemedyTransaction(channel_id: string): Promise>; 211 | onGetLatestBreachRemedyTransaction(jsonData: any): void; 212 | sendSomeCommitmentById(id: number): Promise>; 213 | onSendSomeCommitmentById(jsonData: any): void; 214 | getAllRevockableDeliveryTransactions(channel_id: string): Promise>; 215 | onGetAllRevockableDeliveryTransactions(jsonData: any): void; 216 | closeChannel(recipient_node_peer_id: string, recipient_user_peer_id: string, channel_id: string): Promise>; 217 | onCloseChannel(jsonData: any): void; 218 | closeChannelSigned(recipient_node_peer_id: string, recipient_user_peer_id: string, info: CloseChannelSign): Promise>; 219 | onCloseChannelSigned(jsonData: any): void; 220 | atomicSwap(recipient_node_peer_id: string, recipient_user_peer_id: string, info: AtomicSwapRequest): Promise>; 221 | atomicSwapAccepted(recipient_node_peer_id: string, recipient_user_peer_id: string, info: AtomicSwapAccepted): Promise>; 222 | sendOmniAsset: ({ channelId, amount, recipient_node_peer_id, recipient_user_peer_id, }: { 223 | channelId: string; 224 | amount: number; 225 | recipient_node_peer_id: string; 226 | recipient_user_peer_id: string; 227 | }) => Promise>; 228 | isNotString(str: any): boolean; 229 | listener(id: string, method: 'start' | 'failure' | 'success', data?: any): Result; 230 | updateOmniboltCheckpoint({ channelId, checkpoint, data, }: { 231 | channelId: string; 232 | checkpoint: TOmniboltCheckpoints; 233 | data: any; 234 | }, save?: boolean): void; 235 | clearOmniboltCheckpoint({ channelId }: { 236 | channelId: string; 237 | }): void; 238 | resumeFromCheckpoints(): Promise; 239 | logMsg: (p1?: any, p2?: any) => void; 240 | getInfo(): ILogin; 241 | getNewSigningAddress(): Promise>; 242 | getFundingAddressByIndex({ index, }: { 243 | index: number; 244 | }): Promise>; 245 | getConnectUri(): Result; 246 | } 247 | -------------------------------------------------------------------------------- /lib/types/pojo.d.ts: -------------------------------------------------------------------------------- 1 | export declare class Message { 2 | type: number; 3 | data: object | string | number; 4 | recipient_user_peer_id: string; 5 | recipient_node_peer_id: string; 6 | } 7 | export declare class BtcFundingInfo { 8 | from_address: string; 9 | to_address: string; 10 | amount: number; 11 | miner_fee: number; 12 | } 13 | export declare class FundingBtcCreated { 14 | temporary_channel_id: string; 15 | funding_tx_hex: string; 16 | } 17 | export declare class FundingBtcSigned { 18 | temporary_channel_id: string; 19 | funding_txid: string; 20 | signed_miner_redeem_transaction_hex: string; 21 | approval: boolean; 22 | } 23 | export declare class OmniFundingAssetInfo { 24 | from_address: string; 25 | to_address: string; 26 | property_id: number; 27 | amount: number; 28 | miner_fee: number; 29 | } 30 | export declare class OmniSendAssetInfo { 31 | from_address: string; 32 | to_address: string; 33 | property_id: number; 34 | amount: number; 35 | } 36 | export declare class OpenChannelInfo { 37 | funding_pubkey: string; 38 | is_private: boolean; 39 | } 40 | export declare class AcceptChannelInfo { 41 | temporary_channel_id: string; 42 | funding_pubkey: string; 43 | approval: boolean; 44 | } 45 | export declare class AssetFundingCreatedInfo { 46 | temporary_channel_id: string; 47 | funding_tx_hex: string; 48 | temp_address_pub_key: string; 49 | temp_address_index: number; 50 | } 51 | export declare class AssetFundingSignedInfo { 52 | temporary_channel_id: string; 53 | signed_alice_rsmc_hex: string; 54 | } 55 | export declare class SignedInfo101035 { 56 | temporary_channel_id: string; 57 | rd_signed_hex: string; 58 | br_signed_hex: string; 59 | br_id: number; 60 | } 61 | export declare class SignedInfo101134 { 62 | channel_id: string; 63 | rd_signed_hex: string; 64 | } 65 | export declare class SignedInfo100360 { 66 | channel_id: string; 67 | rsmc_signed_hex: string; 68 | counterparty_signed_hex: string; 69 | } 70 | export declare class SignedInfo100361 { 71 | channel_id: string; 72 | c2b_rsmc_signed_hex: string; 73 | c2b_counterparty_signed_hex: string; 74 | c2a_rd_signed_hex: string; 75 | c2a_br_signed_hex: string; 76 | c2a_br_id: number; 77 | } 78 | export declare class SignedInfo100362 { 79 | channel_id: string; 80 | c2b_rsmc_signed_hex: string; 81 | c2b_counterparty_signed_hex: string; 82 | c2a_rd_signed_hex: string; 83 | } 84 | export declare class SignedInfo100363 { 85 | channel_id: string; 86 | c2b_rd_signed_hex: string; 87 | c2b_br_signed_hex: string; 88 | c2b_br_id: number; 89 | } 90 | export declare class SignedInfo100364 { 91 | channel_id: string; 92 | c2b_rd_signed_hex: string; 93 | } 94 | export declare class SignedInfo100100 { 95 | channel_id: string; 96 | c3a_counterparty_partial_signed_hex: string; 97 | c3a_htlc_partial_signed_hex: string; 98 | c3a_rsmc_partial_signed_hex: string; 99 | } 100 | export declare class SignedInfo100101 { 101 | channel_id: string; 102 | c3a_rsmc_rd_partial_signed_hex: string; 103 | c3a_rsmc_br_partial_signed_hex: string; 104 | c3a_htlc_ht_partial_signed_hex: string; 105 | c3a_htlc_hlock_partial_signed_hex: string; 106 | c3a_htlc_br_partial_signed_hex: string; 107 | c3b_rsmc_partial_signed_hex: string; 108 | c3b_counterparty_partial_signed_hex: string; 109 | c3b_htlc_partial_signed_hex: string; 110 | } 111 | export declare class SignedInfo100102 { 112 | channel_id: string; 113 | c3a_rsmc_rd_complete_signed_hex: string; 114 | c3a_htlc_ht_complete_signed_hex: string; 115 | c3a_htlc_hlock_complete_signed_hex: string; 116 | c3b_rsmc_complete_signed_hex: string; 117 | c3b_counterparty_complete_signed_hex: string; 118 | c3b_htlc_complete_signed_hex: string; 119 | } 120 | export declare class SignedInfo100103 { 121 | channel_id: string; 122 | c3a_htlc_htrd_partial_signed_hex: string; 123 | c3b_rsmc_rd_partial_signed_hex: string; 124 | c3b_rsmc_br_partial_signed_hex: string; 125 | c3b_htlc_htd_partial_signed_hex: string; 126 | c3b_htlc_hlock_partial_signed_hex: string; 127 | c3b_htlc_br_partial_signed_hex: string; 128 | } 129 | export declare class SignedInfo100104 { 130 | channel_id: string; 131 | curr_htlc_temp_address_for_he_pub_key: string; 132 | curr_htlc_temp_address_for_he_index: number; 133 | c3a_htlc_htrd_complete_signed_hex: string; 134 | c3a_htlc_htbr_partial_signed_hex: string; 135 | c3a_htlc_hed_partial_signed_hex: string; 136 | c3b_rsmc_rd_complete_signed_hex: string; 137 | c3b_htlc_htd_complete_signed_hex: string; 138 | c3b_htlc_hlock_complete_signed_hex: string; 139 | } 140 | export declare class SignedInfo100105 { 141 | channel_id: string; 142 | c3b_htlc_hlock_he_partial_signed_hex: string; 143 | } 144 | export declare class SignedInfo100106 { 145 | channel_id: string; 146 | c3b_htlc_herd_partial_signed_hex: string; 147 | } 148 | export declare class SignedInfo100110 { 149 | channel_id: string; 150 | counterparty_partial_signed_hex: string; 151 | rsmc_partial_signed_hex: string; 152 | } 153 | export declare class SignedInfo100111 { 154 | channel_id: string; 155 | c4a_rd_signed_hex: string; 156 | c4a_br_signed_hex: string; 157 | c4a_br_id: string; 158 | c4b_rsmc_signed_hex: string; 159 | c4b_counterparty_signed_hex: string; 160 | } 161 | export declare class SignedInfo100112 { 162 | channel_id: string; 163 | c4a_rd_complete_signed_hex: string; 164 | c4b_rsmc_complete_signed_hex: string; 165 | c4b_counterparty_complete_signed_hex: string; 166 | } 167 | export declare class SignedInfo100113 { 168 | channel_id: string; 169 | c4b_rd_partial_signed_hex: string; 170 | c4b_br_partial_signed_hex: string; 171 | c4b_br_id: string; 172 | } 173 | export declare class SignedInfo100114 { 174 | channel_id: string; 175 | c4b_rd_complete_signed_hex: string; 176 | } 177 | export declare class CommitmentTx { 178 | channel_id: string; 179 | amount: number; 180 | curr_temp_address_pub_key: string; 181 | curr_temp_address_index: number; 182 | last_temp_address_private_key: string; 183 | } 184 | export declare class CommitmentTxSigned { 185 | channel_id: string; 186 | msg_hash: string; 187 | c2a_rsmc_signed_hex: string; 188 | c2a_counterparty_signed_hex: string; 189 | curr_temp_address_pub_key: string; 190 | curr_temp_address_index: number; 191 | last_temp_address_private_key: string; 192 | approval: boolean; 193 | } 194 | export declare class InvoiceInfo { 195 | property_id: number; 196 | amount: number; 197 | h: string; 198 | expiry_time: string; 199 | description: string; 200 | is_private: boolean; 201 | } 202 | export declare class HTLCFindPathInfo extends InvoiceInfo { 203 | invoice: string; 204 | recipient_node_peer_id: string; 205 | recipient_user_peer_id: string; 206 | is_inv_pay: boolean; 207 | } 208 | export declare class addHTLCInfo { 209 | recipient_user_peer_id: string; 210 | property_id: number; 211 | amount: number; 212 | memo: string; 213 | h: string; 214 | routing_packet: string; 215 | cltv_expiry: number; 216 | last_temp_address_private_key: string; 217 | curr_rsmc_temp_address_pub_key: string; 218 | curr_rsmc_temp_address_index: number; 219 | curr_htlc_temp_address_pub_key: string; 220 | curr_htlc_temp_address_index: number; 221 | curr_htlc_temp_address_for_ht1a_pub_key: string; 222 | curr_htlc_temp_address_for_ht1a_index: number; 223 | } 224 | export declare class HtlcSignedInfo { 225 | payer_commitment_tx_hash: string; 226 | curr_rsmc_temp_address_pub_key: string; 227 | curr_rsmc_temp_address_index: number; 228 | curr_htlc_temp_address_pub_key: string; 229 | curr_htlc_temp_address_index: number; 230 | last_temp_address_private_key: string; 231 | c3a_complete_signed_rsmc_hex: string; 232 | c3a_complete_signed_counterparty_hex: string; 233 | c3a_complete_signed_htlc_hex: string; 234 | } 235 | export declare class SignGetHInfo { 236 | request_hash: string; 237 | channel_address_private_key: string; 238 | last_temp_address_private_key: string; 239 | curr_rsmc_temp_address_pub_key: string; 240 | curr_rsmc_temp_address_private_key: string; 241 | curr_htlc_temp_address_pub_key: string; 242 | curr_htlc_temp_address_private_key: string; 243 | approval: boolean; 244 | } 245 | export declare class HtlcRequestOpen { 246 | request_hash: string; 247 | channel_address_private_key: string; 248 | last_temp_address_private_key: string; 249 | curr_rsmc_temp_address_pub_key: string; 250 | curr_rsmc_temp_address_private_key: string; 251 | curr_htlc_temp_address_pub_key: string; 252 | curr_htlc_temp_address_private_key: string; 253 | curr_htlc_temp_address_for_ht1a_pub_key: string; 254 | curr_htlc_temp_address_for_ht1a_private_key: string; 255 | } 256 | export declare class ForwardRInfo { 257 | channel_id: string; 258 | r: string; 259 | } 260 | export declare class SignRInfo { 261 | channel_id: string; 262 | c3b_htlc_herd_complete_signed_hex: string; 263 | c3b_htlc_hebr_partial_signed_hex: string; 264 | } 265 | export declare class CloseHtlcTxInfo { 266 | channel_id: string; 267 | last_rsmc_temp_address_private_key: string; 268 | last_htlc_temp_address_private_key: string; 269 | last_htlc_temp_address_for_htnx_private_key: string; 270 | curr_temp_address_pub_key: string; 271 | curr_temp_address_index: number; 272 | } 273 | export declare class CloseHtlcTxInfoSigned { 274 | msg_hash: string; 275 | last_rsmc_temp_address_private_key: string; 276 | last_htlc_temp_address_private_key: string; 277 | last_htlc_temp_address_for_htnx_private_key: string; 278 | curr_temp_address_pub_key: string; 279 | curr_temp_address_index: number; 280 | } 281 | export declare class IssueManagedAmoutInfo { 282 | from_address: string; 283 | name: string; 284 | ecosystem: number; 285 | divisible_type: number; 286 | data: string; 287 | } 288 | export declare class IssueFixedAmountInfo extends IssueManagedAmoutInfo { 289 | amount: number; 290 | } 291 | export declare class OmniSendGrant { 292 | from_address: string; 293 | property_id: number; 294 | amount: number; 295 | memo: string; 296 | } 297 | export declare class OmniSendRevoke extends OmniSendGrant { 298 | } 299 | export declare class CloseChannelSign { 300 | channel_id: string; 301 | request_close_channel_hash: string; 302 | approval: boolean; 303 | } 304 | export declare class AtomicSwapRequest { 305 | channel_id_from: string; 306 | channel_id_to: string; 307 | recipient_user_peer_id: string; 308 | property_sent: number; 309 | amount: number; 310 | exchange_rate: number; 311 | property_received: number; 312 | transaction_id: string; 313 | time_locker: number; 314 | } 315 | export declare class AtomicSwapAccepted extends AtomicSwapRequest { 316 | target_transaction_id: string; 317 | } 318 | export declare class P2PPeer { 319 | remote_node_address: string; 320 | } 321 | export declare class MessageType { 322 | MsgType_Error_0: number; 323 | MsgType_UserLogin_2001: number; 324 | MsgType_UserLogout_2002: number; 325 | MsgType_p2p_ConnectPeer_2003: number; 326 | MsgType_GetMnemonic_2004: number; 327 | MsgType_GetMiniBtcFundAmount_2006: number; 328 | MsgType_Core_GetNewAddress_2101: number; 329 | MsgType_Core_GetMiningInfo_2102: number; 330 | MsgType_Core_GetNetworkInfo_2103: number; 331 | MsgType_Core_SignMessageWithPrivKey_2104: number; 332 | MsgType_Core_VerifyMessage_2105: number; 333 | MsgType_Core_DumpPrivKey_2106: number; 334 | MsgType_Core_ListUnspent_2107: number; 335 | MsgType_Core_BalanceByAddress_2108: number; 336 | MsgType_Core_FundingBTC_2109: number; 337 | MsgType_Core_BtcCreateMultiSig_2110: number; 338 | MsgType_Core_Btc_ImportPrivKey_2111: number; 339 | MsgType_Core_Omni_Getbalance_2112: number; 340 | MsgType_Core_Omni_CreateNewTokenFixed_2113: number; 341 | MsgType_Core_Omni_CreateNewTokenManaged_2114: number; 342 | MsgType_Core_Omni_GrantNewUnitsOfManagedToken_2115: number; 343 | MsgType_Core_Omni_RevokeUnitsOfManagedToken_2116: number; 344 | MsgType_Core_Omni_ListProperties_2117: number; 345 | MsgType_Core_Omni_GetTransaction_2118: number; 346 | MsgType_Core_Omni_GetProperty_2119: number; 347 | MsgType_Core_Omni_FundingAsset_2120: number; 348 | MsgType_Core_Omni_Send_2121: number; 349 | MsgType_Mnemonic_CreateAddress_3000: number; 350 | MsgType_Mnemonic_GetAddressByIndex_3001: number; 351 | MsgType_FundingCreate_Asset_AllItem_3100: number; 352 | MsgType_FundingCreate_Asset_ItemById_3101: number; 353 | MsgType_FundingCreate_Asset_ItemByChannelId_3102: number; 354 | MsgType_FundingCreate_Asset_Count_3103: number; 355 | MsgType_SendChannelOpen_32: number; 356 | MsgType_RecvChannelOpen_32: number; 357 | MsgType_SendChannelAccept_33: number; 358 | MsgType_RecvChannelAccept_33: number; 359 | MsgType_FundingCreate_SendAssetFundingCreated_34: number; 360 | MsgType_FundingCreate_RecvAssetFundingCreated_34: number; 361 | MsgType_FundingSign_SendAssetFundingSigned_35: number; 362 | MsgType_FundingSign_RecvAssetFundingSigned_35: number; 363 | MsgType_ClientSign_AssetFunding_AliceSignC1a_1034: number; 364 | MsgType_ClientSign_AssetFunding_AliceSignRD_1134: number; 365 | MsgType_ClientSign_Duplex_AssetFunding_RdAndBr_1035: number; 366 | MsgType_FundingCreate_SendBtcFundingCreated_340: number; 367 | MsgType_FundingCreate_BtcFundingMinerRDTxToClient_341: number; 368 | MsgType_FundingCreate_RecvBtcFundingCreated_340: number; 369 | MsgType_FundingSign_SendBtcSign_350: number; 370 | MsgType_FundingSign_RecvBtcSign_350: number; 371 | MsgType_CommitmentTx_SendCommitmentTransactionCreated_351: number; 372 | MsgType_CommitmentTx_RecvCommitmentTransactionCreated_351: number; 373 | MsgType_CommitmentTxSigned_SendRevokeAndAcknowledgeCommitmentTransaction_352: number; 374 | MsgType_CommitmentTxSigned_RecvRevokeAndAcknowledgeCommitmentTransaction_352: number; 375 | MsgType_ClientSign_BobC2b_Rd_353: number; 376 | MsgType_ClientSign_CommitmentTx_AliceSignC2a_360: number; 377 | MsgType_ClientSign_CommitmentTx_BobSignC2b_361: number; 378 | MsgType_ClientSign_CommitmentTx_AliceSignC2b_362: number; 379 | MsgType_ClientSign_CommitmentTx_AliceSignC2b_Rd_363: number; 380 | MsgType_ClientSign_CommitmentTx_BobSignC2b_Rd_364: number; 381 | MsgType_ChannelOpen_AllItem_3150: number; 382 | MsgType_ChannelOpen_ItemByTempId_3151: number; 383 | MsgType_ChannelOpen_Count_3152: number; 384 | MsgType_ChannelOpen_DelItemByTempId_3153: number; 385 | MsgType_GetChannelInfoByChannelId_3154: number; 386 | MsgType_GetChannelInfoByDbId_3155: number; 387 | MsgType_CheckChannelAddessExist_3156: number; 388 | MsgType_CommitmentTx_ItemsByChanId_3200: number; 389 | MsgType_CommitmentTx_ItemById_3201: number; 390 | MsgType_CommitmentTx_Count_3202: number; 391 | MsgType_CommitmentTx_LatestCommitmentTxByChanId_3203: number; 392 | MsgType_CommitmentTx_LatestRDByChanId_3204: number; 393 | MsgType_CommitmentTx_LatestBRByChanId_3205: number; 394 | MsgType_CommitmentTx_SendSomeCommitmentById_3206: number; 395 | MsgType_CommitmentTx_AllRDByChanId_3207: number; 396 | MsgType_CommitmentTx_AllBRByChanId_3208: number; 397 | MsgType_SendCloseChannelRequest_38: number; 398 | MsgType_RecvCloseChannelRequest_38: number; 399 | MsgType_SendCloseChannelSign_39: number; 400 | MsgType_RecvCloseChannelSign_39: number; 401 | MsgType_HTLC_FindPath_401: number; 402 | MsgType_HTLC_Invoice_402: number; 403 | MsgType_HTLC_SendAddHTLC_40: number; 404 | MsgType_HTLC_RecvAddHTLC_40: number; 405 | MsgType_HTLC_SendAddHTLCSigned_41: number; 406 | MsgType_HTLC_RecvAddHTLCSigned_41: number; 407 | MsgType_HTLC_BobSignC3bSubTx_42: number; 408 | MsgType_HTLC_FinishTransferH_43: number; 409 | MsgType_HTLC_SendVerifyR_45: number; 410 | MsgType_HTLC_RecvVerifyR_45: number; 411 | MsgType_HTLC_SendSignVerifyR_46: number; 412 | MsgType_HTLC_RecvSignVerifyR_46: number; 413 | MsgType_HTLC_SendRequestCloseCurrTx_49: number; 414 | MsgType_HTLC_RecvRequestCloseCurrTx_49: number; 415 | MsgType_HTLC_SendCloseSigned_50: number; 416 | MsgType_HTLC_RecvCloseSigned_50: number; 417 | MsgType_HTLC_Close_ClientSign_Bob_C4bSub_51: number; 418 | MsgType_HTLC_ClientSign_Alice_C3a_100: number; 419 | MsgType_HTLC_ClientSign_Bob_C3b_101: number; 420 | MsgType_HTLC_ClientSign_Alice_C3b_102: number; 421 | MsgType_HTLC_ClientSign_Alice_C3bSub_103: number; 422 | MsgType_HTLC_ClientSign_Bob_C3bSub_104: number; 423 | MsgType_HTLC_ClientSign_Alice_He_105: number; 424 | MsgType_HTLC_ClientSign_Bob_HeSub_106: number; 425 | MsgType_HTLC_ClientSign_Alice_HeSub_107: number; 426 | MsgType_HTLC_Close_ClientSign_Alice_C4a_110: number; 427 | MsgType_HTLC_Close_ClientSign_Bob_C4b_111: number; 428 | MsgType_HTLC_Close_ClientSign_Alice_C4b_112: number; 429 | MsgType_HTLC_Close_ClientSign_Alice_C4bSub_113: number; 430 | MsgType_HTLC_Close_ClientSign_Bob_C4bSubResult_114: number; 431 | MsgType_Atomic_SendSwap_80: number; 432 | MsgType_Atomic_RecvSwap_80: number; 433 | MsgType_Atomic_SendSwapAccept_81: number; 434 | MsgType_Atomic_RecvSwapAccept_81: number; 435 | } 436 | -------------------------------------------------------------------------------- /lib/types/result.d.ts: -------------------------------------------------------------------------------- 1 | export declare type Result = Ok | Err; 2 | export declare class Ok { 3 | readonly value: T; 4 | constructor(value: T); 5 | isOk(): this is Ok; 6 | isErr(): this is Err; 7 | } 8 | export declare class Err { 9 | readonly error: Error; 10 | constructor(error: Error); 11 | isOk(): this is Ok; 12 | isErr(): this is Err; 13 | } 14 | export declare const ok: (value: T) => Ok; 15 | export declare const err: (error: Error | string) => Err; 16 | -------------------------------------------------------------------------------- /lib/types/shapes.d.ts: -------------------------------------------------------------------------------- 1 | import { IChannelSigningData, IData } from './types'; 2 | export declare const addressContent: { 3 | index: number; 4 | path: string; 5 | address: string; 6 | scriptHash: string; 7 | publicKey: string; 8 | }; 9 | export declare const defaultDataShape: IData; 10 | export declare const channelSigningData: IChannelSigningData; 11 | -------------------------------------------------------------------------------- /lib/types/types.d.ts: -------------------------------------------------------------------------------- 1 | import { ECPairInterface } from 'bitcoinjs-lib'; 2 | export interface IConnect { 3 | recipient_node_peer_id: string; 4 | recipient_user_peer_id: string; 5 | sender_node_peer_id: string; 6 | sender_user_peer_id: string; 7 | } 8 | export interface ILogin { 9 | chainNodeType: string; 10 | htlcFeeRate: number; 11 | htlcMaxFee: number; 12 | nodeAddress: string; 13 | nodePeerId: string; 14 | userPeerId: string; 15 | } 16 | export interface IConnectResponse extends IConnect, ILogin { 17 | } 18 | export interface IOnChannelOpenAttempt { 19 | chain_hash: string; 20 | channel_reserve_satoshis: number; 21 | delayed_payment_base_point: string; 22 | dust_limit_satoshis: number; 23 | fee_rate_per_kw: number; 24 | funder_address_index: number; 25 | funder_node_address: string; 26 | funder_peer_id: string; 27 | funding_address: string; 28 | funding_pubkey: string; 29 | funding_satoshis: number; 30 | htlc_base_point: string; 31 | htlc_minimum_msat: number; 32 | is_private: boolean; 33 | length: number; 34 | max_accepted_htlcs: number; 35 | max_htlc_value_in_flight_msat: number; 36 | payment_base_point: string; 37 | push_msat: number; 38 | revocation_base_point: string; 39 | temporary_channel_id: string; 40 | to_self_delay: number; 41 | value: null; 42 | value_type: string; 43 | } 44 | export declare type TOnChannelOpenAttempt = IOmniboltResponse; 45 | export interface IAcceptChannel { 46 | accept_at: string; 47 | address_a: string; 48 | address_b: string; 49 | amount: number; 50 | btc_amount: number; 51 | chain_hash: string; 52 | channel_address: string; 53 | channel_address_redeem_script: string; 54 | channel_address_script_pub_key: string; 55 | channel_id: string; 56 | channel_reserve_satoshis: number; 57 | close_at: string; 58 | create_at: string; 59 | create_by: string; 60 | curr_state: number; 61 | delayed_payment_base_point: string; 62 | dust_limit_satoshis: number; 63 | fee_rate_per_kw: number; 64 | fundee_address_index: number; 65 | funder_address_index: number; 66 | funder_node_address: string; 67 | funder_peer_id: string; 68 | funding_address: string; 69 | funding_pubkey: string; 70 | funding_satoshis: number; 71 | htlc_base_point: string; 72 | htlc_minimum_msat: number; 73 | id: number; 74 | is_private: boolean; 75 | length: number; 76 | max_accepted_htlcs: number; 77 | max_htlc_value_in_flight_msat: number; 78 | payment_base_point: string; 79 | peer_id_a: string; 80 | peer_id_b: string; 81 | property_id: number; 82 | pub_key_a: string; 83 | pub_key_b: string; 84 | push_msat: number; 85 | refuse_reason: string; 86 | revocation_base_point: string; 87 | temporary_channel_id: string; 88 | to_self_delay: number; 89 | value: null; 90 | value_type: string; 91 | } 92 | export declare type TOnAcceptChannel = IOmniboltResponse; 93 | export interface IOnChannelOpen { 94 | data: { 95 | asset_amount: number; 96 | balance_a: number; 97 | balance_b: number; 98 | balance_htlc: number; 99 | btc_amount: number; 100 | btc_funding_times: number; 101 | channel_address: string; 102 | channel_id: string; 103 | create_at: string; 104 | curr_state: number; 105 | is_private: false; 106 | num_updates: number; 107 | peer_ida: string; 108 | peer_idb: string; 109 | property_id: number; 110 | temporary_channel_id: string; 111 | }[]; 112 | } 113 | export declare type TOnChannelOpen = IOmniboltResponse; 114 | export interface IGetMyChannelsData { 115 | asset_amount: number; 116 | balance_a: number; 117 | balance_b: number; 118 | balance_htlc: number; 119 | btc_amount: number; 120 | btc_funding_times: number; 121 | channel_address: string; 122 | channel_id: string; 123 | create_at: string; 124 | curr_state: number; 125 | is_private: boolean; 126 | peer_ida: string; 127 | peer_idb: string; 128 | property_id: number; 129 | temporary_channel_id: string; 130 | } 131 | export interface IGetMyChannels { 132 | data: IGetMyChannelsData[]; 133 | pageNum: number; 134 | pageSize: number; 135 | totalCount: number; 136 | totalPage: number; 137 | } 138 | export interface IFundingInputs { 139 | amount: number; 140 | scriptPubKey: string; 141 | txid: string; 142 | vout: number; 143 | } 144 | export interface IFundingCreatedInputs extends IFundingInputs { 145 | redeemScript: string; 146 | } 147 | export interface IFundingBitcoin { 148 | hex: string; 149 | inputs: IFundingInputs[]; 150 | is_multisig: boolean; 151 | total_in_amount: number; 152 | } 153 | export interface IBitcoinFundingCreated { 154 | hex: string; 155 | inputs: { 156 | amount: number; 157 | redeemScript: string; 158 | scriptPubKey: string; 159 | txid: string; 160 | vout: number; 161 | }[]; 162 | is_multisig: boolean; 163 | pub_key_a: string; 164 | pub_key_b: string; 165 | temporary_channel_id: string; 166 | total_in_amount: number; 167 | total_out_amount: number; 168 | } 169 | export interface IInputs { 170 | amount: number; 171 | redeemScript: string; 172 | scriptPubKey: string; 173 | sequence: number; 174 | txid: string; 175 | vout: number; 176 | } 177 | export interface IListening110035 { 178 | channel_id: string; 179 | hex: string; 180 | inputs: IInputs[]; 181 | is_multisig: boolean; 182 | pub_key_a: string; 183 | pub_key_b: string; 184 | temporary_channel_id: string; 185 | to_peer_id: string; 186 | } 187 | export interface IOnBitcoinFundingCreated { 188 | funder_node_address: string; 189 | funder_peer_id: string; 190 | funding_btc_hex: string; 191 | funding_redeem_hex: string; 192 | funding_txid: string; 193 | sign_data: { 194 | hex: string; 195 | inputs: IFundingCreatedInputs[]; 196 | is_multisig: boolean; 197 | pub_key_a: string; 198 | pub_key_b: string; 199 | temporary_channel_id: string; 200 | total_in_amount: number; 201 | total_out_amount: number; 202 | }; 203 | } 204 | export declare type TOnBitcoinFundingCreated = IOmniboltResponse; 205 | export interface ISendSignedHex101034 extends IOnAssetFundingCreated { 206 | } 207 | export interface IOnAssetFundingCreated { 208 | c1a_rsmc_hex: string; 209 | channel_id: string; 210 | funder_node_address: string; 211 | funder_peer_id: string; 212 | funding_omni_hex: string; 213 | rsmc_temp_address_pub_key: string; 214 | sign_data: { 215 | hex: string; 216 | inputs: { 217 | amount: number; 218 | redeemScript: string; 219 | scriptPubKey: string; 220 | txid: string; 221 | vout: number; 222 | }[]; 223 | is_multisig: boolean; 224 | pub_key_a: string; 225 | pub_key_b: string; 226 | temporary_channel_id: string; 227 | total_in_amount: number; 228 | total_out_amount: number; 229 | }; 230 | temporary_channel_id: string; 231 | to_peer_id: string; 232 | } 233 | export declare type TOnAssetFundingCreated = IOmniboltResponse; 234 | export interface ISendSignedHex100341 { 235 | signed_hex: string; 236 | } 237 | export interface IBitcoinFundingSigned { 238 | approval: true; 239 | funding_redeem_hex: string; 240 | funding_txid: string; 241 | temporary_channel_id: string; 242 | } 243 | export interface IAssetFundingSigned { 244 | alice_br_sign_data: { 245 | br_id: number; 246 | hex: string; 247 | inputs: IFundingInputs[]; 248 | is_multisig: boolean; 249 | pub_key_a: string; 250 | pub_key_b: string; 251 | }; 252 | alice_rd_sign_data: { 253 | hex: string; 254 | inputs: IFundingInputs[]; 255 | is_multisig: true; 256 | pub_key_a: string; 257 | pub_key_b: string; 258 | }; 259 | temporary_channel_id: string; 260 | } 261 | export interface ISendSignedHex101035 { 262 | channel_id: string; 263 | } 264 | export declare type TSendSignedHex101035 = ISendSignedHex101035; 265 | export interface ICounterpartyRawData { 266 | hex: string; 267 | inputs: { 268 | amount: number; 269 | redeemScript: string; 270 | scriptPubKey: string; 271 | txid: string; 272 | vout: number; 273 | }[]; 274 | is_multisig: true; 275 | private_key: string; 276 | pub_key_a: string; 277 | pub_key_b: string; 278 | } 279 | export interface IRSMCRawData { 280 | hex: string; 281 | inputs: { 282 | amount: number; 283 | redeemScript: string; 284 | scriptPubKey: string; 285 | txid: string; 286 | vout: number; 287 | }[]; 288 | is_multisig: false; 289 | private_key: string; 290 | pub_key_a: string; 291 | pub_key_b: string; 292 | } 293 | export interface ICommitmentTransactionCreated { 294 | channel_id: string; 295 | counterparty_raw_data: ICounterpartyRawData; 296 | rsmc_raw_data: IRSMCRawData; 297 | } 298 | export interface IOnCommitmentTransactionCreated { 299 | amount: number; 300 | amount_a: number; 301 | amount_b: number; 302 | channel_id: string; 303 | commitment_tx_hash: string; 304 | counterparty_raw_data: ICounterpartyRawData; 305 | curr_temp_address_pub_key: string; 306 | last_temp_address_private_key: string; 307 | length: number; 308 | msg_hash: string; 309 | payer_node_address: string; 310 | payer_peer_id: string; 311 | rsmc_raw_data: IRSMCRawData; 312 | to_peer_id: string; 313 | value: null; 314 | value_type: string; 315 | } 316 | export declare type TOnCommitmentTransactionCreated = IOmniboltResponse; 317 | export interface ICommitmentInputs { 318 | amount: number; 319 | redeemScript: string; 320 | scriptPubKey: string; 321 | txid: string; 322 | vout: number; 323 | } 324 | export interface ICommitmentSequenceInputs extends ICommitmentInputs { 325 | sequence: number; 326 | } 327 | export interface ICommitmentTransactionAcceptedResponse { 328 | c2a_br_raw_data: { 329 | br_id: number; 330 | hex: string; 331 | inputs: ICommitmentInputs[]; 332 | is_multisig: boolean; 333 | pub_key_a: string; 334 | pub_key_b: string; 335 | }; 336 | c2a_rd_raw_data: { 337 | hex: string; 338 | inputs: ICommitmentSequenceInputs[]; 339 | is_multisig: boolean; 340 | pub_key_a: string; 341 | pub_key_b: string; 342 | }; 343 | c2b_counterparty_raw_data: { 344 | hex: string; 345 | inputs: ICommitmentInputs[]; 346 | is_multisig: boolean; 347 | pub_key_a: string; 348 | pub_key_b: string; 349 | }; 350 | c2b_rsmc_raw_data: { 351 | hex: string; 352 | inputs: ICommitmentInputs[]; 353 | is_multisig: boolean; 354 | pub_key_a: string; 355 | pub_key_b: string; 356 | }; 357 | channel_id: string; 358 | } 359 | export interface ISendSignedHex100361Response { 360 | approval: boolean; 361 | channel_id: string; 362 | commitment_tx_hash: string; 363 | } 364 | export interface ISendSignedHex100364Response { 365 | amount_to_counterparty: number; 366 | amount_to_rsmc: number; 367 | channel_id: string; 368 | create_at: string; 369 | create_by: string; 370 | curr_hash: string; 371 | curr_state: number; 372 | htlc_amount_to_payee: number; 373 | id: number; 374 | input_amount: number; 375 | input_txid: string; 376 | input_vout: number; 377 | last_commitment_tx_id: number; 378 | last_edit_time: string; 379 | last_hash: string; 380 | owner: string; 381 | peer_id_a: string; 382 | peer_id_b: string; 383 | property_id: number; 384 | rsmc_input_txid: string; 385 | rsmc_multi_address: string; 386 | rsmc_multi_address_script_pub_key: string; 387 | rsmc_redeem_script: string; 388 | rsmc_temp_address_index: number; 389 | rsmc_temp_address_pub_key: string; 390 | rsmc_tx_hex: string; 391 | rsmc_txid: string; 392 | send_at: string; 393 | sign_at: string; 394 | to_counterparty_tx_hex: string; 395 | to_counterparty_txid: string; 396 | tx_type: number; 397 | } 398 | export interface ISendSignedHex100362Response { 399 | c2b_br_raw_data: { 400 | br_id: number; 401 | hex: string; 402 | inputs: { 403 | amount: number; 404 | redeemScript: string; 405 | scriptPubKey: string; 406 | txid: string; 407 | vout: number; 408 | }[]; 409 | is_multisig: boolean; 410 | private_key: string; 411 | pub_key_a: string; 412 | pub_key_b: string; 413 | }; 414 | c2b_rd_raw_data: { 415 | hex: string; 416 | inputs: { 417 | amount: number; 418 | redeemScript: string; 419 | scriptPubKey: string; 420 | sequence: number; 421 | txid: string; 422 | vout: number; 423 | }[]; 424 | is_multisig: boolean; 425 | private_key: string; 426 | pub_key_a: string; 427 | pub_key_b: string; 428 | }; 429 | channel_id: string; 430 | } 431 | export interface ISendSignedHex100363Response { 432 | approval: boolean; 433 | channel_id: string; 434 | latest_commitment_tx_info: { 435 | amount_to_counterparty: number; 436 | amount_to_rsmc: number; 437 | channel_id: string; 438 | create_at: string; 439 | create_by: string; 440 | curr_hash: string; 441 | curr_state: number; 442 | htlc_amount_to_payee: number; 443 | id: number; 444 | input_amount: number; 445 | input_txid: string; 446 | input_vout: number; 447 | last_commitment_tx_id: number; 448 | last_edit_time: string; 449 | last_hash: string; 450 | owner: string; 451 | peer_id_a: string; 452 | peer_id_b: string; 453 | property_id: number; 454 | rsmc_input_txid: string; 455 | rsmc_multi_address: string; 456 | rsmc_multi_address_script_pub_key: string; 457 | rsmc_redeem_script: string; 458 | rsmc_temp_address_index: number; 459 | rsmc_temp_address_pub_key: string; 460 | rsmc_tx_hex: string; 461 | rsmc_txid: string; 462 | send_at: string; 463 | sign_at: string; 464 | to_counterparty_tx_hex: string; 465 | to_counterparty_txid: string; 466 | tx_type: number; 467 | }; 468 | } 469 | export interface IOn110353 { 470 | c2b_rd_partial_data: { 471 | hex: string; 472 | inputs: { 473 | amount: number; 474 | redeemScript: string; 475 | scriptPubKey: string; 476 | sequence: number; 477 | txid: string; 478 | vout: number; 479 | }[]; 480 | is_multisig: boolean; 481 | private_key: string; 482 | pub_key_a: string; 483 | pub_key_b: string; 484 | }; 485 | channel_id: string; 486 | to_peer_id: string; 487 | } 488 | export declare type TOn110353 = IOmniboltResponse; 489 | export interface IOn110352 { 490 | c2a_rd_partial_data: { 491 | hex: string; 492 | inputs: { 493 | amount: number; 494 | redeemScript: string; 495 | scriptPubKey: string; 496 | sequence: number; 497 | txid: string; 498 | vout: number; 499 | }[]; 500 | is_multisig: boolean; 501 | private_key: string; 502 | pub_key_a: string; 503 | pub_key_b: string; 504 | }; 505 | c2b_counterparty_partial_data: { 506 | hex: string; 507 | inputs: { 508 | amount: number; 509 | redeemScript: string; 510 | scriptPubKey: string; 511 | txid: string; 512 | vout: number; 513 | }[]; 514 | is_multisig: boolean; 515 | private_key: string; 516 | pub_key_a: string; 517 | pub_key_b: string; 518 | }; 519 | c2b_rsmc_partial_data: { 520 | hex: string; 521 | inputs: { 522 | amount: number; 523 | redeemScript: string; 524 | scriptPubKey: string; 525 | txid: string; 526 | vout: number; 527 | }[]; 528 | is_multisig: boolean; 529 | private_key: string; 530 | pub_key_a: string; 531 | pub_key_b: string; 532 | }; 533 | channel_id: string; 534 | payee_node_address: string; 535 | payee_peer_id: string; 536 | to_peer_id: string; 537 | } 538 | export declare type TOn110352 = IOmniboltResponse; 539 | export interface IOmniboltResponse extends IAdditionalResponseData { 540 | type: number; 541 | status: boolean; 542 | from: string; 543 | to: string; 544 | result: T; 545 | } 546 | export interface IAdditionalResponseData { 547 | pageNum?: number; 548 | pageSize?: number; 549 | totalCount?: number; 550 | totalPage?: number; 551 | } 552 | export interface IGetProperty { 553 | category: string; 554 | creationtxid: string; 555 | data: string; 556 | divisible: boolean; 557 | fixedissuance: boolean; 558 | issuer: string; 559 | managedissuance: boolean; 560 | name: string; 561 | propertyid: number; 562 | subcategory: string; 563 | totaltokens: string; 564 | url: string; 565 | } 566 | export interface ICloseChannel { 567 | accept_at: string; 568 | address_a: string; 569 | address_b: string; 570 | amount: number; 571 | btc_amount: number; 572 | chain_hash: string; 573 | channel_address: string; 574 | channel_address_redeem_script: string; 575 | channel_address_script_pub_key: string; 576 | channel_id: string; 577 | channel_reserve_satoshis: number; 578 | close_at: string; 579 | create_at: string; 580 | create_by: string; 581 | curr_state: number; 582 | delayed_payment_base_point: string; 583 | dust_limit_satoshis: number; 584 | fee_rate_per_kw: number; 585 | fundee_address_index: number; 586 | funder_address_index: number; 587 | funder_node_address: string; 588 | funder_peer_id: string; 589 | funding_address: string; 590 | funding_pubkey: string; 591 | funding_satoshis: number; 592 | htlc_base_point: string; 593 | htlc_minimum_msat: number; 594 | id: number; 595 | is_private: boolean; 596 | length: number; 597 | max_accepted_htlcs: number; 598 | max_htlc_value_in_flight_msat: number; 599 | payment_base_point: string; 600 | peer_id_a: string; 601 | peer_id_b: string; 602 | property_id: number; 603 | pub_key_a: string; 604 | pub_key_b: string; 605 | push_msat: number; 606 | refuse_reason: string; 607 | revocation_base_point: string; 608 | temporary_channel_id: string; 609 | to_self_delay: number; 610 | value: number | null; 611 | value_type: string; 612 | } 613 | export interface IAddressContent { 614 | index: number; 615 | path: string; 616 | address: string; 617 | scriptHash: string; 618 | publicKey: string; 619 | } 620 | export interface ISigningDataContent { 621 | fundingAddress: IAddressContent; 622 | addressIndex: IAddressContent; 623 | last_temp_address: IAddressContent; 624 | rsmc_temp_address: IAddressContent; 625 | htlc_temp_address: IAddressContent; 626 | htlc_temp_address_for_he1b: IAddressContent; 627 | kTbSignedHex: string; 628 | funding_txid: string; 629 | kTempPrivKey: string; 630 | kTbSignedHexCR110351: string; 631 | kTbSignedHexRR110351: string; 632 | } 633 | export interface ISigningData { 634 | [key: string]: ISigningDataContent; 635 | } 636 | export declare type TOmniboltCheckpoints = 'onChannelOpenAttempt' | 'channelAccept' | 'onAcceptChannel' | 'fundBitcoin' | 'onFundBitcoin' | 'onBitcoinFundingCreated' | 'onAssetFundingCreated' | 'sendSignedHex101035' | 'onCommitmentTransactionCreated' | 'commitmentTransactionAccepted' | 'on110353' | 'on110352' | 'htlcFindPath' | 'onHtlcFindPath' | 'addHtlc' | 'onAddHtlc' | 'htlcSIgned' | 'onHtlcSigned' | 'forwardR' | 'onForwardR' | 'signR' | 'onSignR' | 'closeHtlc' | 'onCloseHtlc' | 'closeHtlcSigned' | 'onCloseHtlcSigned' | 'onChannelCloseAttempt' | 'sendSignedHex100363'; 637 | export interface ICheckpoint { 638 | checkpoint: TOmniboltCheckpoints; 639 | data: any; 640 | } 641 | export interface ICheckpoints { 642 | [key: string]: ICheckpoint; 643 | } 644 | export interface IFundingAddress extends IAddressContent { 645 | assets: []; 646 | } 647 | export declare type TFundingAddresses = { 648 | [key: string]: IAddressContent; 649 | }; 650 | export interface IData { 651 | nextAddressIndex: IAddressContent; 652 | signingData: ISigningData; 653 | checkpoints: ICheckpoints; 654 | fundingAddresses: TFundingAddresses; 655 | } 656 | export interface ISaveData { 657 | nextAddressIndex: IAddressContent; 658 | signingData: ISigningData; 659 | checkpoints: ICheckpoints; 660 | fundingAddresses: TFundingAddresses; 661 | } 662 | export declare type TAvailableNetworks = 'bitcoin' | 'bitcoinTestnet'; 663 | export interface IGetAddress { 664 | keyPair: ECPairInterface | undefined; 665 | network: INetwork | undefined; 666 | type?: 'bech32' | 'segwit' | 'legacy'; 667 | } 668 | export interface INetwork { 669 | messagePrefix: string; 670 | bech32: string; 671 | bip32: { 672 | public: number; 673 | private: number; 674 | }; 675 | pubKeyHash: number; 676 | scriptHash: number; 677 | wif: number; 678 | } 679 | export interface IChannelSigningData { 680 | fundingAddress: IAddressContent; 681 | addressIndex: IAddressContent; 682 | last_temp_address: IAddressContent; 683 | rsmc_temp_address: IAddressContent; 684 | htlc_temp_address: IAddressContent; 685 | htlc_temp_address_for_he1b: IAddressContent; 686 | kTbSignedHex: string; 687 | funding_txid: string; 688 | kTempPrivKey: string; 689 | kTbSignedHexCR110351: string; 690 | kTbSignedHexRR110351: string; 691 | kTbTempData: string; 692 | } 693 | export declare type IListeners = { 694 | [key in TOmniboltCheckpoints]?: IListenerParams; 695 | }; 696 | export interface IListenerParams { 697 | start: (data: TStart) => any; 698 | success: (data: TSuccess) => any; 699 | failure: (data: any) => any; 700 | } 701 | export interface ISignP2PKH { 702 | txhex: string; 703 | inputs: IFundingInputs[]; 704 | privkey: string; 705 | selectedNetwork?: TAvailableNetworks; 706 | } 707 | export interface ISignP2SH { 708 | is_first_sign: boolean; 709 | txhex: string; 710 | pubkey_1: string; 711 | pubkey_2: string; 712 | privkey: string; 713 | inputs: any; 714 | selectedNetwork?: TAvailableNetworks | undefined; 715 | } 716 | export interface ISendSignedHex100363 { 717 | data: ISendSignedHex100362Response; 718 | privkey: string; 719 | channelId: string; 720 | nodeID: string; 721 | userID: string; 722 | } 723 | export interface ISendSignedHex101134 { 724 | channel_id: string; 725 | temporary_channel_id: string; 726 | } 727 | export interface ICommitmentTransactionAcceptedCheckpointData { 728 | info: ICommitmentTransactionAcceptedResponse; 729 | nodeID: string; 730 | userID: string; 731 | } 732 | export interface IOpenChannel { 733 | chain_hash: string; 734 | channel_reserve_satoshis: number; 735 | delayed_payment_base_point: string; 736 | dust_limit_satoshis: number; 737 | fee_rate_per_kw: number; 738 | funder_address_index: number; 739 | funder_node_address: string; 740 | funder_peer_id: string; 741 | funding_address: string; 742 | funding_pubkey: string; 743 | funding_satoshis: number; 744 | htlc_base_point: string; 745 | htlc_minimum_msat: number; 746 | is_private: boolean; 747 | length: number; 748 | max_accepted_htlcs: number; 749 | max_htlc_value_in_flight_msat: number; 750 | payment_base_point: string; 751 | push_msat: number; 752 | revocation_base_point: string; 753 | temporary_channel_id: string; 754 | to_self_delay: number; 755 | value: number | null; 756 | value_type: string; 757 | } 758 | export interface IFundAssetResponse { 759 | hex: string; 760 | inputs: { 761 | amount: number; 762 | scriptPubKey: string; 763 | txid: string; 764 | vout: number; 765 | }[]; 766 | } 767 | export interface IFundingInfo { 768 | fundingAddressIndex?: number; 769 | amount_to_fund?: number; 770 | miner_fee?: number; 771 | asset_id: number; 772 | asset_amount: number; 773 | } 774 | export interface IConnectUri { 775 | remote_node_address: string; 776 | recipient_user_peer_id: string; 777 | } 778 | export interface ICreateChannel extends IConnectUri { 779 | info: IFundingInfo; 780 | } 781 | export interface IFundTempChannel { 782 | recipient_node_peer_id: string; 783 | recipient_user_peer_id: string; 784 | temporary_channel_id: string; 785 | info: IFundingInfo; 786 | } 787 | export interface IParseOmniboltUriResponse { 788 | action: string; 789 | data: { 790 | remote_node_address?: string; 791 | recipient_user_peer_id?: string; 792 | [key: string]: any; 793 | }; 794 | } 795 | export interface IGenerateOmniboltUri { 796 | action: string; 797 | data: string | object; 798 | } 799 | export interface IGetAllBalancesForAddressResponse { 800 | balance: string; 801 | frozen: string; 802 | name: string; 803 | propertyid: number; 804 | reserved: string; 805 | } 806 | export interface IGetTransactionResponse { 807 | amount: string; 808 | block: number; 809 | blockhash: string; 810 | blocktime: number; 811 | category: string; 812 | confirmations: number; 813 | data: string; 814 | divisible: boolean; 815 | ecosystem: string; 816 | fee: string; 817 | ismine: boolean; 818 | positioninblock: number; 819 | propertyid: number; 820 | propertyname: string; 821 | propertytype: string; 822 | sendingaddress: string; 823 | subcategory: string; 824 | txid: string; 825 | type: string; 826 | type_int: number; 827 | url: string; 828 | valid: boolean; 829 | version: number; 830 | } 831 | -------------------------------------------------------------------------------- /lib/types/utils/browser-or-node.d.ts: -------------------------------------------------------------------------------- 1 | declare const isBrowser: () => boolean; 2 | declare const isWebWorker: () => boolean; 3 | declare const isNode: () => boolean; 4 | declare const isJsDom: () => boolean; 5 | export { isBrowser, isWebWorker, isNode, isJsDom }; 6 | -------------------------------------------------------------------------------- /lib/types/utils/index.d.ts: -------------------------------------------------------------------------------- 1 | import { Result } from '../result'; 2 | import { IAddressContent, IGenerateOmniboltUri, IGetAddress, IParseOmniboltUriResponse, ISignP2PKH, ISignP2SH, TAvailableNetworks } from '../types'; 3 | import { INetwork } from './networks'; 4 | export declare const getNextOmniboltAddress: ({ selectedNetwork, addressIndex, mnemonic, }: { 5 | selectedNetwork: TAvailableNetworks; 6 | addressIndex: IAddressContent; 7 | mnemonic: string; 8 | }) => Promise>; 9 | export declare const getAddress: ({ keyPair, network, type, }: IGetAddress) => string; 10 | export declare const getScriptHash: (address?: string, network?: INetwork | string) => string; 11 | export declare const getPrivateKey: ({ addressData, selectedNetwork, mnemonic, }: { 12 | addressData: IAddressContent; 13 | selectedNetwork?: "bitcoin" | "bitcoinTestnet" | undefined; 14 | mnemonic: string; 15 | }) => Promise>; 16 | export declare const signP2PKH: ({ txhex, privkey, inputs, selectedNetwork }: ISignP2PKH) => string; 17 | export declare const generateFundingAddress: ({ index, mnemonic, selectedNetwork, }: { 18 | index: number; 19 | mnemonic: string; 20 | selectedNetwork: TAvailableNetworks; 21 | }) => Promise>; 22 | export declare const signP2SH: ({ is_first_sign, txhex, pubkey_1, pubkey_2, privkey, inputs, selectedNetwork, }: ISignP2SH) => Promise; 23 | export declare const accMul: (arg1: any, arg2: any) => number; 24 | export declare const promiseTimeout: (ms: number, promise: Promise) => Promise; 25 | export declare const sleep: (ms?: number) => Promise; 26 | export declare const parseOmniboltUri: (uri: string) => Result; 27 | export declare const generateOmniboltUri: ({ action, data }: IGenerateOmniboltUri) => Result; 28 | -------------------------------------------------------------------------------- /lib/types/utils/networks.d.ts: -------------------------------------------------------------------------------- 1 | export declare type TAvailableNetworks = 'bitcoin' | 'bitcoinTestnet'; 2 | export declare enum EAvailableNetworks { 3 | bitcoin = "bitcoin", 4 | bitcoinTestnet = "bitcoinTestnet" 5 | } 6 | export interface INetwork { 7 | messagePrefix: string; 8 | bech32: string; 9 | bip32: { 10 | public: number; 11 | private: number; 12 | }; 13 | pubKeyHash: number; 14 | scriptHash: number; 15 | wif: number; 16 | } 17 | export declare type INetworks = { 18 | [key in EAvailableNetworks]: INetwork; 19 | }; 20 | export declare const networks: INetworks; 21 | -------------------------------------------------------------------------------- /lib/utils/browser-or-node.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.isJsDom = exports.isNode = exports.isWebWorker = exports.isBrowser = void 0; 4 | const isBrowser = () => { 5 | try { 6 | return typeof window !== 'undefined' && typeof window.document !== 'undefined'; 7 | } 8 | catch { 9 | return false; 10 | } 11 | }; 12 | exports.isBrowser = isBrowser; 13 | const isWebWorker = () => { 14 | try { 15 | return typeof self === 'object' 16 | && self.constructor 17 | && self.constructor.name === 'DedicatedWorkerGlobalScope'; 18 | } 19 | catch { 20 | return false; 21 | } 22 | }; 23 | exports.isWebWorker = isWebWorker; 24 | const isNode = () => { 25 | try { 26 | return typeof process !== 'undefined' 27 | && process.versions != null 28 | && process.versions.node != null; 29 | } 30 | catch { 31 | return false; 32 | } 33 | }; 34 | exports.isNode = isNode; 35 | const isJsDom = () => { 36 | try { 37 | return (typeof window !== 'undefined' && window.name === 'nodejs') 38 | || navigator.userAgent.includes('Node.js') 39 | || navigator.userAgent.includes('jsdom'); 40 | } 41 | catch { 42 | return false; 43 | } 44 | }; 45 | exports.isJsDom = isJsDom; 46 | //# sourceMappingURL=browser-or-node.js.map -------------------------------------------------------------------------------- /lib/utils/browser-or-node.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"browser-or-node.js","sourceRoot":"","sources":["../../src/utils/browser-or-node.ts"],"names":[],"mappings":";;;AAEA,MAAM,SAAS,GAAG,GAAY,EAAE;IAC/B,IAAI;QACH,OAAO,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,MAAM,CAAC,QAAQ,KAAK,WAAW,CAAC;KAC/E;IAAC,MAAM;QACP,OAAO,KAAK,CAAC;KACb;AACF,CAAC,CAAA;AAwCA,8BAAS;AArCV,MAAM,WAAW,GAAG,GAAY,EAAE;IACjC,IAAI;QACH,OAAO,OAAO,IAAI,KAAK,QAAQ;eAC5B,IAAI,CAAC,WAAW;eAChB,IAAI,CAAC,WAAW,CAAC,IAAI,KAAK,4BAA4B,CAAC;KAC1D;IAAC,MAAM;QACP,OAAO,KAAK,CAAC;KACb;AACF,CAAC,CAAA;AA6BW,kCAAW;AA1BvB,MAAM,MAAM,GAAG,GAAY,EAAE;IAC5B,IAAI;QACH,OAAO,OAAO,OAAO,KAAK,WAAW;eAClC,OAAO,CAAC,QAAQ,IAAI,IAAI;eACxB,OAAO,CAAC,QAAQ,CAAC,IAAI,IAAI,IAAI,CAAC;KACjC;IAAC,MAAM;QACP,OAAO,KAAK,CAAC;KACb;AACF,CAAC,CAAA;AAkBwB,wBAAM;AAX/B,MAAM,OAAO,GAAG,GAAY,EAAE;IAC7B,IAAI;QACH,OAAO,CAAC,OAAO,MAAM,KAAK,WAAW,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ,CAAC;eAC9D,SAAS,CAAC,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC;eACvC,SAAS,CAAC,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;KAC1C;IAAC,MAAM;QACP,OAAO,KAAK,CAAC;KACb;AACF,CAAC,CAAA;AAGgC,0BAAO"} -------------------------------------------------------------------------------- /lib/utils/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.generateOmniboltUri = exports.parseOmniboltUri = exports.sleep = exports.promiseTimeout = exports.accMul = exports.signP2SH = exports.generateFundingAddress = exports.signP2PKH = exports.getPrivateKey = exports.getScriptHash = exports.getAddress = exports.getNextOmniboltAddress = void 0; 4 | const result_1 = require("../result"); 5 | const networks_1 = require("./networks"); 6 | const bitcoin = require('bitcoinjs-lib'); 7 | const bip39 = require('bip39'); 8 | const bip32 = require('bip32'); 9 | exports.getNextOmniboltAddress = async ({ selectedNetwork, addressIndex, mnemonic, }) => { 10 | let index = 0; 11 | if (addressIndex && 12 | addressIndex?.index >= 0 && 13 | addressIndex?.path?.length > 0) { 14 | index = addressIndex.index + 1; 15 | } 16 | const coinType = selectedNetwork === 'bitcoinTestnet' ? '1' : '0'; 17 | const addressPath = `m/44'/${coinType}'/2'/0/${index}`; 18 | const seed = bip39.mnemonicToSeedSync(mnemonic, ''); 19 | const network = networks_1.networks[selectedNetwork]; 20 | const root = bip32.fromSeed(seed, network); 21 | const addressKeypair = root.derivePath(addressPath); 22 | const address = exports.getAddress({ 23 | keyPair: addressKeypair, 24 | network, 25 | }); 26 | const scriptHash = exports.getScriptHash(address, network); 27 | return result_1.ok({ 28 | index, 29 | path: addressPath, 30 | address, 31 | scriptHash, 32 | publicKey: addressKeypair.publicKey.toString('hex'), 33 | }); 34 | }; 35 | exports.getAddress = ({ keyPair = undefined, network = undefined, type = 'legacy', }) => { 36 | if (!keyPair || !network) { 37 | return ''; 38 | } 39 | try { 40 | switch (type) { 41 | case 'bech32': 42 | return bitcoin.payments.p2wpkh({ pubkey: keyPair.publicKey, network }) 43 | .address; 44 | case 'segwit': 45 | return bitcoin.payments.p2sh({ 46 | redeem: bitcoin.payments.p2wpkh({ 47 | pubkey: keyPair.publicKey, 48 | network, 49 | }), 50 | network, 51 | }).address; 52 | case 'legacy': 53 | return bitcoin.payments.p2pkh({ pubkey: keyPair.publicKey, network }) 54 | .address; 55 | } 56 | return ''; 57 | } 58 | catch { 59 | return ''; 60 | } 61 | }; 62 | exports.getScriptHash = (address = '', network = networks_1.networks.bitcoin) => { 63 | try { 64 | if (!address || !network) { 65 | return ''; 66 | } 67 | if (typeof network === 'string' && network in networks_1.networks) { 68 | network = networks_1.networks[network]; 69 | } 70 | const script = bitcoin.address.toOutputScript(address, network); 71 | let hash = bitcoin.crypto.sha256(script); 72 | const reversedHash = Buffer.from(hash.reverse()); 73 | return reversedHash.toString('hex'); 74 | } 75 | catch { 76 | return ''; 77 | } 78 | }; 79 | exports.getPrivateKey = async ({ addressData, selectedNetwork = 'bitcoin', mnemonic, }) => { 80 | try { 81 | if (!addressData) { 82 | return result_1.err('No addressContent specified.'); 83 | } 84 | if (!mnemonic) { 85 | return result_1.err('No mnemonic phrase specified.'); 86 | } 87 | const network = networks_1.networks[selectedNetwork]; 88 | const bip39Passphrase = ''; 89 | const seed = bip39.mnemonicToSeedSync(mnemonic, bip39Passphrase); 90 | const root = bip32.fromSeed(seed, network); 91 | const addressPath = addressData.path; 92 | const addressKeypair = root.derivePath(addressPath); 93 | return result_1.ok(addressKeypair.toWIF()); 94 | } 95 | catch (e) { 96 | return result_1.err(e); 97 | } 98 | }; 99 | exports.signP2PKH = ({ txhex, privkey, inputs, selectedNetwork = 'bitcoin' }) => { 100 | if (txhex === '') 101 | return ''; 102 | const network = networks_1.networks[selectedNetwork]; 103 | const tx = bitcoin.Transaction.fromHex(txhex); 104 | const txb = bitcoin.TransactionBuilder.fromTransaction(tx, network); 105 | const key = bitcoin.ECPair.fromWIF(privkey, network); 106 | for (let i = 0; i < inputs.length; i++) { 107 | txb.sign({ 108 | prevOutScriptType: 'p2pkh', 109 | vin: i, 110 | keyPair: key, 111 | }); 112 | } 113 | return txb.build().toHex(); 114 | }; 115 | exports.generateFundingAddress = async ({ index = 0, mnemonic, selectedNetwork, }) => { 116 | const coinType = selectedNetwork === 'bitcoinTestnet' ? '1' : '0'; 117 | const addressPath = `m/44'/${coinType}'/0'/0/${index}`; 118 | const seed = bip39.mnemonicToSeedSync(mnemonic, ''); 119 | const network = networks_1.networks[selectedNetwork]; 120 | const root = bip32.fromSeed(seed, network); 121 | const addressKeypair = root.derivePath(addressPath); 122 | const address = exports.getAddress({ 123 | keyPair: addressKeypair, 124 | network, 125 | }); 126 | const scriptHash = exports.getScriptHash(address, network); 127 | return result_1.ok({ 128 | index, 129 | path: addressPath, 130 | address, 131 | scriptHash, 132 | publicKey: addressKeypair.publicKey.toString('hex'), 133 | }); 134 | }; 135 | exports.signP2SH = async ({ is_first_sign, txhex, pubkey_1, pubkey_2, privkey, inputs, selectedNetwork = 'bitcoin', }) => { 136 | if (txhex === '') { 137 | return ''; 138 | } 139 | const network = networks_1.networks[selectedNetwork]; 140 | const tx = bitcoin.Transaction.fromHex(txhex); 141 | const txb = bitcoin.TransactionBuilder.fromTransaction(tx, network); 142 | const pubkeys = [pubkey_1, pubkey_2].map((hex) => Buffer.from(hex, 'hex')); 143 | const p2ms = bitcoin.payments.p2ms({ m: 2, pubkeys, network }); 144 | const p2sh = bitcoin.payments.p2sh({ redeem: p2ms, network }); 145 | const key = bitcoin.ECPair.fromWIF(privkey, network); 146 | for (let i = 0; i < inputs.length; i++) { 147 | let amount = exports.accMul(inputs[i].amount, 100000000); 148 | txb.sign(i, key, p2sh.redeem.output, undefined, amount, undefined); 149 | } 150 | if (is_first_sign === true) { 151 | let firstHex = txb.buildIncomplete().toHex(); 152 | console.info('First signed - Hex => ' + firstHex); 153 | return firstHex; 154 | } 155 | else { 156 | let finalHex = txb.build().toHex(); 157 | console.info('signP2SH - Second signed - Hex = ' + finalHex); 158 | return finalHex; 159 | } 160 | }; 161 | exports.accMul = (arg1, arg2) => { 162 | let m = 0, s1 = arg1.toString(), s2 = arg2.toString(); 163 | try { 164 | m += s1.split('.')[1].length; 165 | } 166 | catch (e) { } 167 | try { 168 | m += s2.split('.')[1].length; 169 | } 170 | catch (e) { } 171 | return ((Number(s1.replace('.', '')) * Number(s2.replace('.', ''))) / 172 | Math.pow(10, m)); 173 | }; 174 | exports.promiseTimeout = (ms, promise) => { 175 | let id; 176 | let timeout = new Promise((resolve) => { 177 | id = setTimeout(() => { 178 | resolve(result_1.err('Timed Out.')); 179 | }, ms); 180 | }); 181 | return Promise.race([promise, timeout]).then((result) => { 182 | clearTimeout(id); 183 | try { 184 | if (result?.isErr()) { 185 | return result_1.err(result?.error?.message); 186 | } 187 | } 188 | catch (e) { 189 | return result_1.err(e); 190 | } 191 | return result; 192 | }); 193 | }; 194 | exports.sleep = (ms = 1000) => { 195 | return new Promise((resolve) => setTimeout(resolve, ms)); 196 | }; 197 | exports.parseOmniboltUri = (uri) => { 198 | try { 199 | if (!uri) { 200 | return result_1.err('No URI provided.'); 201 | } 202 | let action; 203 | const isOmniboltUri = uri.substr(0, 9) === 'omnibolt:'; 204 | if (!isOmniboltUri) 205 | return result_1.err('This is not an omnibolt uri.'); 206 | uri = uri.substr(9, uri.length); 207 | const actionIndex = uri.indexOf(':'); 208 | action = uri.substr(0, actionIndex); 209 | const data = JSON.parse(uri.substr(actionIndex + 1, uri.length)); 210 | return result_1.ok({ 211 | action, 212 | data, 213 | }); 214 | } 215 | catch (e) { 216 | return result_1.err(e); 217 | } 218 | }; 219 | exports.generateOmniboltUri = ({ action, data }) => { 220 | try { 221 | if (!action || !data) 222 | return result_1.err('Unable to generate omnibolt uri.'); 223 | if (typeof data !== 'string') { 224 | data = JSON.stringify(data); 225 | } 226 | return result_1.ok(`omnibolt:${action}:${data}`); 227 | } 228 | catch (e) { 229 | return result_1.err(e); 230 | } 231 | }; 232 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /lib/utils/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;AAKA,sCAA4C;AAU5C,yCAAgD;AAEhD,MAAM,OAAO,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;AACzC,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAC/B,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AASlB,QAAA,sBAAsB,GAAG,KAAK,EAAE,EAC5C,eAAe,EACf,YAAY,EACZ,QAAQ,GAKR,EAAoC,EAAE;IACtC,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IACC,YAAY;QACV,YAAY,EAAE,KAAK,IAAI,CAAC;QACxB,YAAY,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,EAC/B;QACD,KAAK,GAAG,YAAY,CAAC,KAAK,GAAG,CAAC,CAAC;KAC/B;IAED,MAAM,QAAQ,GAAG,eAAe,KAAK,gBAAgB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;IAClE,MAAM,WAAW,GAAG,SAAS,QAAQ,UAAU,KAAK,EAAE,CAAC;IACvD,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AAE,CAAC;YACT,MAAM;YACN,IAAI;SACJ,CAAC,CAAC;KACH;IAAC,OAAO,CAAC,EAAE;QACX,OAAO,YAAG,CAAC,CAAC,CAAC,CAAC;KACd;AACF,CAAC,CAAC;AAQW,QAAA,mBAAmB,GAAG,CAAC,EAAE,MAAM,EAAE,IAAI,EAAwB,EAAkB,EAAE;IAC7F,IAAI;QACH,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI;YAAE,OAAO,YAAG,CAAC,kCAAkC,CAAC,CAAC;QACrE,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;YAC7B,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;SAC5B;QACD,OAAO,WAAE,CAAC,YAAY,MAAM,IAAI,IAAI,EAAE,CAAC,CAAC;KACxC;IAAC,OAAO,CAAC,EAAE;QACX,OAAO,YAAG,CAAC,CAAC,CAAC,CAAC;KACd;AACF,CAAC,CAAC"} -------------------------------------------------------------------------------- /lib/utils/networks.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.networks = exports.EAvailableNetworks = void 0; 4 | var EAvailableNetworks; 5 | (function (EAvailableNetworks) { 6 | EAvailableNetworks["bitcoin"] = "bitcoin"; 7 | EAvailableNetworks["bitcoinTestnet"] = "bitcoinTestnet"; 8 | })(EAvailableNetworks = exports.EAvailableNetworks || (exports.EAvailableNetworks = {})); 9 | exports.networks = { 10 | bitcoin: { 11 | messagePrefix: '\x18Bitcoin Signed Message:\n', 12 | bech32: 'bc', 13 | bip32: { 14 | public: 0x0488b21e, 15 | private: 0x0488ade4, 16 | }, 17 | pubKeyHash: 0x00, 18 | scriptHash: 0x05, 19 | wif: 0x80, 20 | }, 21 | bitcoinTestnet: { 22 | messagePrefix: '\x18Bitcoin Signed Message:\n', 23 | bech32: 'tb', 24 | bip32: { 25 | public: 0x043587cf, 26 | private: 0x04358394, 27 | }, 28 | pubKeyHash: 0x6f, 29 | scriptHash: 0xc4, 30 | wif: 0xef, 31 | }, 32 | }; 33 | //# sourceMappingURL=networks.js.map -------------------------------------------------------------------------------- /lib/utils/networks.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"networks.js","sourceRoot":"","sources":["../../src/utils/networks.ts"],"names":[],"mappings":";;;AAEA,IAAY,kBAGX;AAHD,WAAY,kBAAkB;IAC7B,yCAAmB,CAAA;IACnB,uDAAiC,CAAA;AAClC,CAAC,EAHW,kBAAkB,GAAlB,0BAAkB,KAAlB,0BAAkB,QAG7B;AAsBY,QAAA,QAAQ,GAAc;IAClC,OAAO,EAAE;QACR,aAAa,EAAE,+BAA+B;QAC9C,MAAM,EAAE,IAAI;QACZ,KAAK,EAAE;YACN,MAAM,EAAE,UAAU;YAClB,OAAO,EAAE,UAAU;SACnB;QACD,UAAU,EAAE,IAAI;QAChB,UAAU,EAAE,IAAI;QAChB,GAAG,EAAE,IAAI;KACT;IACD,cAAc,EAAE;QACf,aAAa,EAAE,+BAA+B;QAC9C,MAAM,EAAE,IAAI;QACZ,KAAK,EAAE;YACN,MAAM,EAAE,UAAU;YAClB,OAAO,EAAE,UAAU;SACnB;QACD,UAAU,EAAE,IAAI;QAChB,UAAU,EAAE,IAAI;QAChB,GAAG,EAAE,IAAI;KACT;CACD,CAAC"} -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "omnibolt-js", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "lib/index.js", 6 | "scripts": { 7 | "start": "tsc && node src/index.ts", 8 | "test": "env mocha -r ts-node/register 'tests/**/*.ts'", 9 | "build": "npm run format && tsc", 10 | "format": "prettier --write \"src/*.ts\" \"*.js\"", 11 | "lint": "eslint . --ext .ts,.tsx --fix" 12 | }, 13 | "types": "lib/types/index.d.ts", 14 | "files": [ 15 | "lib/**/*" 16 | ], 17 | "keywords": [ 18 | "bitcoin", 19 | "lightning", 20 | "omnibolt", 21 | "tokens" 22 | ], 23 | "author": "Synonym", 24 | "license": "MIT", 25 | "devDependencies": { 26 | "@types/chai": "^4.3.0", 27 | "@types/mocha": "^9.1.0", 28 | "@types/node": "^17.0.14", 29 | "@typescript-eslint/eslint-plugin": "^4.26.1", 30 | "@typescript-eslint/parser": "^4.26.1", 31 | "chai": "^4.3.6", 32 | "eslint": "^7.14.0", 33 | "mocha": "^9.2.0", 34 | "prettier": "^2.2.0", 35 | "ts-node": "^10.4.0", 36 | "typescript": "^3.9.7", 37 | "ws": "^8.4.2" 38 | }, 39 | "dependencies": { 40 | "bip32": "^2.0.6", 41 | "bip39": "^3.0.4", 42 | "bitcoinjs-lib": "^5.2.0" 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | import ObdApi from './obdapi'; 2 | 3 | export { ObdApi }; 4 | -------------------------------------------------------------------------------- /src/pojo.ts: -------------------------------------------------------------------------------- 1 | export class Message { 2 | type: number = 0; 3 | data: object | string | number = {}; 4 | recipient_user_peer_id: string = ''; 5 | recipient_node_peer_id: string = ''; 6 | } 7 | 8 | export class BtcFundingInfo { 9 | from_address: string = ''; 10 | to_address: string = ''; 11 | amount: number = 0.0; 12 | miner_fee: number = 0.0; 13 | } 14 | 15 | export class FundingBtcCreated { 16 | temporary_channel_id: string = ''; 17 | funding_tx_hex: string = ''; 18 | } 19 | 20 | export class FundingBtcSigned { 21 | temporary_channel_id: string = ''; 22 | funding_txid: string = ''; 23 | signed_miner_redeem_transaction_hex: string = ''; 24 | approval: boolean = false; 25 | } 26 | 27 | export class OmniFundingAssetInfo { 28 | from_address: string = ''; 29 | to_address: string = ''; 30 | property_id: number = 0; 31 | amount: number = 0; 32 | miner_fee: number = 0.0; 33 | } 34 | 35 | export class OmniSendAssetInfo { 36 | from_address: string = ''; 37 | to_address: string = ''; 38 | property_id: number = 0; 39 | amount: number = 0; 40 | } 41 | 42 | export class OpenChannelInfo { 43 | funding_pubkey: string = ''; 44 | //funder_address_index: number = 0; 45 | is_private: boolean = false; 46 | } 47 | 48 | export class AcceptChannelInfo { 49 | temporary_channel_id: string = ''; 50 | funding_pubkey: string = ''; 51 | //fundee_address_index: number = 0; 52 | approval: boolean = false; 53 | } 54 | 55 | export class AssetFundingCreatedInfo { 56 | temporary_channel_id: string = ''; 57 | funding_tx_hex: string = ''; 58 | temp_address_pub_key: string = ''; 59 | temp_address_index: number = 0; 60 | // temp_address_private_key: string = ""; 61 | // channel_address_private_key: string = ""; 62 | } 63 | 64 | export class AssetFundingSignedInfo { 65 | temporary_channel_id: string = ''; 66 | signed_alice_rsmc_hex: string = ''; 67 | } 68 | 69 | export class SignedInfo101035 { 70 | temporary_channel_id: string = ''; 71 | rd_signed_hex: string = ''; 72 | br_signed_hex: string = ''; 73 | br_id: number = 0; 74 | } 75 | 76 | export class SignedInfo101134 { 77 | channel_id: string = ''; 78 | rd_signed_hex: string = ''; 79 | } 80 | 81 | export class SignedInfo100360 { 82 | channel_id: string = ''; 83 | rsmc_signed_hex: string = ''; 84 | counterparty_signed_hex: string = ''; 85 | } 86 | 87 | export class SignedInfo100361 { 88 | channel_id: string = ''; 89 | c2b_rsmc_signed_hex: string = ''; 90 | c2b_counterparty_signed_hex: string = ''; 91 | c2a_rd_signed_hex: string = ''; 92 | c2a_br_signed_hex: string = ''; 93 | c2a_br_id: number = 0; 94 | } 95 | 96 | export class SignedInfo100362 { 97 | channel_id: string = ''; 98 | c2b_rsmc_signed_hex: string = ''; 99 | c2b_counterparty_signed_hex: string = ''; 100 | c2a_rd_signed_hex: string = ''; 101 | } 102 | 103 | export class SignedInfo100363 { 104 | channel_id: string = ''; 105 | c2b_rd_signed_hex: string = ''; 106 | c2b_br_signed_hex: string = ''; 107 | c2b_br_id: number = 0; 108 | } 109 | 110 | export class SignedInfo100364 { 111 | channel_id: string = ''; 112 | c2b_rd_signed_hex: string = ''; 113 | } 114 | 115 | export class SignedInfo100100 { 116 | channel_id: string = ''; 117 | c3a_counterparty_partial_signed_hex: string = ''; 118 | c3a_htlc_partial_signed_hex: string = ''; 119 | c3a_rsmc_partial_signed_hex: string = ''; 120 | } 121 | 122 | export class SignedInfo100101 { 123 | channel_id: string = ''; 124 | c3a_rsmc_rd_partial_signed_hex: string = ''; 125 | c3a_rsmc_br_partial_signed_hex: string = ''; 126 | c3a_htlc_ht_partial_signed_hex: string = ''; 127 | c3a_htlc_hlock_partial_signed_hex: string = ''; 128 | c3a_htlc_br_partial_signed_hex: string = ''; 129 | c3b_rsmc_partial_signed_hex: string = ''; 130 | c3b_counterparty_partial_signed_hex: string = ''; 131 | c3b_htlc_partial_signed_hex: string = ''; 132 | } 133 | 134 | export class SignedInfo100102 { 135 | channel_id: string = ''; 136 | c3a_rsmc_rd_complete_signed_hex: string = ''; 137 | c3a_htlc_ht_complete_signed_hex: string = ''; 138 | c3a_htlc_hlock_complete_signed_hex: string = ''; 139 | c3b_rsmc_complete_signed_hex: string = ''; 140 | c3b_counterparty_complete_signed_hex: string = ''; 141 | c3b_htlc_complete_signed_hex: string = ''; 142 | } 143 | 144 | export class SignedInfo100103 { 145 | channel_id: string = ''; 146 | c3a_htlc_htrd_partial_signed_hex: string = ''; 147 | c3b_rsmc_rd_partial_signed_hex: string = ''; 148 | c3b_rsmc_br_partial_signed_hex: string = ''; 149 | c3b_htlc_htd_partial_signed_hex: string = ''; 150 | c3b_htlc_hlock_partial_signed_hex: string = ''; 151 | c3b_htlc_br_partial_signed_hex: string = ''; 152 | } 153 | 154 | export class SignedInfo100104 { 155 | channel_id: string = ''; 156 | curr_htlc_temp_address_for_he_pub_key: string = ''; 157 | curr_htlc_temp_address_for_he_index: number = 0; 158 | c3a_htlc_htrd_complete_signed_hex: string = ''; 159 | c3a_htlc_htbr_partial_signed_hex: string = ''; 160 | c3a_htlc_hed_partial_signed_hex: string = ''; 161 | c3b_rsmc_rd_complete_signed_hex: string = ''; 162 | c3b_htlc_htd_complete_signed_hex: string = ''; 163 | c3b_htlc_hlock_complete_signed_hex: string = ''; 164 | } 165 | 166 | export class SignedInfo100105 { 167 | channel_id: string = ''; 168 | c3b_htlc_hlock_he_partial_signed_hex: string = ''; 169 | } 170 | 171 | export class SignedInfo100106 { 172 | channel_id: string = ''; 173 | c3b_htlc_herd_partial_signed_hex: string = ''; 174 | } 175 | 176 | export class SignedInfo100110 { 177 | channel_id: string = ''; 178 | counterparty_partial_signed_hex: string = ''; 179 | rsmc_partial_signed_hex: string = ''; 180 | } 181 | 182 | export class SignedInfo100111 { 183 | channel_id: string = ''; 184 | c4a_rd_signed_hex: string = ''; 185 | c4a_br_signed_hex: string = ''; 186 | c4a_br_id: string = ''; 187 | c4b_rsmc_signed_hex: string = ''; 188 | c4b_counterparty_signed_hex: string = ''; 189 | } 190 | 191 | export class SignedInfo100112 { 192 | channel_id: string = ''; 193 | c4a_rd_complete_signed_hex: string = ''; 194 | c4b_rsmc_complete_signed_hex: string = ''; 195 | c4b_counterparty_complete_signed_hex: string = ''; 196 | } 197 | 198 | export class SignedInfo100113 { 199 | channel_id: string = ''; 200 | c4b_rd_partial_signed_hex: string = ''; 201 | c4b_br_partial_signed_hex: string = ''; 202 | c4b_br_id: string = ''; 203 | } 204 | 205 | export class SignedInfo100114 { 206 | channel_id: string = ''; 207 | c4b_rd_complete_signed_hex: string = ''; 208 | } 209 | 210 | export class CommitmentTx { 211 | channel_id: string = ''; 212 | amount: number = 0; 213 | curr_temp_address_pub_key: string = ''; 214 | curr_temp_address_index: number = 0; 215 | last_temp_address_private_key: string = ''; 216 | } 217 | 218 | export class CommitmentTxSigned { 219 | channel_id: string = ''; 220 | msg_hash: string = ''; 221 | c2a_rsmc_signed_hex: string = ''; 222 | c2a_counterparty_signed_hex: string = ''; 223 | curr_temp_address_pub_key: string = ''; 224 | curr_temp_address_index: number = 0; 225 | last_temp_address_private_key: string = ''; 226 | approval: boolean = false; 227 | } 228 | 229 | export class InvoiceInfo { 230 | property_id: number = 0; 231 | amount: number = 0; 232 | h: string = ''; 233 | expiry_time: string = ''; 234 | description: string = ''; 235 | is_private: boolean = false; 236 | } 237 | 238 | export class HTLCFindPathInfo extends InvoiceInfo { 239 | invoice: string = ''; 240 | recipient_node_peer_id: string = ''; 241 | recipient_user_peer_id: string = ''; 242 | is_inv_pay: boolean = false; 243 | } 244 | 245 | export class addHTLCInfo { 246 | recipient_user_peer_id: string = ''; 247 | property_id: number = 0; 248 | amount: number = 0; 249 | memo: string = ''; 250 | h: string = ''; 251 | routing_packet: string = ''; 252 | cltv_expiry: number = 0; 253 | // channel_address_private_key: string = ""; 254 | last_temp_address_private_key: string = ''; 255 | curr_rsmc_temp_address_pub_key: string = ''; 256 | // curr_rsmc_temp_address_private_key: string = ""; 257 | curr_rsmc_temp_address_index: number = 0; 258 | curr_htlc_temp_address_pub_key: string = ''; 259 | // curr_htlc_temp_address_private_key: string = ""; 260 | curr_htlc_temp_address_index: number = 0; 261 | curr_htlc_temp_address_for_ht1a_pub_key: string = ''; 262 | // curr_htlc_temp_address_for_ht1a_private_key: string = ""; 263 | curr_htlc_temp_address_for_ht1a_index: number = 0; 264 | } 265 | 266 | export class HtlcSignedInfo { 267 | payer_commitment_tx_hash: string = ''; 268 | curr_rsmc_temp_address_pub_key: string = ''; 269 | curr_rsmc_temp_address_index: number = 0; 270 | curr_htlc_temp_address_pub_key: string = ''; 271 | curr_htlc_temp_address_index: number = 0; 272 | last_temp_address_private_key: string = ''; 273 | 274 | c3a_complete_signed_rsmc_hex: string = ''; 275 | c3a_complete_signed_counterparty_hex: string = ''; 276 | c3a_complete_signed_htlc_hex: string = ''; 277 | // channel_address_private_key: string = ""; 278 | // curr_rsmc_temp_address_private_key: string = ""; 279 | // curr_htlc_temp_address_private_key: string = ""; 280 | // approval: boolean = false; 281 | } 282 | 283 | export class SignGetHInfo { 284 | request_hash: string = ''; 285 | channel_address_private_key: string = ''; 286 | last_temp_address_private_key: string = ''; 287 | curr_rsmc_temp_address_pub_key: string = ''; 288 | curr_rsmc_temp_address_private_key: string = ''; 289 | curr_htlc_temp_address_pub_key: string = ''; 290 | curr_htlc_temp_address_private_key: string = ''; 291 | approval: boolean = false; 292 | } 293 | 294 | export class HtlcRequestOpen { 295 | request_hash: string = ''; 296 | channel_address_private_key: string = ''; 297 | last_temp_address_private_key: string = ''; 298 | curr_rsmc_temp_address_pub_key: string = ''; 299 | curr_rsmc_temp_address_private_key: string = ''; 300 | curr_htlc_temp_address_pub_key: string = ''; 301 | curr_htlc_temp_address_private_key: string = ''; 302 | curr_htlc_temp_address_for_ht1a_pub_key: string = ''; 303 | curr_htlc_temp_address_for_ht1a_private_key: string = ''; 304 | } 305 | 306 | export class ForwardRInfo { 307 | channel_id: string = ''; 308 | r: string = ''; 309 | } 310 | 311 | export class SignRInfo { 312 | channel_id: string = ''; 313 | c3b_htlc_herd_complete_signed_hex: string = ''; 314 | c3b_htlc_hebr_partial_signed_hex: string = ''; 315 | // msg_hash: string = ""; 316 | // r: string = ""; 317 | // channel_address_private_key: string = ""; 318 | } 319 | 320 | export class CloseHtlcTxInfo { 321 | channel_id: string = ''; 322 | last_rsmc_temp_address_private_key: string = ''; 323 | last_htlc_temp_address_private_key: string = ''; 324 | last_htlc_temp_address_for_htnx_private_key: string = ''; 325 | curr_temp_address_pub_key: string = ''; 326 | curr_temp_address_index: number = 0; 327 | } 328 | 329 | export class CloseHtlcTxInfoSigned { 330 | msg_hash: string = ''; 331 | last_rsmc_temp_address_private_key: string = ''; 332 | last_htlc_temp_address_private_key: string = ''; 333 | last_htlc_temp_address_for_htnx_private_key: string = ''; 334 | curr_temp_address_pub_key: string = ''; 335 | curr_temp_address_index: number = 0; 336 | } 337 | 338 | export class IssueManagedAmoutInfo { 339 | from_address: string = ''; 340 | name: string = ''; 341 | ecosystem: number = 0; 342 | divisible_type: number = 0; 343 | data: string = ''; 344 | } 345 | 346 | export class IssueFixedAmountInfo extends IssueManagedAmoutInfo { 347 | amount: number = 0; 348 | } 349 | 350 | export class OmniSendGrant { 351 | from_address: string = ''; 352 | property_id: number = 0; 353 | amount: number = 0; 354 | memo: string = ''; 355 | } 356 | 357 | export class OmniSendRevoke extends OmniSendGrant {} 358 | 359 | export class CloseChannelSign { 360 | channel_id: string = ''; 361 | request_close_channel_hash: string = ''; 362 | approval: boolean = false; 363 | } 364 | 365 | /** 366 | * -80 367 | */ 368 | export class AtomicSwapRequest { 369 | channel_id_from: string = ''; 370 | channel_id_to: string = ''; 371 | recipient_user_peer_id: string = ''; 372 | property_sent: number = 0; 373 | amount: number = 0; 374 | exchange_rate: number = 0; 375 | property_received: number = 0; 376 | transaction_id: string = ''; 377 | time_locker: number = 0; 378 | } 379 | 380 | /** 381 | * -81 382 | */ 383 | export class AtomicSwapAccepted extends AtomicSwapRequest { 384 | target_transaction_id: string = ''; 385 | } 386 | 387 | /** 388 | * MsgType_p2p_ConnectPeer_2003 389 | */ 390 | export class P2PPeer { 391 | remote_node_address: string = ''; 392 | } 393 | 394 | export class MessageType { 395 | MsgType_Error_0 = 0; 396 | 397 | MsgType_UserLogin_2001 = -102001; 398 | MsgType_UserLogout_2002 = -102002; 399 | MsgType_p2p_ConnectPeer_2003 = -102003; 400 | MsgType_GetMnemonic_2004 = -102004; 401 | 402 | MsgType_GetMiniBtcFundAmount_2006 = -102006; 403 | 404 | MsgType_Core_GetNewAddress_2101 = -102101; 405 | MsgType_Core_GetMiningInfo_2102 = -102102; 406 | MsgType_Core_GetNetworkInfo_2103 = -102103; 407 | MsgType_Core_SignMessageWithPrivKey_2104 = -102104; 408 | MsgType_Core_VerifyMessage_2105 = -102105; 409 | MsgType_Core_DumpPrivKey_2106 = -102106; 410 | MsgType_Core_ListUnspent_2107 = -102107; 411 | MsgType_Core_BalanceByAddress_2108 = -102108; 412 | MsgType_Core_FundingBTC_2109 = -102109; 413 | MsgType_Core_BtcCreateMultiSig_2110 = -102110; 414 | MsgType_Core_Btc_ImportPrivKey_2111 = -102111; 415 | MsgType_Core_Omni_Getbalance_2112 = -102112; 416 | MsgType_Core_Omni_CreateNewTokenFixed_2113 = -102113; 417 | MsgType_Core_Omni_CreateNewTokenManaged_2114 = -102114; 418 | MsgType_Core_Omni_GrantNewUnitsOfManagedToken_2115 = -102115; 419 | MsgType_Core_Omni_RevokeUnitsOfManagedToken_2116 = -102116; 420 | MsgType_Core_Omni_ListProperties_2117 = -102117; 421 | MsgType_Core_Omni_GetTransaction_2118 = -102118; 422 | MsgType_Core_Omni_GetProperty_2119 = -102119; 423 | MsgType_Core_Omni_FundingAsset_2120 = -102120; 424 | MsgType_Core_Omni_Send_2121 = -102121; 425 | 426 | MsgType_Mnemonic_CreateAddress_3000 = -103000; 427 | MsgType_Mnemonic_GetAddressByIndex_3001 = -103001; 428 | MsgType_FundingCreate_Asset_AllItem_3100 = -103100; 429 | MsgType_FundingCreate_Asset_ItemById_3101 = -103101; 430 | MsgType_FundingCreate_Asset_ItemByChannelId_3102 = -103102; 431 | MsgType_FundingCreate_Asset_Count_3103 = -103103; 432 | 433 | MsgType_SendChannelOpen_32 = -100032; 434 | MsgType_RecvChannelOpen_32 = -110032; 435 | MsgType_SendChannelAccept_33 = -100033; 436 | MsgType_RecvChannelAccept_33 = -110033; 437 | 438 | MsgType_FundingCreate_SendAssetFundingCreated_34 = -100034; 439 | MsgType_FundingCreate_RecvAssetFundingCreated_34 = -110034; 440 | MsgType_FundingSign_SendAssetFundingSigned_35 = -100035; 441 | MsgType_FundingSign_RecvAssetFundingSigned_35 = -110035; 442 | 443 | MsgType_ClientSign_AssetFunding_AliceSignC1a_1034 = -101034; 444 | MsgType_ClientSign_AssetFunding_AliceSignRD_1134 = -101134; 445 | MsgType_ClientSign_Duplex_AssetFunding_RdAndBr_1035 = -101035; 446 | 447 | MsgType_FundingCreate_SendBtcFundingCreated_340 = -100340; 448 | MsgType_FundingCreate_BtcFundingMinerRDTxToClient_341 = -100341; 449 | MsgType_FundingCreate_RecvBtcFundingCreated_340 = -110340; 450 | MsgType_FundingSign_SendBtcSign_350 = -100350; 451 | MsgType_FundingSign_RecvBtcSign_350 = -110350; 452 | 453 | MsgType_CommitmentTx_SendCommitmentTransactionCreated_351 = -100351; 454 | MsgType_CommitmentTx_RecvCommitmentTransactionCreated_351 = -110351; 455 | MsgType_CommitmentTxSigned_SendRevokeAndAcknowledgeCommitmentTransaction_352 = -100352; 456 | MsgType_CommitmentTxSigned_RecvRevokeAndAcknowledgeCommitmentTransaction_352 = -110352; 457 | 458 | MsgType_ClientSign_BobC2b_Rd_353 = -110353; 459 | MsgType_ClientSign_CommitmentTx_AliceSignC2a_360 = -100360; 460 | MsgType_ClientSign_CommitmentTx_BobSignC2b_361 = -100361; 461 | MsgType_ClientSign_CommitmentTx_AliceSignC2b_362 = -100362; 462 | MsgType_ClientSign_CommitmentTx_AliceSignC2b_Rd_363 = -100363; 463 | MsgType_ClientSign_CommitmentTx_BobSignC2b_Rd_364 = -100364; 464 | 465 | MsgType_ChannelOpen_AllItem_3150 = -103150; 466 | MsgType_ChannelOpen_ItemByTempId_3151 = -103151; 467 | MsgType_ChannelOpen_Count_3152 = -103152; 468 | MsgType_ChannelOpen_DelItemByTempId_3153 = -103153; 469 | MsgType_GetChannelInfoByChannelId_3154 = -103154; 470 | MsgType_GetChannelInfoByDbId_3155 = -103155; 471 | MsgType_CheckChannelAddessExist_3156 = -103156; 472 | 473 | MsgType_CommitmentTx_ItemsByChanId_3200 = -103200; 474 | MsgType_CommitmentTx_ItemById_3201 = -103201; 475 | MsgType_CommitmentTx_Count_3202 = -103202; 476 | MsgType_CommitmentTx_LatestCommitmentTxByChanId_3203 = -103203; 477 | MsgType_CommitmentTx_LatestRDByChanId_3204 = -103204; 478 | MsgType_CommitmentTx_LatestBRByChanId_3205 = -103205; 479 | MsgType_CommitmentTx_SendSomeCommitmentById_3206 = -103206; 480 | MsgType_CommitmentTx_AllRDByChanId_3207 = -103207; 481 | MsgType_CommitmentTx_AllBRByChanId_3208 = -103208; 482 | 483 | MsgType_SendCloseChannelRequest_38 = -100038; 484 | MsgType_RecvCloseChannelRequest_38 = -110038; 485 | MsgType_SendCloseChannelSign_39 = -100039; 486 | MsgType_RecvCloseChannelSign_39 = -110039; 487 | 488 | MsgType_HTLC_FindPath_401 = -100401; 489 | MsgType_HTLC_Invoice_402 = -100402; 490 | MsgType_HTLC_SendAddHTLC_40 = -100040; 491 | MsgType_HTLC_RecvAddHTLC_40 = -110040; 492 | MsgType_HTLC_SendAddHTLCSigned_41 = -100041; 493 | MsgType_HTLC_RecvAddHTLCSigned_41 = -110041; 494 | MsgType_HTLC_BobSignC3bSubTx_42 = -110042; 495 | MsgType_HTLC_FinishTransferH_43 = -110043; 496 | MsgType_HTLC_SendVerifyR_45 = -100045; 497 | MsgType_HTLC_RecvVerifyR_45 = -110045; 498 | MsgType_HTLC_SendSignVerifyR_46 = -100046; 499 | MsgType_HTLC_RecvSignVerifyR_46 = -110046; 500 | MsgType_HTLC_SendRequestCloseCurrTx_49 = -100049; 501 | MsgType_HTLC_RecvRequestCloseCurrTx_49 = -110049; 502 | MsgType_HTLC_SendCloseSigned_50 = -100050; 503 | MsgType_HTLC_RecvCloseSigned_50 = -110050; 504 | MsgType_HTLC_Close_ClientSign_Bob_C4bSub_51 = -110051; 505 | 506 | MsgType_HTLC_ClientSign_Alice_C3a_100 = -100100; 507 | MsgType_HTLC_ClientSign_Bob_C3b_101 = -100101; 508 | MsgType_HTLC_ClientSign_Alice_C3b_102 = -100102; 509 | MsgType_HTLC_ClientSign_Alice_C3bSub_103 = -100103; 510 | MsgType_HTLC_ClientSign_Bob_C3bSub_104 = -100104; 511 | MsgType_HTLC_ClientSign_Alice_He_105 = -100105; 512 | MsgType_HTLC_ClientSign_Bob_HeSub_106 = -100106; 513 | MsgType_HTLC_ClientSign_Alice_HeSub_107 = -100107; 514 | 515 | MsgType_HTLC_Close_ClientSign_Alice_C4a_110 = -100110; 516 | MsgType_HTLC_Close_ClientSign_Bob_C4b_111 = -100111; 517 | MsgType_HTLC_Close_ClientSign_Alice_C4b_112 = -100112; 518 | MsgType_HTLC_Close_ClientSign_Alice_C4bSub_113 = -100113; 519 | MsgType_HTLC_Close_ClientSign_Bob_C4bSubResult_114 = -100114; 520 | 521 | MsgType_Atomic_SendSwap_80 = -100080; 522 | MsgType_Atomic_RecvSwap_80 = -110080; 523 | MsgType_Atomic_SendSwapAccept_81 = -100081; 524 | MsgType_Atomic_RecvSwapAccept_81 = -110081; 525 | } 526 | -------------------------------------------------------------------------------- /src/result.ts: -------------------------------------------------------------------------------- 1 | export type Result = Ok | Err; 2 | 3 | export class Ok { 4 | public constructor(public readonly value: T) {} 5 | 6 | public isOk(): this is Ok { 7 | return true; 8 | } 9 | 10 | public isErr(): this is Err { 11 | return false; 12 | } 13 | } 14 | 15 | export class Err { 16 | public constructor(public readonly error: Error) { 17 | if (error) console.info(error); 18 | } 19 | 20 | public isOk(): this is Ok { 21 | return false; 22 | } 23 | 24 | public isErr(): this is Err { 25 | return true; 26 | } 27 | } 28 | 29 | /** 30 | * Construct a new Ok result value. 31 | */ 32 | export const ok = (value: T): Ok => new Ok(value); 33 | 34 | /** 35 | * Construct a new Err result value. 36 | */ 37 | export const err = (error: Error | string): Err => { 38 | if (typeof error === 'string') { 39 | return new Err(new Error(error)); 40 | } 41 | 42 | return new Err(error); 43 | }; 44 | -------------------------------------------------------------------------------- /src/shapes.ts: -------------------------------------------------------------------------------- 1 | import { IChannelSigningData, IData } from './types'; 2 | 3 | export const addressContent = { 4 | index: 0, 5 | path: '', 6 | address: '', 7 | scriptHash: '', 8 | publicKey: '', 9 | }; 10 | 11 | export const defaultDataShape: IData = { 12 | nextAddressIndex: { 13 | index: 0, 14 | path: '', 15 | address: '', 16 | scriptHash: '', 17 | publicKey: '', 18 | }, 19 | signingData: {}, 20 | checkpoints: {}, 21 | fundingAddresses: {}, 22 | }; 23 | 24 | export const channelSigningData: IChannelSigningData = { 25 | fundingAddress: { ...addressContent }, 26 | addressIndex: { ...addressContent }, 27 | last_temp_address: { ...addressContent }, 28 | rsmc_temp_address: { ...addressContent }, 29 | htlc_temp_address: { ...addressContent }, 30 | htlc_temp_address_for_he1b: { ...addressContent }, 31 | kTbSignedHex: '', 32 | funding_txid: '', 33 | kTempPrivKey: '', 34 | kTbSignedHexCR110351: '', 35 | kTbSignedHexRR110351: '', 36 | kTbTempData: '', 37 | }; 38 | -------------------------------------------------------------------------------- /src/types.ts: -------------------------------------------------------------------------------- 1 | import { ECPairInterface } from 'bitcoinjs-lib'; 2 | 3 | export interface IConnect { 4 | recipient_node_peer_id: string; 5 | recipient_user_peer_id: string; 6 | sender_node_peer_id: string; 7 | sender_user_peer_id: string; 8 | } 9 | 10 | export interface ILogin { 11 | chainNodeType: string; 12 | htlcFeeRate: number; 13 | htlcMaxFee: number; 14 | nodeAddress: string; 15 | nodePeerId: string; 16 | userPeerId: string; 17 | } 18 | 19 | export interface IConnectResponse extends IConnect, ILogin {} 20 | 21 | export interface IOnChannelOpenAttempt { 22 | chain_hash: string; 23 | channel_reserve_satoshis: number; 24 | delayed_payment_base_point: string; 25 | dust_limit_satoshis: number; 26 | fee_rate_per_kw: number; 27 | funder_address_index: number; 28 | funder_node_address: string; 29 | funder_peer_id: string; 30 | funding_address: string; 31 | funding_pubkey: string; 32 | funding_satoshis: number; 33 | htlc_base_point: string; 34 | htlc_minimum_msat: number; 35 | is_private: boolean; 36 | length: number; 37 | max_accepted_htlcs: number; 38 | max_htlc_value_in_flight_msat: number; 39 | payment_base_point: string; 40 | push_msat: number; 41 | revocation_base_point: string; 42 | temporary_channel_id: string; 43 | to_self_delay: number; 44 | value: null; 45 | value_type: string; 46 | } 47 | 48 | export type TOnChannelOpenAttempt = IOmniboltResponse; 49 | 50 | export interface IAcceptChannel { 51 | accept_at: string; 52 | address_a: string; 53 | address_b: string; 54 | amount: number; 55 | btc_amount: number; 56 | chain_hash: string; 57 | channel_address: string; 58 | channel_address_redeem_script: string; 59 | channel_address_script_pub_key: string; 60 | channel_id: string; 61 | channel_reserve_satoshis: number; 62 | close_at: string; 63 | create_at: string; 64 | create_by: string; 65 | curr_state: number; 66 | delayed_payment_base_point: string; 67 | dust_limit_satoshis: number; 68 | fee_rate_per_kw: number; 69 | fundee_address_index: number; 70 | funder_address_index: number; 71 | funder_node_address: string; 72 | funder_peer_id: string; 73 | funding_address: string; 74 | funding_pubkey: string; 75 | funding_satoshis: number; 76 | htlc_base_point: string; 77 | htlc_minimum_msat: number; 78 | id: number; 79 | is_private: boolean; 80 | length: number; 81 | max_accepted_htlcs: number; 82 | max_htlc_value_in_flight_msat: number; 83 | payment_base_point: string; 84 | peer_id_a: string; 85 | peer_id_b: string; 86 | property_id: number; 87 | pub_key_a: string; 88 | pub_key_b: string; 89 | push_msat: number; 90 | refuse_reason: string; 91 | revocation_base_point: string; 92 | temporary_channel_id: string; 93 | to_self_delay: number; 94 | value: null; 95 | value_type: string; 96 | } 97 | 98 | export type TOnAcceptChannel = IOmniboltResponse; 99 | 100 | export interface IOnChannelOpen { 101 | data: { 102 | asset_amount: number; 103 | balance_a: number; 104 | balance_b: number; 105 | balance_htlc: number; 106 | btc_amount: number; 107 | btc_funding_times: number; 108 | channel_address: string; 109 | channel_id: string; 110 | create_at: string; 111 | curr_state: number; 112 | is_private: false; 113 | num_updates: number; 114 | peer_ida: string; 115 | peer_idb: string; 116 | property_id: number; 117 | temporary_channel_id: string; 118 | }[]; 119 | } 120 | 121 | export type TOnChannelOpen = IOmniboltResponse; 122 | 123 | export interface IGetMyChannelsData { 124 | asset_amount: number; 125 | balance_a: number; 126 | balance_b: number; 127 | balance_htlc: number; 128 | btc_amount: number; 129 | btc_funding_times: number; 130 | channel_address: string; 131 | channel_id: string; 132 | create_at: string; 133 | curr_state: number; 134 | is_private: boolean; 135 | peer_ida: string; //Initiator of the channel 136 | peer_idb: string; //Recipient of the channel 137 | property_id: number; 138 | temporary_channel_id: string; 139 | } 140 | export interface IGetMyChannels { 141 | data: IGetMyChannelsData[]; 142 | pageNum: number; 143 | pageSize: number; 144 | totalCount: number; 145 | totalPage: number; 146 | } 147 | 148 | export interface IFundingInputs { 149 | amount: number; 150 | scriptPubKey: string; 151 | txid: string; 152 | vout: number; 153 | } 154 | 155 | export interface IFundingCreatedInputs extends IFundingInputs { 156 | redeemScript: string; 157 | } 158 | 159 | export interface IFundingBitcoin { 160 | hex: string; 161 | inputs: IFundingInputs[]; 162 | is_multisig: boolean; 163 | total_in_amount: number; 164 | } 165 | 166 | export interface IBitcoinFundingCreated { 167 | hex: string; 168 | inputs: { 169 | amount: number; //In BTC 170 | redeemScript: string; 171 | scriptPubKey: string; 172 | txid: string; 173 | vout: number; 174 | }[]; 175 | is_multisig: boolean; 176 | pub_key_a: string; 177 | pub_key_b: string; 178 | temporary_channel_id: string; 179 | total_in_amount: number; 180 | total_out_amount: number; 181 | } 182 | 183 | export interface IInputs { 184 | amount: number; //In BTC 185 | redeemScript: string; 186 | scriptPubKey: string; 187 | sequence: number; 188 | txid: string; 189 | vout: number; 190 | } 191 | export interface IListening110035 { 192 | channel_id: string; 193 | hex: string; 194 | inputs: IInputs[]; 195 | is_multisig: boolean; 196 | pub_key_a: string; 197 | pub_key_b: string; 198 | temporary_channel_id: string; 199 | to_peer_id: string; 200 | } 201 | 202 | export interface IOnBitcoinFundingCreated { 203 | funder_node_address: string; 204 | funder_peer_id: string; 205 | funding_btc_hex: string; 206 | funding_redeem_hex: string; 207 | funding_txid: string; 208 | sign_data: { 209 | hex: string; 210 | inputs: IFundingCreatedInputs[]; 211 | is_multisig: boolean; 212 | pub_key_a: string; 213 | pub_key_b: string; 214 | temporary_channel_id: string; 215 | total_in_amount: number; 216 | total_out_amount: number; 217 | }; 218 | } 219 | 220 | export type TOnBitcoinFundingCreated = IOmniboltResponse; 221 | 222 | export interface ISendSignedHex101034 extends IOnAssetFundingCreated {} 223 | export interface IOnAssetFundingCreated { 224 | c1a_rsmc_hex: string; 225 | channel_id: string; 226 | funder_node_address: string; 227 | funder_peer_id: string; 228 | funding_omni_hex: string; 229 | rsmc_temp_address_pub_key: string; 230 | sign_data: { 231 | hex: string; 232 | inputs: { 233 | amount: number; 234 | redeemScript: string; 235 | scriptPubKey: string; 236 | txid: string; 237 | vout: number; 238 | }[]; 239 | is_multisig: boolean; 240 | pub_key_a: string; 241 | pub_key_b: string; 242 | temporary_channel_id: string; 243 | total_in_amount: number; 244 | total_out_amount: number; 245 | }; 246 | temporary_channel_id: string; 247 | to_peer_id: string; 248 | } 249 | 250 | export type TOnAssetFundingCreated = IOmniboltResponse; 251 | 252 | export interface ISendSignedHex100341 { 253 | signed_hex: string; 254 | } 255 | 256 | export interface IBitcoinFundingSigned { 257 | approval: true; 258 | funding_redeem_hex: string; 259 | funding_txid: string; 260 | temporary_channel_id: string; 261 | } 262 | 263 | export interface IAssetFundingSigned { 264 | alice_br_sign_data: { 265 | br_id: number; 266 | hex: string; 267 | inputs: IFundingInputs[]; 268 | is_multisig: boolean; 269 | pub_key_a: string; 270 | pub_key_b: string; 271 | }; 272 | alice_rd_sign_data: { 273 | hex: string; 274 | inputs: IFundingInputs[]; 275 | is_multisig: true; 276 | pub_key_a: string; 277 | pub_key_b: string; 278 | }; 279 | temporary_channel_id: string; 280 | } 281 | 282 | export interface ISendSignedHex101035 { 283 | channel_id: string; 284 | } 285 | 286 | export type TSendSignedHex101035 = ISendSignedHex101035; 287 | 288 | export interface ICounterpartyRawData { 289 | hex: string; 290 | inputs: { 291 | amount: number; 292 | redeemScript: string; 293 | scriptPubKey: string; 294 | txid: string; 295 | vout: number; 296 | }[]; 297 | is_multisig: true; 298 | private_key: string; 299 | pub_key_a: string; 300 | pub_key_b: string; 301 | } 302 | 303 | export interface IRSMCRawData { 304 | hex: string; 305 | inputs: { 306 | amount: number; 307 | redeemScript: string; 308 | scriptPubKey: string; 309 | txid: string; 310 | vout: number; 311 | }[]; 312 | is_multisig: false; 313 | private_key: string; 314 | pub_key_a: string; 315 | pub_key_b: string; 316 | } 317 | 318 | export interface ICommitmentTransactionCreated { 319 | channel_id: string; 320 | counterparty_raw_data: ICounterpartyRawData; 321 | rsmc_raw_data: IRSMCRawData; 322 | } 323 | 324 | export interface IOnCommitmentTransactionCreated { 325 | amount: number; 326 | amount_a: number; 327 | amount_b: number; 328 | channel_id: string; 329 | commitment_tx_hash: string; 330 | counterparty_raw_data: ICounterpartyRawData; 331 | curr_temp_address_pub_key: string; 332 | last_temp_address_private_key: string; 333 | length: number; 334 | msg_hash: string; 335 | payer_node_address: string; 336 | payer_peer_id: string; 337 | rsmc_raw_data: IRSMCRawData; 338 | to_peer_id: string; 339 | value: null; 340 | value_type: string; 341 | } 342 | 343 | export type TOnCommitmentTransactionCreated = IOmniboltResponse; 344 | 345 | export interface ICommitmentInputs { 346 | amount: number; 347 | redeemScript: string; 348 | scriptPubKey: string; 349 | txid: string; 350 | vout: number; 351 | } 352 | 353 | export interface ICommitmentSequenceInputs extends ICommitmentInputs { 354 | sequence: number; 355 | } 356 | 357 | export interface ICommitmentTransactionAcceptedResponse { 358 | c2a_br_raw_data: { 359 | br_id: number; 360 | hex: string; 361 | inputs: ICommitmentInputs[]; 362 | is_multisig: boolean; 363 | //private_key?: string; 364 | pub_key_a: string; 365 | pub_key_b: string; 366 | }; 367 | c2a_rd_raw_data: { 368 | hex: string; 369 | inputs: ICommitmentSequenceInputs[]; 370 | is_multisig: boolean; 371 | //private_key?: string; 372 | pub_key_a: string; 373 | pub_key_b: string; 374 | }; 375 | c2b_counterparty_raw_data: { 376 | hex: string; 377 | inputs: ICommitmentInputs[]; 378 | is_multisig: boolean; 379 | //private_key?: string; 380 | pub_key_a: string; 381 | pub_key_b: string; 382 | }; 383 | c2b_rsmc_raw_data: { 384 | hex: string; 385 | inputs: ICommitmentInputs[]; 386 | is_multisig: boolean; 387 | //private_key?: string; 388 | pub_key_a: string; 389 | pub_key_b: string; 390 | }; 391 | channel_id: string; 392 | } 393 | 394 | export interface ISendSignedHex100361Response { 395 | approval: boolean; 396 | channel_id: string; 397 | commitment_tx_hash: string; 398 | } 399 | 400 | export interface ISendSignedHex100364Response { 401 | amount_to_counterparty: number; 402 | amount_to_rsmc: number; 403 | channel_id: string; 404 | create_at: string; 405 | create_by: string; 406 | curr_hash: string; 407 | curr_state: number; 408 | htlc_amount_to_payee: number; 409 | id: number; 410 | input_amount: number; 411 | input_txid: string; 412 | input_vout: number; 413 | last_commitment_tx_id: number; 414 | last_edit_time: string; 415 | last_hash: string; 416 | owner: string; 417 | peer_id_a: string; 418 | peer_id_b: string; 419 | property_id: number; 420 | rsmc_input_txid: string; 421 | rsmc_multi_address: string; 422 | rsmc_multi_address_script_pub_key: string; 423 | rsmc_redeem_script: string; 424 | rsmc_temp_address_index: number; 425 | rsmc_temp_address_pub_key: string; 426 | rsmc_tx_hex: string; 427 | rsmc_txid: string; 428 | send_at: string; 429 | sign_at: string; 430 | to_counterparty_tx_hex: string; 431 | to_counterparty_txid: string; 432 | tx_type: number; 433 | } 434 | 435 | export interface ISendSignedHex100362Response { 436 | c2b_br_raw_data: { 437 | br_id: number; 438 | hex: string; 439 | inputs: { 440 | amount: number; 441 | redeemScript: string; 442 | scriptPubKey: string; 443 | txid: string; 444 | vout: number; 445 | }[]; 446 | is_multisig: boolean; 447 | private_key: string; 448 | pub_key_a: string; 449 | pub_key_b: string; 450 | }; 451 | c2b_rd_raw_data: { 452 | hex: string; 453 | inputs: { 454 | amount: number; 455 | redeemScript: string; 456 | scriptPubKey: string; 457 | sequence: number; 458 | txid: string; 459 | vout: number; 460 | }[]; 461 | is_multisig: boolean; 462 | private_key: string; 463 | pub_key_a: string; 464 | pub_key_b: string; 465 | }; 466 | channel_id: string; 467 | } 468 | 469 | export interface ISendSignedHex100363Response { 470 | approval: boolean; 471 | channel_id: string; 472 | latest_commitment_tx_info: { 473 | amount_to_counterparty: number; 474 | amount_to_rsmc: number; 475 | channel_id: string; 476 | create_at: string; 477 | create_by: string; 478 | curr_hash: string; 479 | curr_state: number; 480 | htlc_amount_to_payee: number; 481 | id: number; 482 | input_amount: number; 483 | input_txid: string; 484 | input_vout: number; 485 | last_commitment_tx_id: number; 486 | last_edit_time: string; 487 | last_hash: string; 488 | owner: string; 489 | peer_id_a: string; 490 | peer_id_b: string; 491 | property_id: number; 492 | rsmc_input_txid: string; 493 | rsmc_multi_address: string; 494 | rsmc_multi_address_script_pub_key: string; 495 | rsmc_redeem_script: string; 496 | rsmc_temp_address_index: number; 497 | rsmc_temp_address_pub_key: string; 498 | rsmc_tx_hex: string; 499 | rsmc_txid: string; 500 | send_at: string; 501 | sign_at: string; 502 | to_counterparty_tx_hex: string; 503 | to_counterparty_txid: string; 504 | tx_type: number; 505 | }; 506 | } 507 | 508 | export interface IOn110353 { 509 | c2b_rd_partial_data: { 510 | hex: string; 511 | inputs: { 512 | amount: number; 513 | redeemScript: string; 514 | scriptPubKey: string; 515 | sequence: number; 516 | txid: string; 517 | vout: number; 518 | }[]; 519 | is_multisig: boolean; 520 | private_key: string; 521 | pub_key_a: string; 522 | pub_key_b: string; 523 | }; 524 | channel_id: string; 525 | to_peer_id: string; 526 | } 527 | 528 | export type TOn110353 = IOmniboltResponse; 529 | 530 | export interface IOn110352 { 531 | c2a_rd_partial_data: { 532 | hex: string; 533 | inputs: { 534 | amount: number; 535 | redeemScript: string; 536 | scriptPubKey: string; 537 | sequence: number; 538 | txid: string; 539 | vout: number; 540 | }[]; 541 | is_multisig: boolean; 542 | private_key: string; 543 | pub_key_a: string; 544 | pub_key_b: string; 545 | }; 546 | c2b_counterparty_partial_data: { 547 | hex: string; 548 | inputs: { 549 | amount: number; 550 | redeemScript: string; 551 | scriptPubKey: string; 552 | txid: string; 553 | vout: number; 554 | }[]; 555 | is_multisig: boolean; 556 | private_key: string; 557 | pub_key_a: string; 558 | pub_key_b: string; 559 | }; 560 | c2b_rsmc_partial_data: { 561 | hex: string; 562 | inputs: { 563 | amount: number; 564 | redeemScript: string; 565 | scriptPubKey: string; 566 | txid: string; 567 | vout: number; 568 | }[]; 569 | is_multisig: boolean; 570 | private_key: string; 571 | pub_key_a: string; 572 | pub_key_b: string; 573 | }; 574 | channel_id: string; 575 | payee_node_address: string; 576 | payee_peer_id: string; 577 | to_peer_id: string; 578 | } 579 | export type TOn110352 = IOmniboltResponse; 580 | 581 | export interface IOmniboltResponse extends IAdditionalResponseData { 582 | type: number; 583 | status: boolean; 584 | from: string; 585 | to: string; 586 | result: T; 587 | } 588 | 589 | export interface IAdditionalResponseData { 590 | pageNum?: number; 591 | pageSize?: number; 592 | totalCount?: number; 593 | totalPage?: number; 594 | } 595 | 596 | export interface IGetProperty { 597 | category: string; 598 | creationtxid: string; 599 | data: string; 600 | divisible: boolean; 601 | fixedissuance: boolean; 602 | issuer: string; 603 | managedissuance: boolean; 604 | name: string; 605 | propertyid: number; 606 | subcategory: string; 607 | totaltokens: string; 608 | url: string; 609 | } 610 | 611 | export interface ICloseChannel { 612 | accept_at: string; 613 | address_a: string; 614 | address_b: string; 615 | amount: number; 616 | btc_amount: number; 617 | chain_hash: string; 618 | channel_address: string; 619 | channel_address_redeem_script: string; 620 | channel_address_script_pub_key: string; 621 | channel_id: string; 622 | channel_reserve_satoshis: number; 623 | close_at: string; 624 | create_at: string; 625 | create_by: string; 626 | curr_state: number; 627 | delayed_payment_base_point: string; 628 | dust_limit_satoshis: number; 629 | fee_rate_per_kw: number; 630 | fundee_address_index: number; 631 | funder_address_index: number; 632 | funder_node_address: string; 633 | funder_peer_id: string; 634 | funding_address: string; 635 | funding_pubkey: string; 636 | funding_satoshis: number; 637 | htlc_base_point: string; 638 | htlc_minimum_msat: number; 639 | id: number; 640 | is_private: boolean; 641 | length: number; 642 | max_accepted_htlcs: number; 643 | max_htlc_value_in_flight_msat: number; 644 | payment_base_point: string; 645 | peer_id_a: string; 646 | peer_id_b: string; 647 | property_id: number; 648 | pub_key_a: string; 649 | pub_key_b: string; 650 | push_msat: number; 651 | refuse_reason: string; 652 | revocation_base_point: string; 653 | temporary_channel_id: string; 654 | to_self_delay: number; 655 | value: number | null; 656 | value_type: string; 657 | } 658 | 659 | export interface IAddressContent { 660 | index: number; 661 | path: string; 662 | address: string; 663 | scriptHash: string; 664 | publicKey: string; 665 | } 666 | 667 | export interface ISigningDataContent { 668 | fundingAddress: IAddressContent; 669 | addressIndex: IAddressContent; 670 | last_temp_address: IAddressContent; 671 | rsmc_temp_address: IAddressContent; 672 | htlc_temp_address: IAddressContent; 673 | htlc_temp_address_for_he1b: IAddressContent; 674 | kTbSignedHex: string; 675 | funding_txid: string; 676 | kTempPrivKey: string; 677 | kTbSignedHexCR110351: string; 678 | kTbSignedHexRR110351: string; 679 | } 680 | 681 | export interface ISigningData { 682 | [key: string]: ISigningDataContent; 683 | } 684 | 685 | export type TOmniboltCheckpoints = 686 | | 'onChannelOpenAttempt' 687 | | 'channelAccept' 688 | | 'onAcceptChannel' 689 | | 'fundBitcoin' 690 | | 'onFundBitcoin' 691 | | 'onBitcoinFundingCreated' 692 | | 'onAssetFundingCreated' 693 | | 'sendSignedHex101035' 694 | | 'onCommitmentTransactionCreated' 695 | | 'commitmentTransactionAccepted' 696 | | 'on110353' 697 | | 'on110352' 698 | | 'htlcFindPath' 699 | | 'onHtlcFindPath' 700 | | 'addHtlc' 701 | | 'onAddHtlc' 702 | | 'htlcSIgned' 703 | | 'onHtlcSigned' 704 | | 'forwardR' 705 | | 'onForwardR' 706 | | 'signR' 707 | | 'onSignR' 708 | | 'closeHtlc' 709 | | 'onCloseHtlc' 710 | | 'closeHtlcSigned' 711 | | 'onCloseHtlcSigned' 712 | | 'onChannelCloseAttempt' 713 | | 'sendSignedHex100363'; 714 | 715 | export interface ICheckpoint { 716 | checkpoint: TOmniboltCheckpoints; 717 | data: any; // Data to replay; 718 | } 719 | 720 | export interface ICheckpoints { 721 | //key === channelId; 722 | [key: string]: ICheckpoint; 723 | } 724 | 725 | export interface IFundingAddress extends IAddressContent { 726 | assets: []; 727 | } 728 | 729 | export type TFundingAddresses = { 730 | [key: string]: IAddressContent; 731 | }; 732 | 733 | export interface IData { 734 | nextAddressIndex: IAddressContent; 735 | signingData: ISigningData; 736 | checkpoints: ICheckpoints; 737 | fundingAddresses: TFundingAddresses; 738 | } 739 | 740 | export interface ISaveData { 741 | nextAddressIndex: IAddressContent; 742 | signingData: ISigningData; 743 | checkpoints: ICheckpoints; 744 | fundingAddresses: TFundingAddresses; 745 | } 746 | 747 | export type TAvailableNetworks = 'bitcoin' | 'bitcoinTestnet'; 748 | 749 | export interface IGetAddress { 750 | keyPair: ECPairInterface | undefined; 751 | network: INetwork | undefined; 752 | type?: 'bech32' | 'segwit' | 'legacy'; 753 | } 754 | 755 | export interface INetwork { 756 | messagePrefix: string; 757 | bech32: string; 758 | bip32: { 759 | public: number; 760 | private: number; 761 | }; 762 | pubKeyHash: number; 763 | scriptHash: number; 764 | wif: number; 765 | } 766 | 767 | export interface IChannelSigningData { 768 | fundingAddress: IAddressContent; 769 | addressIndex: IAddressContent; 770 | last_temp_address: IAddressContent; 771 | rsmc_temp_address: IAddressContent; 772 | htlc_temp_address: IAddressContent; 773 | htlc_temp_address_for_he1b: IAddressContent; 774 | kTbSignedHex: string; 775 | funding_txid: string; 776 | kTempPrivKey: string; 777 | kTbSignedHexCR110351: string; 778 | kTbSignedHexRR110351: string; 779 | kTbTempData: string; 780 | } 781 | 782 | export type IListeners = { 783 | [key in TOmniboltCheckpoints]?: IListenerParams; 784 | }; 785 | 786 | export interface IListenerParams { 787 | start: (data: TStart) => any; 788 | success: (data: TSuccess) => any; 789 | failure: (data: any) => any; 790 | } 791 | 792 | export interface ISignP2PKH { 793 | txhex: string; 794 | inputs: IFundingInputs[]; 795 | privkey: string; 796 | selectedNetwork?: TAvailableNetworks; 797 | } 798 | 799 | export interface ISignP2SH { 800 | is_first_sign: boolean; 801 | txhex: string; 802 | pubkey_1: string; 803 | pubkey_2: string; 804 | privkey: string; 805 | inputs: any; 806 | selectedNetwork?: TAvailableNetworks | undefined; 807 | } 808 | 809 | export interface ISendSignedHex100363 { 810 | data: ISendSignedHex100362Response; 811 | privkey: string; 812 | channelId: string; 813 | nodeID: string; 814 | userID: string; 815 | } 816 | 817 | export interface ISendSignedHex101134 { 818 | channel_id: string; 819 | temporary_channel_id: string; 820 | } 821 | 822 | export interface ICommitmentTransactionAcceptedCheckpointData { 823 | info: ICommitmentTransactionAcceptedResponse; 824 | nodeID: string; 825 | userID: string; 826 | } 827 | 828 | export interface IOpenChannel { 829 | chain_hash: string; 830 | channel_reserve_satoshis: number; 831 | delayed_payment_base_point: string; 832 | dust_limit_satoshis: number; 833 | fee_rate_per_kw: number; 834 | funder_address_index: number; 835 | funder_node_address: string; 836 | funder_peer_id: string; 837 | funding_address: string; 838 | funding_pubkey: string; 839 | funding_satoshis: number; 840 | htlc_base_point: string; 841 | htlc_minimum_msat: number; 842 | is_private: boolean; 843 | length: number; 844 | max_accepted_htlcs: number; 845 | max_htlc_value_in_flight_msat: number; 846 | payment_base_point: string; 847 | push_msat: number; 848 | revocation_base_point: string; 849 | temporary_channel_id: string; 850 | to_self_delay: number; 851 | value: number | null; 852 | value_type: string; 853 | } 854 | 855 | export interface IFundAssetResponse { 856 | hex: string; 857 | inputs: { 858 | amount: number; //In BTC 859 | scriptPubKey: string; 860 | txid: string; 861 | vout: number; 862 | }[]; 863 | } 864 | 865 | export interface IFundingInfo { 866 | fundingAddressIndex?: number; 867 | amount_to_fund?: number; // X3 868 | miner_fee?: number; // X3 869 | asset_id: number; 870 | asset_amount: number; 871 | } 872 | 873 | export interface IConnectUri { 874 | remote_node_address: string; 875 | recipient_user_peer_id: string; 876 | } 877 | 878 | export interface ICreateChannel extends IConnectUri { 879 | info: IFundingInfo; 880 | } 881 | 882 | export interface IFundTempChannel { 883 | recipient_node_peer_id: string; 884 | recipient_user_peer_id: string; 885 | temporary_channel_id: string; 886 | info: IFundingInfo; 887 | } 888 | 889 | export interface IParseOmniboltUriResponse { 890 | action: string; 891 | data: { 892 | remote_node_address?: string; 893 | recipient_user_peer_id?: string; 894 | [key: string]: any; 895 | }; 896 | } 897 | 898 | export interface IGenerateOmniboltUri { 899 | action: string; 900 | data: string | object; 901 | } 902 | 903 | export interface IGetAllBalancesForAddressResponse { 904 | balance: string; 905 | frozen: string; 906 | name: string; 907 | propertyid: number; 908 | reserved: string; 909 | } 910 | 911 | export interface IGetTransactionResponse { 912 | amount: string; 913 | block: number; 914 | blockhash: string; 915 | blocktime: number; 916 | category: string; 917 | confirmations: number; 918 | data: string; 919 | divisible: boolean; 920 | ecosystem: string; 921 | fee: string; 922 | ismine: boolean; 923 | positioninblock: number; 924 | propertyid: number; 925 | propertyname: string; 926 | propertytype: string; 927 | sendingaddress: string; 928 | subcategory: string; 929 | txid: string; 930 | type: string; 931 | type_int: number; 932 | url: string; 933 | valid: boolean; 934 | version: number; 935 | } 936 | -------------------------------------------------------------------------------- /src/utils/browser-or-node.ts: -------------------------------------------------------------------------------- 1 | /* global window self */ 2 | 3 | const isBrowser = (): boolean => { 4 | try { 5 | return typeof window !== 'undefined' && typeof window.document !== 'undefined'; 6 | } catch { 7 | return false; 8 | } 9 | } 10 | 11 | /* eslint-disable no-restricted-globals */ 12 | const isWebWorker = (): boolean => { 13 | try { 14 | return typeof self === 'object' 15 | && self.constructor 16 | && self.constructor.name === 'DedicatedWorkerGlobalScope'; 17 | } catch { 18 | return false; 19 | } 20 | } 21 | /* eslint-enable no-restricted-globals */ 22 | 23 | const isNode = (): boolean => { 24 | try { 25 | return typeof process !== 'undefined' 26 | && process.versions != null 27 | && process.versions.node != null; 28 | } catch { 29 | return false; 30 | } 31 | } 32 | 33 | /** 34 | * @see https://github.com/jsdom/jsdom/releases/tag/12.0.0 35 | * @see https://github.com/jsdom/jsdom/issues/1537 36 | */ 37 | /* eslint-disable no-undef */ 38 | const isJsDom = (): boolean => { 39 | try { 40 | return (typeof window !== 'undefined' && window.name === 'nodejs') 41 | || navigator.userAgent.includes('Node.js') 42 | || navigator.userAgent.includes('jsdom'); 43 | } catch { 44 | return false; 45 | } 46 | } 47 | 48 | export { 49 | isBrowser, isWebWorker, isNode, isJsDom 50 | }; 51 | -------------------------------------------------------------------------------- /src/utils/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This method adds a new omnibolt address based on the previous address index. 3 | * @param {string} [selectedWallet] 4 | * @param {TAvailableNetworks} [selectedNetwork] 5 | */ 6 | import { err, ok, Result } from '../result'; 7 | import { 8 | IAddressContent, 9 | IGenerateOmniboltUri, 10 | IGetAddress, 11 | IParseOmniboltUriResponse, 12 | ISignP2PKH, 13 | ISignP2SH, 14 | TAvailableNetworks 15 | } from '../types'; 16 | import { INetwork, networks } from './networks'; 17 | 18 | const bitcoin = require('bitcoinjs-lib'); 19 | const bip39 = require('bip39'); 20 | const bip32 = require('bip32'); 21 | 22 | /** 23 | * This method returns a new omnibolt address based on the previous address index. 24 | * @async 25 | * @param {string} [selectedWallet] 26 | * @param {TAvailableNetworks} [selectedNetwork] 27 | * @return {>>} 28 | */ 29 | export const getNextOmniboltAddress = async ({ 30 | selectedNetwork, 31 | addressIndex, 32 | mnemonic, 33 | }: { 34 | selectedNetwork: TAvailableNetworks; 35 | addressIndex: IAddressContent; 36 | mnemonic: string; 37 | }): Promise> => { 38 | let index = 0; 39 | if ( 40 | addressIndex && 41 | addressIndex?.index >= 0 && 42 | addressIndex?.path?.length > 0 43 | ) { 44 | index = addressIndex.index + 1; 45 | } 46 | //`m/${purpose}'/${coinType}'/${account}'/${change}/${addressIndex}` 47 | const coinType = selectedNetwork === 'bitcoinTestnet' ? '1' : '0'; 48 | const addressPath = `m/44'/${coinType}'/2'/0/${index}`; 49 | const seed = bip39.mnemonicToSeedSync(mnemonic, ''); 50 | const network = networks[selectedNetwork]; 51 | const root = bip32.fromSeed(seed, network); 52 | const addressKeypair = root.derivePath(addressPath); 53 | const address = getAddress({ 54 | keyPair: addressKeypair, 55 | network, 56 | }); 57 | const scriptHash = getScriptHash(address, network); 58 | return ok({ 59 | index, 60 | path: addressPath, 61 | address, 62 | scriptHash, 63 | publicKey: addressKeypair.publicKey.toString('hex'), 64 | }); 65 | }; 66 | 67 | /** 68 | * Get address for a given keyPair, network and type. 69 | * @param {Object|undefined} keyPair 70 | * @param {string|Object|undefined} network 71 | * @param {string} type - Determines what type of address to generate (legacy, segwit, bech32). 72 | * @return {string} 73 | */ 74 | export const getAddress = ({ 75 | keyPair = undefined, 76 | network = undefined, 77 | type = 'legacy', 78 | }: IGetAddress): string => { 79 | if (!keyPair || !network) { 80 | return ''; 81 | } 82 | try { 83 | switch (type) { 84 | case 'bech32': 85 | //Get Native Bech32 (bc1) addresses 86 | return bitcoin.payments.p2wpkh({ pubkey: keyPair.publicKey, network }) 87 | .address; 88 | case 'segwit': 89 | //Get Segwit P2SH Address (3) 90 | return bitcoin.payments.p2sh({ 91 | redeem: bitcoin.payments.p2wpkh({ 92 | pubkey: keyPair.publicKey, 93 | network, 94 | }), 95 | network, 96 | }).address; 97 | //Get Legacy Address (1) 98 | case 'legacy': 99 | return bitcoin.payments.p2pkh({ pubkey: keyPair.publicKey, network }) 100 | .address; 101 | } 102 | return ''; 103 | } catch { 104 | return ''; 105 | } 106 | }; 107 | 108 | /** 109 | * Get scriptHash for a given address 110 | * @param {string} address 111 | * @param {string|Object} network 112 | * @return {string} 113 | */ 114 | export const getScriptHash = ( 115 | address = '', 116 | network: INetwork | string = networks.bitcoin, 117 | ): string => { 118 | try { 119 | if (!address || !network) { 120 | return ''; 121 | } 122 | if (typeof network === 'string' && network in networks) { 123 | network = networks[network]; 124 | } 125 | const script = bitcoin.address.toOutputScript(address, network); 126 | let hash = bitcoin.crypto.sha256(script); 127 | const reversedHash = Buffer.from(hash.reverse()); 128 | return reversedHash.toString('hex'); 129 | } catch { 130 | return ''; 131 | } 132 | }; 133 | 134 | /** 135 | * Returns private key for the provided address data. 136 | * @param {IAddressContent} addressData 137 | * @param {string} [selectedWallet] 138 | * @param {TAvailableNetworks} [selectedNetwork] 139 | * @return {Promise>} 140 | */ 141 | export const getPrivateKey = async ({ 142 | addressData, 143 | selectedNetwork = 'bitcoin', 144 | mnemonic, 145 | }: { 146 | addressData: IAddressContent; 147 | selectedNetwork?: TAvailableNetworks; 148 | mnemonic: string; 149 | }): Promise> => { 150 | try { 151 | if (!addressData) { 152 | return err('No addressContent specified.'); 153 | } 154 | if (!mnemonic) { 155 | return err('No mnemonic phrase specified.'); 156 | } 157 | const network = networks[selectedNetwork]; 158 | const bip39Passphrase = ''; 159 | const seed = bip39.mnemonicToSeedSync(mnemonic, bip39Passphrase); 160 | const root = bip32.fromSeed(seed, network); 161 | 162 | const addressPath = addressData.path; 163 | const addressKeypair = root.derivePath(addressPath); 164 | return ok(addressKeypair.toWIF()); 165 | } catch (e) { 166 | return err(e); 167 | } 168 | }; 169 | 170 | /** 171 | * Sign P2PKH address with TransactionBuilder way 172 | * main network: btctool.bitcoin.networks.bitcoin; 173 | * @param txhex 174 | * @param privkey 175 | * @param inputs all of inputs 176 | * @param selectedNetwork 177 | */ 178 | 179 | export const signP2PKH = ({ txhex, privkey, inputs, selectedNetwork = 'bitcoin' }: ISignP2PKH): string => { 180 | if (txhex === '') return ''; 181 | const network = networks[selectedNetwork]; 182 | const tx = bitcoin.Transaction.fromHex(txhex); 183 | const txb = bitcoin.TransactionBuilder.fromTransaction(tx, network); 184 | const key = bitcoin.ECPair.fromWIF(privkey, network); 185 | 186 | // Sign all inputs 187 | for (let i = 0; i < inputs.length; i++) { 188 | txb.sign({ 189 | prevOutScriptType: 'p2pkh', 190 | vin: i, 191 | keyPair: key, 192 | }); 193 | } 194 | 195 | // Return hex 196 | return txb.build().toHex(); 197 | }; 198 | 199 | /** 200 | * This method returns a funding address based on the provided index. 201 | * @async 202 | * @param {number} index 203 | * @param {string} mnemonic 204 | * @param {TAvailableNetworks} [selectedNetwork] 205 | * @return {>>} 206 | */ 207 | export const generateFundingAddress = async ({ 208 | index = 0, 209 | mnemonic, 210 | selectedNetwork, 211 | }: { 212 | index: number; 213 | mnemonic: string; 214 | selectedNetwork: TAvailableNetworks; 215 | }): Promise> => { 216 | //`m/${purpose}'/${coinType}'/${account}'/${change}/${addressIndex}` 217 | const coinType = selectedNetwork === 'bitcoinTestnet' ? '1' : '0'; 218 | const addressPath = `m/44'/${coinType}'/0'/0/${index}`; 219 | const seed = bip39.mnemonicToSeedSync(mnemonic, ''); 220 | const network = networks[selectedNetwork]; 221 | const root = bip32.fromSeed(seed, network); 222 | const addressKeypair = root.derivePath(addressPath); 223 | const address = getAddress({ 224 | keyPair: addressKeypair, 225 | network, 226 | }); 227 | const scriptHash = getScriptHash(address, network); 228 | return ok({ 229 | index, 230 | path: addressPath, 231 | address, 232 | scriptHash, 233 | publicKey: addressKeypair.publicKey.toString('hex'), 234 | }); 235 | }; 236 | 237 | /** 238 | * Sign P2SH address with TransactionBuilder way for 2-2 multi-sig address 239 | * @param is_first_sign Is the first person to sign this transaction? 240 | * @param txhex 241 | * @param pubkey_1 242 | * @param pubkey_2 243 | * @param privkey 244 | * @param inputs all of inputs 245 | * @param selectedNetwork 246 | */ 247 | //TODO: Remove TransactionBuilder and work into existing signing logic. 248 | export const signP2SH = async ({ 249 | is_first_sign, 250 | txhex, 251 | pubkey_1, 252 | pubkey_2, 253 | privkey, 254 | inputs, 255 | selectedNetwork = 'bitcoin', 256 | }: ISignP2SH): Promise => { 257 | if (txhex === '') { 258 | return ''; 259 | } 260 | const network = networks[selectedNetwork]; 261 | const tx = bitcoin.Transaction.fromHex(txhex); 262 | const txb = bitcoin.TransactionBuilder.fromTransaction(tx, network); 263 | const pubkeys = [pubkey_1, pubkey_2].map((hex) => Buffer.from(hex, 'hex')); 264 | const p2ms = bitcoin.payments.p2ms({ m: 2, pubkeys, network }); 265 | const p2sh = bitcoin.payments.p2sh({ redeem: p2ms, network }); 266 | // private key 267 | const key = bitcoin.ECPair.fromWIF(privkey, network); 268 | 269 | // Sign all inputs 270 | for (let i = 0; i < inputs.length; i++) { 271 | let amount = accMul(inputs[i].amount, 100000000); 272 | txb.sign(i, key, p2sh.redeem.output, undefined, amount, undefined); 273 | } 274 | 275 | if (is_first_sign === true) { 276 | // The first person to sign this transaction 277 | let firstHex = txb.buildIncomplete().toHex(); 278 | console.info('First signed - Hex => ' + firstHex); 279 | return firstHex; 280 | } else { 281 | // The second person to sign this transaction 282 | let finalHex = txb.build().toHex(); 283 | console.info('signP2SH - Second signed - Hex = ' + finalHex); 284 | return finalHex; 285 | } 286 | }; 287 | 288 | /**accMul 289 | * This function is used to get accurate multiplication result. 290 | * 291 | * Explanation: There will be errors in the multiplication result of javascript, 292 | * which is more obvious when multiplying two floating-point numbers. 293 | * This function returns a more accurate multiplication result. 294 | * 295 | * @param arg1 296 | * @param arg2 297 | */ 298 | export const accMul = (arg1, arg2): number => { 299 | let m = 0, 300 | s1 = arg1.toString(), 301 | s2 = arg2.toString(); 302 | 303 | try { 304 | m += s1.split('.')[1].length; 305 | } catch (e) {} 306 | 307 | try { 308 | m += s2.split('.')[1].length; 309 | } catch (e) {} 310 | 311 | return ( 312 | (Number(s1.replace('.', '')) * Number(s2.replace('.', ''))) / 313 | Math.pow(10, m) 314 | ); 315 | }; 316 | 317 | /** 318 | * Used to timeout a request after a specified period of time. 319 | * @param {number} ms 320 | * @param {Promise} promise 321 | * @return {Promise} 322 | */ 323 | export const promiseTimeout = ( 324 | ms: number, 325 | promise: Promise, 326 | ): Promise => { 327 | let id; 328 | let timeout = new Promise((resolve) => { 329 | id = setTimeout(() => { 330 | resolve(err('Timed Out.')); 331 | }, ms); 332 | }); 333 | return Promise.race([promise, timeout]).then((result) => { 334 | clearTimeout(id); 335 | try { 336 | if (result?.isErr()) { 337 | return err(result?.error?.message); 338 | } 339 | } catch (e) { 340 | return err(e); 341 | } 342 | return result; 343 | }); 344 | }; 345 | 346 | export const sleep = (ms = 1000): Promise => { 347 | return new Promise((resolve) => setTimeout(resolve, ms)); 348 | }; 349 | 350 | /** 351 | * Parses an omnibolt uri, returning the specified action and data provided. 352 | * Example: omnibolt:connect:{"remote_node_address":"nodeAddress","recipient_user_peer_id":"userId"} 353 | * @param {string} uri 354 | */ 355 | export const parseOmniboltUri = (uri: string): Result => { 356 | try { 357 | if (!uri) { 358 | return err('No URI provided.'); 359 | } 360 | let action; 361 | const isOmniboltUri = uri.substr(0,9) === 'omnibolt:'; 362 | if (!isOmniboltUri) return err('This is not an omnibolt uri.'); 363 | uri = uri.substr(9, uri.length); 364 | const actionIndex = uri.indexOf(':'); 365 | action = uri.substr(0, actionIndex); 366 | const data = JSON.parse(uri.substr(actionIndex+1, uri.length)); 367 | return ok({ 368 | action, 369 | data, 370 | }); 371 | } catch (e) { 372 | return err(e); 373 | } 374 | }; 375 | 376 | /** 377 | * Generates an omnibolt uri where specific omnibolt actions and data can be specified for easier sharing. 378 | * @param {string} action 379 | * @param {string|object} data 380 | * @return {Result} 381 | */ 382 | export const generateOmniboltUri = ({ action, data }: IGenerateOmniboltUri): Result => { 383 | try { 384 | if (!action || !data) return err('Unable to generate omnibolt uri.'); 385 | if (typeof data !== 'string') { 386 | data = JSON.stringify(data); 387 | } 388 | return ok(`omnibolt:${action}:${data}`); 389 | } catch (e) { 390 | return err(e); 391 | } 392 | }; 393 | -------------------------------------------------------------------------------- /src/utils/networks.ts: -------------------------------------------------------------------------------- 1 | export type TAvailableNetworks = 'bitcoin' | 'bitcoinTestnet'; 2 | 3 | export enum EAvailableNetworks { 4 | bitcoin = 'bitcoin', 5 | bitcoinTestnet = 'bitcoinTestnet', 6 | } 7 | 8 | export interface INetwork { 9 | messagePrefix: string; 10 | bech32: string; 11 | bip32: { 12 | public: number; 13 | private: number; 14 | }; 15 | pubKeyHash: number; 16 | scriptHash: number; 17 | wif: number; 18 | } 19 | 20 | export type INetworks = { 21 | [key in EAvailableNetworks]: INetwork; 22 | }; 23 | 24 | /* 25 | Source: https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/src/networks.js 26 | List of address prefixes: https://en.bitcoin.it/wiki/List_of_address_prefixes 27 | */ 28 | export const networks: INetworks = { 29 | bitcoin: { 30 | messagePrefix: '\x18Bitcoin Signed Message:\n', 31 | bech32: 'bc', 32 | bip32: { 33 | public: 0x0488b21e, 34 | private: 0x0488ade4, 35 | }, 36 | pubKeyHash: 0x00, 37 | scriptHash: 0x05, 38 | wif: 0x80, 39 | }, 40 | bitcoinTestnet: { 41 | messagePrefix: '\x18Bitcoin Signed Message:\n', 42 | bech32: 'tb', 43 | bip32: { 44 | public: 0x043587cf, 45 | private: 0x04358394, 46 | }, 47 | pubKeyHash: 0x6f, 48 | scriptHash: 0xc4, 49 | wif: 0xef, 50 | }, 51 | }; 52 | -------------------------------------------------------------------------------- /tests/constants.ts: -------------------------------------------------------------------------------- 1 | import { defaultDataShape } from '../src/shapes'; 2 | 3 | export const loginPhrase = 'snow evidence basic rally wing flock room mountain monitor page sail betray steel major fall pioneer summer tenant pact bargain lucky joy lab parrot'; 4 | export const mnemonic = 'table panda praise oyster benefit ticket bonus capital silly burger fatal use oyster cream feel wine trap focus planet sail atom approve album valid'; 5 | export const url = '62.234.216.108:60020/wstest'; 6 | export const selectedNetwork = 'bitcoinTestnet'; 7 | export const userPeerId = '6a3cff12cb9d7a18333900ca0e5fe4dcf3e7414e184db6e8cf980203b1dfe44e'; 8 | export const nodeAddress = '/ip4/62.234.216.108/tcp/4001/p2p/QmaYAYp4MzkncRUvZgwDc4DLDbKfWftftoUiZSjnRz2ABy'; 9 | export const nodePeerId = 'QmaYAYp4MzkncRUvZgwDc4DLDbKfWftftoUiZSjnRz2ABy'; 10 | export const propertyId = '137'; 11 | 12 | export const omniboltConnectUri = { 13 | action: 'connect', 14 | data: '{"remote_node_address":"/ip4/62.234.216.108/tcp/4001/p2p/QmaYAYp4MzkncRUvZgwDc4DLDbKfWftftoUiZSjnRz2ABy","recipient_user_peer_id":"6a3cff12cb9d7a18333900ca0e5fe4dcf3e7414e184db6e8cf980203b1dfe44e"}', 15 | }; 16 | export const omniboltConnectString = `omnibolt:${omniboltConnectUri.action}:${omniboltConnectUri.data}`; 17 | 18 | export const saveData = async (): Promise => {}; 19 | export const data = defaultDataShape; 20 | 21 | export const connectionInfo = { 22 | chainNodeType: 'test', 23 | htlcFeeRate: 0.0001, 24 | htlcMaxFee: 0.01, 25 | nodeAddress: '/ip4/62.234.216.108/tcp/4001/p2p/QmaYAYp4MzkncRUvZgwDc4DLDbKfWftftoUiZSjnRz2ABy', 26 | nodePeerId: 'QmaYAYp4MzkncRUvZgwDc4DLDbKfWftftoUiZSjnRz2ABy', 27 | userPeerId: '6a3cff12cb9d7a18333900ca0e5fe4dcf3e7414e184db6e8cf980203b1dfe44e', 28 | }; 29 | export const fundingAddresses = [ 30 | { 31 | index: 0, 32 | address: 'mypLwE2kcywW4cTHKmBGDPwULogb8PaKJP', 33 | path: "m/44'/1'/0'/0/0", 34 | publicKey: '022f16ad3c05a43782e59b23349c3cb3b04a99c744220de1fd8a345de93a2fc652', 35 | scriptHash: 'cba28cd77d770590f60db0c75d3c8be41333a476a09e427ed0a14d5ba3552b94', 36 | }, 37 | { 38 | index: 1, 39 | address: 'mfd5H88MafMHdYViR38nQNZYkB4m8QtFw1', 40 | path: "m/44'/1'/0'/0/1", 41 | publicKey: '035a600bf65844c49186b766233cc078c85b0b88c53fe56c9871375cae9c7d9173', 42 | scriptHash: '7621403c2a1d020a2025409081afe33ab0fb90e36d72e8c9b88a2fc4fb5ef7de', 43 | } 44 | ]; 45 | export const channelInfo = { 46 | asset_amount: 5, 47 | balance_a: 2, 48 | balance_b: 3, 49 | balance_htlc: 0, 50 | btc_amount: 0.00009296, 51 | btc_funding_times: 3, 52 | channel_address: '2N1pt9VG7wvoWye3aN1PuEvggmVTkn9XQTF', 53 | channel_id: "186456df442b8a43342ea64236d1e8f3a7e59b8e84081bda32babd91b8ab7a1a", 54 | create_at: '2022-02-02T03:40:52.263387548+08:00', 55 | curr_state: 20, 56 | is_private: false, 57 | peer_ida: '677169d8d2113d36a15143d46ae6db33003ad6399f295bb4586a1d91c6bb622a', 58 | peer_idb: '6a3cff12cb9d7a18333900ca0e5fe4dcf3e7414e184db6e8cf980203b1dfe44e', 59 | property_id: 137, 60 | temporary_channel_id: '4f99546eb2f9b19b92412d7717d66e7451ae9751a203d9b9d20d7650a5ffa8c8', 61 | }; 62 | export const assetInformation = { 63 | category: '', 64 | creationtxid: 'a04a7a285e636ebf013ceec94748ee9dbe8d3d72f64a53cc12fcbc36d45fce2f', 65 | data: 'OBD Test Token NO.1', 66 | divisible: true, 67 | fixedissuance: true, 68 | issuer: 'n4j37pAMNsjkTs6roKof3TGNvmPh16fvpS', 69 | managedissuance: false, 70 | name: 'OBD-1', 71 | propertyid: 137, 72 | subcategory: '', 73 | totaltokens: '10000000000.00000000', 74 | url: '' 75 | }; 76 | 77 | export const fundingAddressBalanceInfo = [ 78 | { 79 | balance: '65.00000000', 80 | frozen: '0.00000000', 81 | name: 'OBD-1', 82 | propertyid: 137, 83 | reserved: '0.00000000' 84 | } 85 | ]; 86 | 87 | export const getTransactionResponse = { 88 | amount: '10000000000.00000000', 89 | block: 1746496, 90 | blockhash: '00000000c475a61b682018a9d7b7d64ab58c6e46be865eedb00e8ad6d91ed6a8', 91 | blocktime: 1590400679, 92 | category: '', 93 | confirmations: 393735, 94 | data: 'OBD Test Token NO.1', 95 | divisible: true, 96 | ecosystem: 'main', 97 | fee: '0.00000254', 98 | ismine: true, 99 | positioninblock: 147, 100 | propertyid: 137, 101 | propertyname: 'OBD-1', 102 | propertytype: 'divisible', 103 | sendingaddress: 'n4j37pAMNsjkTs6roKof3TGNvmPh16fvpS', 104 | subcategory: '', 105 | txid: 'a04a7a285e636ebf013ceec94748ee9dbe8d3d72f64a53cc12fcbc36d45fce2f', 106 | type: 'Create Property - Fixed', 107 | type_int: 50, 108 | url: '', 109 | valid: true, 110 | version: 0 111 | }; 112 | -------------------------------------------------------------------------------- /tests/omnibolt.test.ts: -------------------------------------------------------------------------------- 1 | import * as chai from 'chai'; 2 | import { ObdApi } from '../src'; 3 | import WebSocket from 'ws'; 4 | import { 5 | assetInformation, 6 | channelInfo, 7 | connectionInfo, 8 | data, 9 | fundingAddressBalanceInfo, 10 | fundingAddresses, 11 | getTransactionResponse, 12 | loginPhrase, 13 | mnemonic, 14 | nodeAddress, 15 | propertyId, 16 | saveData, 17 | selectedNetwork, 18 | url, 19 | userPeerId 20 | } from './constants'; 21 | 22 | const expect = chai.expect; 23 | let obdapi: ObdApi; 24 | 25 | describe('omnibolt-js Library', () => { 26 | 27 | it('Should create an obdapi instance' , async () => { 28 | obdapi = new ObdApi({ websocket: WebSocket }); 29 | expect(obdapi).to.be.a('object'); 30 | expect(obdapi.selectedNetwork).to.deep.equal(selectedNetwork); 31 | }); 32 | 33 | it('Should connect and login to an obd server.' , async () => { 34 | const response = await obdapi.connect({ 35 | loginPhrase, 36 | mnemonic, 37 | url, 38 | selectedNetwork, 39 | saveData, 40 | data, 41 | }); 42 | expect(response.isOk()).to.equal(true); 43 | if (response.isErr()) return; 44 | expect(response.value.userPeerId).to.deep.equal(userPeerId); 45 | expect(response.value.nodeAddress).to.deep.equal(nodeAddress); 46 | }); 47 | 48 | it('Should return connection info.' , async () => { 49 | const response = await obdapi.getInfo(); 50 | expect(response).to.deep.equal(connectionInfo); 51 | }); 52 | 53 | it('Should return connect uri string.' , async () => { 54 | const response = await obdapi.getConnectUri(); 55 | expect(response.isOk()).to.equal(true); 56 | if (response.isErr()) return; 57 | const connectUriData = JSON.stringify({ remote_node_address: obdapi.loginData.nodeAddress, recipient_user_peer_id: obdapi.loginData.userPeerId }); 58 | expect(response.value).to.deep.equal(`omnibolt:connect:${connectUriData}`); 59 | }); 60 | 61 | const getFundingAddressTest = async (index): Promise => { 62 | const response = await obdapi.getFundingAddress({ index }); 63 | expect(response.isOk()).to.equal(true); 64 | if (response.isErr()) return; 65 | const fundingAddress = fundingAddresses[index]; 66 | expect(response.value).to.deep.equal(fundingAddress); 67 | }; 68 | 69 | it('Should return funding address at index zero' , async () => { 70 | await getFundingAddressTest(0); 71 | }); 72 | 73 | it('Should return funding address at index one' , async () => { 74 | await getFundingAddressTest(1); 75 | }); 76 | 77 | it('Should return available channels' , async () => { 78 | const response = await obdapi.getMyChannels(); 79 | expect(response.isOk()).to.equal(true); 80 | if (response.isErr()) return; 81 | expect(response.value.data).to.be.a('array'); 82 | const responseData = response.value.data[0]; 83 | expect(responseData).to.deep.equal(channelInfo); 84 | }); 85 | 86 | it('Should return asset/property information' , async () => { 87 | let response = await obdapi.getProperty(propertyId); 88 | expect(response.isOk()).to.equal(true); 89 | if (response.isErr()) return; 90 | expect(response.value).to.deep.equal(assetInformation); 91 | }); 92 | 93 | it('Should return funding address balance information' , async () => { 94 | let response = await obdapi.getAllBalancesForAddress(fundingAddresses[0].address); 95 | expect(response.isOk()).to.equal(true); 96 | if (response.isErr()) return; 97 | expect(response.value).to.deep.equal(fundingAddressBalanceInfo); 98 | }); 99 | 100 | it('Should return transaction information' , async () => { 101 | let response = await obdapi.getTransaction(assetInformation.creationtxid); 102 | expect(response.isOk()).to.equal(true); 103 | if (response.isErr()) return; 104 | expect(response.value).to.deep.equal(getTransactionResponse); 105 | }); 106 | }); 107 | -------------------------------------------------------------------------------- /tests/utils.test.ts: -------------------------------------------------------------------------------- 1 | import { generateOmniboltUri, parseOmniboltUri } from '../src/utils'; 2 | 3 | import * as chai from 'chai'; 4 | import { omniboltConnectString, omniboltConnectUri } from './constants'; 5 | const expect = chai.expect; 6 | 7 | 8 | describe('Utils/Helper Methods', () => { 9 | 10 | it('Should parse an omnibolt connect uri' , async () => { 11 | const response = parseOmniboltUri(omniboltConnectString); 12 | expect(response.isOk()).to.deep.equal(true); 13 | if (response.isErr()) return; 14 | expect(response.value.action).to.deep.equal(omniboltConnectUri.action); 15 | expect(JSON.stringify(response.value.data)).to.deep.equal(omniboltConnectUri.data); 16 | }); 17 | 18 | it('Should generate an omnibolt connect uri' , async () => { 19 | const response = generateOmniboltUri({ action: omniboltConnectUri.action, data: omniboltConnectUri.data }); 20 | expect(response.isOk()).to.deep.equal(true); 21 | if (response.isErr()) return; 22 | expect(response.value).to.deep.equal(omniboltConnectString); 23 | }); 24 | 25 | }); 26 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "esnext", 4 | "module": "commonjs", 5 | "outDir": "./lib", 6 | "declarationDir": "./lib/types", 7 | "sourceMap": true, 8 | "removeComments": true, 9 | "allowSyntheticDefaultImports": true, 10 | "esModuleInterop": true, 11 | "isolatedModules": false, 12 | "resolveJsonModule": true, 13 | "noImplicitAny": false, 14 | "lib": [ 15 | "esnext", 16 | "dom" 17 | ], 18 | "moduleResolution": "node", 19 | "declaration": true, 20 | "strict": true, 21 | "allowJs": true, 22 | "strictNullChecks": true, 23 | "strictFunctionTypes": true, 24 | "strictPropertyInitialization": true, 25 | "noImplicitThis": true, 26 | "alwaysStrict": true, 27 | "noUnusedLocals": true, 28 | "skipLibCheck": true 29 | //"noUnusedParameters": true 30 | }, 31 | "include": [ 32 | "src/**/*.ts" 33 | ], 34 | "exclude": ["node_modules"] 35 | } 36 | --------------------------------------------------------------------------------