beignet 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (329) hide show
  1. package/.eslintignore +4 -0
  2. package/.eslintrc +40 -0
  3. package/.prettierrc +9 -0
  4. package/LICENSE +21 -0
  5. package/README.md +166 -0
  6. package/dist/electrum/constants.js +31 -0
  7. package/dist/electrum/constants.js.map +1 -0
  8. package/dist/electrum/index.js +552 -0
  9. package/dist/electrum/index.js.map +1 -0
  10. package/dist/index.js +23 -0
  11. package/dist/index.js.map +1 -0
  12. package/dist/shapes/electrum.js +14 -0
  13. package/dist/shapes/electrum.js.map +1 -0
  14. package/dist/shapes/index.js +19 -0
  15. package/dist/shapes/index.js.map +1 -0
  16. package/dist/shapes/wallet.js +115 -0
  17. package/dist/shapes/wallet.js.map +1 -0
  18. package/dist/transaction/index.js +692 -0
  19. package/dist/transaction/index.js.map +1 -0
  20. package/dist/types/electrum/constants.d.ts +7 -0
  21. package/dist/types/electrum/index.d.ts +85 -0
  22. package/dist/types/electrum.js +9 -0
  23. package/dist/types/electrum.js.map +1 -0
  24. package/dist/types/index.d.ts +6 -0
  25. package/dist/types/index.js +20 -0
  26. package/dist/types/index.js.map +1 -0
  27. package/dist/types/shapes/electrum.d.ts +5 -0
  28. package/dist/types/shapes/index.d.ts +2 -0
  29. package/dist/types/shapes/wallet.d.ts +10 -0
  30. package/dist/types/transaction/index.d.ts +92 -0
  31. package/dist/types/transaction.js +12 -0
  32. package/dist/types/transaction.js.map +1 -0
  33. package/dist/types/types/electrum.d.ts +113 -0
  34. package/dist/types/types/index.d.ts +3 -0
  35. package/dist/types/types/transaction.d.ts +51 -0
  36. package/dist/types/types/wallet.d.ts +400 -0
  37. package/dist/types/utils/conversion.d.ts +10 -0
  38. package/dist/types/utils/derivation-path.d.ts +19 -0
  39. package/dist/types/utils/electrum.d.ts +10 -0
  40. package/dist/types/utils/exchange-rate.d.ts +30 -0
  41. package/dist/types/utils/helpers.d.ts +23 -0
  42. package/dist/types/utils/index.d.ts +7 -0
  43. package/dist/types/utils/result.d.ts +16 -0
  44. package/dist/types/utils/transaction.d.ts +21 -0
  45. package/dist/types/utils/wallet.d.ts +47 -0
  46. package/dist/types/wallet/constants.d.ts +12 -0
  47. package/dist/types/wallet/index.d.ts +214 -0
  48. package/dist/types/wallet.js +36 -0
  49. package/dist/types/wallet.js.map +1 -0
  50. package/dist/utils/conversion.js +52 -0
  51. package/dist/utils/conversion.js.map +1 -0
  52. package/dist/utils/derivation-path.js +104 -0
  53. package/dist/utils/derivation-path.js.map +1 -0
  54. package/dist/utils/electrum.js +149 -0
  55. package/dist/utils/electrum.js.map +1 -0
  56. package/dist/utils/exchange-rate.js +49 -0
  57. package/dist/utils/exchange-rate.js.map +1 -0
  58. package/dist/utils/helpers.js +137 -0
  59. package/dist/utils/helpers.js.map +1 -0
  60. package/dist/utils/index.js +24 -0
  61. package/dist/utils/index.js.map +1 -0
  62. package/dist/utils/result.js +36 -0
  63. package/dist/utils/result.js.map +1 -0
  64. package/dist/utils/transaction.js +327 -0
  65. package/dist/utils/transaction.js.map +1 -0
  66. package/dist/utils/wallet.js +227 -0
  67. package/dist/utils/wallet.js.map +1 -0
  68. package/dist/wallet/constants.js +15 -0
  69. package/dist/wallet/constants.js.map +1 -0
  70. package/dist/wallet/index.js +2113 -0
  71. package/dist/wallet/index.js.map +1 -0
  72. package/docs/html/.nojekyll +1 -0
  73. package/docs/html/assets/highlight.css +22 -0
  74. package/docs/html/assets/main.js +58 -0
  75. package/docs/html/assets/search.js +1 -0
  76. package/docs/html/assets/style.css +1367 -0
  77. package/docs/html/classes/Electrum.html +812 -0
  78. package/docs/html/classes/Transaction.html +687 -0
  79. package/docs/html/classes/Wallet.html +2030 -0
  80. package/docs/html/enums/EAddressType.html +227 -0
  81. package/docs/html/enums/EAvailableNetworks.html +255 -0
  82. package/docs/html/enums/EBoostType.html +220 -0
  83. package/docs/html/enums/EFeeId.html +241 -0
  84. package/docs/html/enums/EPaymentType.html +220 -0
  85. package/docs/html/enums/EProtocol.html +220 -0
  86. package/docs/html/enums/EUnit.html +227 -0
  87. package/docs/html/functions/availableNetworks.html +200 -0
  88. package/docs/html/functions/constructByteCountParam.html +210 -0
  89. package/docs/html/functions/decodeOpReturnMessage.html +202 -0
  90. package/docs/html/functions/decodeRawTransaction.html +210 -0
  91. package/docs/html/functions/err.html +214 -0
  92. package/docs/html/functions/formatKeyDerivationPath.html +219 -0
  93. package/docs/html/functions/formatPeerData.html +207 -0
  94. package/docs/html/functions/generateMnemonic.html +223 -0
  95. package/docs/html/functions/generateWalletId.html +202 -0
  96. package/docs/html/functions/getAddressFromScriptPubKey.html +209 -0
  97. package/docs/html/functions/getAddressTypeFromPath.html +206 -0
  98. package/docs/html/functions/getByteCount.html +206 -0
  99. package/docs/html/functions/getDataFallback.html +207 -0
  100. package/docs/html/functions/getDefaultPort.html +209 -0
  101. package/docs/html/functions/getDefaultWalletData.html +200 -0
  102. package/docs/html/functions/getDefaultWalletDataKeys.html +200 -0
  103. package/docs/html/functions/getExchangeRates.html +200 -0
  104. package/docs/html/functions/getHighestUsedIndexFromTxHashes.html +216 -0
  105. package/docs/html/functions/getKeyDerivationPath.html +211 -0
  106. package/docs/html/functions/getKeyDerivationPathObject.html +216 -0
  107. package/docs/html/functions/getKeyDerivationPathString.html +220 -0
  108. package/docs/html/functions/getKeyValue.html +206 -0
  109. package/docs/html/functions/getPeers.html +211 -0
  110. package/docs/html/functions/getProtocolForPort.html +209 -0
  111. package/docs/html/functions/getScriptHash.html +210 -0
  112. package/docs/html/functions/getSeed.html +209 -0
  113. package/docs/html/functions/getSeedHash.html +206 -0
  114. package/docs/html/functions/getSha256.html +206 -0
  115. package/docs/html/functions/getStorageKeyValues.html +209 -0
  116. package/docs/html/functions/getTxFee.html +210 -0
  117. package/docs/html/functions/getWalletDataStorageKey.html +206 -0
  118. package/docs/html/functions/isValidBech32mEncodedString.html +211 -0
  119. package/docs/html/functions/objectKeys-1.html +211 -0
  120. package/docs/html/functions/objectsMatch.html +210 -0
  121. package/docs/html/functions/ok.html +214 -0
  122. package/docs/html/functions/parseOnChainPaymentRequest.html +204 -0
  123. package/docs/html/functions/reduceValue.html +215 -0
  124. package/docs/html/functions/removeDustOutputs.html +206 -0
  125. package/docs/html/functions/setReplaceByFee.html +210 -0
  126. package/docs/html/functions/shuffleArray.html +211 -0
  127. package/docs/html/functions/validateAddress.html +216 -0
  128. package/docs/html/functions/validateMnemonic.html +206 -0
  129. package/docs/html/functions/validateTransaction.html +206 -0
  130. package/docs/html/index.html +360 -0
  131. package/docs/html/interfaces/IAddInput.html +231 -0
  132. package/docs/html/interfaces/IAddress.html +247 -0
  133. package/docs/html/interfaces/IAddressData.html +231 -0
  134. package/docs/html/interfaces/IAddressType.html +199 -0
  135. package/docs/html/interfaces/IAddressTypeData.html +252 -0
  136. package/docs/html/interfaces/IAddresses.html +199 -0
  137. package/docs/html/interfaces/IBoostedTransaction.html +238 -0
  138. package/docs/html/interfaces/IBoostedTransactions.html +199 -0
  139. package/docs/html/interfaces/ICreateTransaction.html +224 -0
  140. package/docs/html/interfaces/ICustomGetAddress.html +231 -0
  141. package/docs/html/interfaces/ICustomGetScriptHash.html +224 -0
  142. package/docs/html/interfaces/IElectrumGetAddressBalanceRes.html +235 -0
  143. package/docs/html/interfaces/IExchangeRates.html +210 -0
  144. package/docs/html/interfaces/IFormattedPeerData.html +245 -0
  145. package/docs/html/interfaces/IFormattedTransaction.html +343 -0
  146. package/docs/html/interfaces/IFormattedTransactions.html +199 -0
  147. package/docs/html/interfaces/IGenerateAddresses.html +252 -0
  148. package/docs/html/interfaces/IGenerateAddressesResponse.html +224 -0
  149. package/docs/html/interfaces/IGetAddress.html +231 -0
  150. package/docs/html/interfaces/IGetAddressBalanceRes.html +226 -0
  151. package/docs/html/interfaces/IGetAddressByPath.html +224 -0
  152. package/docs/html/interfaces/IGetAddressHistoryResponse.html +269 -0
  153. package/docs/html/interfaces/IGetAddressResponse.html +231 -0
  154. package/docs/html/interfaces/IGetAddressScriptHashesHistoryResponse.html +245 -0
  155. package/docs/html/interfaces/IGetDerivationPath.html +259 -0
  156. package/docs/html/interfaces/IGetFeeEstimatesResponse.html +238 -0
  157. package/docs/html/interfaces/IGetHeaderResponse.html +245 -0
  158. package/docs/html/interfaces/IGetNextAvailableAddressResponse.html +238 -0
  159. package/docs/html/interfaces/IGetTransactions.html +245 -0
  160. package/docs/html/interfaces/IGetTransactionsFromInputs.html +245 -0
  161. package/docs/html/interfaces/IGetUtxosResponse.html +224 -0
  162. package/docs/html/interfaces/IHeader.html +231 -0
  163. package/docs/html/interfaces/IIndexes.html +238 -0
  164. package/docs/html/interfaces/IKeyDerivationPath.html +247 -0
  165. package/docs/html/interfaces/IKeyDerivationPathData.html +224 -0
  166. package/docs/html/interfaces/INewBlock.html +224 -0
  167. package/docs/html/interfaces/IOnchainFees.html +245 -0
  168. package/docs/html/interfaces/IOutput.html +231 -0
  169. package/docs/html/interfaces/IPeerData.html +231 -0
  170. package/docs/html/interfaces/IRbfData.html +252 -0
  171. package/docs/html/interfaces/ISend.html +224 -0
  172. package/docs/html/interfaces/ISendTransaction.html +322 -0
  173. package/docs/html/interfaces/ISendTx.html +231 -0
  174. package/docs/html/interfaces/ISetupTransaction.html +238 -0
  175. package/docs/html/interfaces/ISubscribeToAddress.html +247 -0
  176. package/docs/html/interfaces/ISubscribeToHeader.html +245 -0
  177. package/docs/html/interfaces/ITargets.html +238 -0
  178. package/docs/html/interfaces/ITransaction.html +281 -0
  179. package/docs/html/interfaces/ITxHash.html +217 -0
  180. package/docs/html/interfaces/ITxHashes.html +235 -0
  181. package/docs/html/interfaces/IUtxo.html +275 -0
  182. package/docs/html/interfaces/IVin.html +252 -0
  183. package/docs/html/interfaces/IVout.html +246 -0
  184. package/docs/html/interfaces/IWallet.html +350 -0
  185. package/docs/html/interfaces/IWalletData.html +343 -0
  186. package/docs/html/types/ElectrumConnectionPubSub.html +233 -0
  187. package/docs/html/types/ElectrumConnectionSubscription.html +204 -0
  188. package/docs/html/types/InputData.html +203 -0
  189. package/docs/html/types/ObjectKeys.html +198 -0
  190. package/docs/html/types/Result.html +201 -0
  191. package/docs/html/types/TAddressIndexInfo.html +204 -0
  192. package/docs/html/types/TAddressLabel.html +193 -0
  193. package/docs/html/types/TAddressType.html +193 -0
  194. package/docs/html/types/TAddressTypeContent.html +198 -0
  195. package/docs/html/types/TAddressTypes.html +193 -0
  196. package/docs/html/types/TAvailableNetworks.html +193 -0
  197. package/docs/html/types/TConnectToElectrumRes.html +193 -0
  198. package/docs/html/types/TDecodeRawTx.html +214 -0
  199. package/docs/html/types/TElectrumNetworks.html +193 -0
  200. package/docs/html/types/TGetAddressHistory.html +200 -0
  201. package/docs/html/types/TGetByteCountInput.html +193 -0
  202. package/docs/html/types/TGetByteCountInputs.html +193 -0
  203. package/docs/html/types/TGetByteCountOutput.html +193 -0
  204. package/docs/html/types/TGetByteCountOutputs.html +193 -0
  205. package/docs/html/types/TGetData.html +211 -0
  206. package/docs/html/types/TGetTotalFeeObj.html +204 -0
  207. package/docs/html/types/TKeyDerivationAccount.html +193 -0
  208. package/docs/html/types/TKeyDerivationChange.html +193 -0
  209. package/docs/html/types/TKeyDerivationCoinType.html +193 -0
  210. package/docs/html/types/TKeyDerivationIndex.html +193 -0
  211. package/docs/html/types/TKeyDerivationPurpose.html +193 -0
  212. package/docs/html/types/TMessageDataMap.html +210 -0
  213. package/docs/html/types/TMessageKeys.html +193 -0
  214. package/docs/html/types/TOnMessage.html +213 -0
  215. package/docs/html/types/TProcessUnconfirmedTransactions.html +202 -0
  216. package/docs/html/types/TProtocol.html +193 -0
  217. package/docs/html/types/TServer.html +204 -0
  218. package/docs/html/types/TSetData.html +213 -0
  219. package/docs/html/types/TSetupTransactionResponse.html +193 -0
  220. package/docs/html/types/TStorage.html +200 -0
  221. package/docs/html/types/TSubscribedReceive.html +193 -0
  222. package/docs/html/types/TTransactionMessage.html +198 -0
  223. package/docs/html/types/TTxResponse.html +206 -0
  224. package/docs/html/types/TTxResult.html +200 -0
  225. package/docs/html/types/TUnspentAddressScriptHashData.html +198 -0
  226. package/docs/html/types/TWalletDataKeys.html +193 -0
  227. package/docs/html/variables/defaultElectrumPorts.html +193 -0
  228. package/docs/html/variables/electrumConnection.html +199 -0
  229. package/docs/html/variables/mostUsedExchangeTickers.html +241 -0
  230. package/docs/markdown/.nojekyll +1 -0
  231. package/docs/markdown/README.md +1875 -0
  232. package/docs/markdown/classes/Electrum.md +718 -0
  233. package/docs/markdown/classes/Transaction.md +536 -0
  234. package/docs/markdown/classes/Wallet.md +2189 -0
  235. package/docs/markdown/enums/EAddressType.md +41 -0
  236. package/docs/markdown/enums/EAvailableNetworks.md +85 -0
  237. package/docs/markdown/enums/EBoostType.md +30 -0
  238. package/docs/markdown/enums/EFeeId.md +63 -0
  239. package/docs/markdown/enums/EPaymentType.md +30 -0
  240. package/docs/markdown/enums/EProtocol.md +30 -0
  241. package/docs/markdown/enums/EUnit.md +41 -0
  242. package/docs/markdown/interfaces/IAddInput.md +41 -0
  243. package/docs/markdown/interfaces/IAddress.md +69 -0
  244. package/docs/markdown/interfaces/IAddressData.md +41 -0
  245. package/docs/markdown/interfaces/IAddressType.md +7 -0
  246. package/docs/markdown/interfaces/IAddressTypeData.md +74 -0
  247. package/docs/markdown/interfaces/IAddresses.md +7 -0
  248. package/docs/markdown/interfaces/IBoostedTransaction.md +52 -0
  249. package/docs/markdown/interfaces/IBoostedTransactions.md +7 -0
  250. package/docs/markdown/interfaces/ICreateTransaction.md +30 -0
  251. package/docs/markdown/interfaces/ICustomGetAddress.md +41 -0
  252. package/docs/markdown/interfaces/ICustomGetScriptHash.md +30 -0
  253. package/docs/markdown/interfaces/IElectrumGetAddressBalanceRes.md +55 -0
  254. package/docs/markdown/interfaces/IExchangeRates.md +7 -0
  255. package/docs/markdown/interfaces/IFormattedPeerData.md +63 -0
  256. package/docs/markdown/interfaces/IFormattedTransaction.md +217 -0
  257. package/docs/markdown/interfaces/IFormattedTransactions.md +7 -0
  258. package/docs/markdown/interfaces/IGenerateAddresses.md +74 -0
  259. package/docs/markdown/interfaces/IGenerateAddressesResponse.md +30 -0
  260. package/docs/markdown/interfaces/IGetAddress.md +41 -0
  261. package/docs/markdown/interfaces/IGetAddressBalanceRes.md +36 -0
  262. package/docs/markdown/interfaces/IGetAddressByPath.md +30 -0
  263. package/docs/markdown/interfaces/IGetAddressHistoryResponse.md +121 -0
  264. package/docs/markdown/interfaces/IGetAddressResponse.md +41 -0
  265. package/docs/markdown/interfaces/IGetAddressScriptHashesHistoryResponse.md +63 -0
  266. package/docs/markdown/interfaces/IGetDerivationPath.md +100 -0
  267. package/docs/markdown/interfaces/IGetFeeEstimatesResponse.md +52 -0
  268. package/docs/markdown/interfaces/IGetHeaderResponse.md +63 -0
  269. package/docs/markdown/interfaces/IGetNextAvailableAddressResponse.md +52 -0
  270. package/docs/markdown/interfaces/IGetTransactions.md +63 -0
  271. package/docs/markdown/interfaces/IGetTransactionsFromInputs.md +63 -0
  272. package/docs/markdown/interfaces/IGetUtxosResponse.md +30 -0
  273. package/docs/markdown/interfaces/IHeader.md +41 -0
  274. package/docs/markdown/interfaces/IIndexes.md +52 -0
  275. package/docs/markdown/interfaces/IKeyDerivationPath.md +69 -0
  276. package/docs/markdown/interfaces/IKeyDerivationPathData.md +30 -0
  277. package/docs/markdown/interfaces/INewBlock.md +30 -0
  278. package/docs/markdown/interfaces/IOnchainFees.md +63 -0
  279. package/docs/markdown/interfaces/IOutput.md +41 -0
  280. package/docs/markdown/interfaces/IPeerData.md +41 -0
  281. package/docs/markdown/interfaces/IRbfData.md +74 -0
  282. package/docs/markdown/interfaces/ISend.md +30 -0
  283. package/docs/markdown/interfaces/ISendTransaction.md +184 -0
  284. package/docs/markdown/interfaces/ISendTx.md +41 -0
  285. package/docs/markdown/interfaces/ISetupTransaction.md +52 -0
  286. package/docs/markdown/interfaces/ISubscribeToAddress.md +60 -0
  287. package/docs/markdown/interfaces/ISubscribeToHeader.md +59 -0
  288. package/docs/markdown/interfaces/ITargets.md +52 -0
  289. package/docs/markdown/interfaces/ITransaction.md +88 -0
  290. package/docs/markdown/interfaces/ITxHash.md +19 -0
  291. package/docs/markdown/interfaces/ITxHashes.md +55 -0
  292. package/docs/markdown/interfaces/IUtxo.md +112 -0
  293. package/docs/markdown/interfaces/IVin.md +70 -0
  294. package/docs/markdown/interfaces/IVout.md +52 -0
  295. package/docs/markdown/interfaces/IWallet.md +209 -0
  296. package/docs/markdown/interfaces/IWalletData.md +217 -0
  297. package/example/helpers.ts +76 -0
  298. package/example/index.ts +77 -0
  299. package/package.json +69 -0
  300. package/src/electrum/constants.ts +28 -0
  301. package/src/electrum/index.ts +838 -0
  302. package/src/index.ts +6 -0
  303. package/src/shapes/electrum.ts +13 -0
  304. package/src/shapes/index.ts +2 -0
  305. package/src/shapes/wallet.ts +133 -0
  306. package/src/transaction/index.ts +1078 -0
  307. package/src/types/electrum.ts +139 -0
  308. package/src/types/index.ts +3 -0
  309. package/src/types/transaction.ts +58 -0
  310. package/src/types/wallet.ts +503 -0
  311. package/src/utils/conversion.ts +88 -0
  312. package/src/utils/derivation-path.ts +171 -0
  313. package/src/utils/electrum.ts +188 -0
  314. package/src/utils/exchange-rate.ts +70 -0
  315. package/src/utils/helpers.ts +191 -0
  316. package/src/utils/index.ts +7 -0
  317. package/src/utils/result.ts +79 -0
  318. package/src/utils/transaction.ts +417 -0
  319. package/src/utils/wallet.ts +351 -0
  320. package/src/wallet/constants.ts +24 -0
  321. package/src/wallet/index.ts +3304 -0
  322. package/tests/constants.ts +9 -0
  323. package/tests/derivation.test.ts +146 -0
  324. package/tests/electrum.test.ts +137 -0
  325. package/tests/storage.test.ts +222 -0
  326. package/tests/transaction.test.ts +187 -0
  327. package/tests/wallet.test.ts +307 -0
  328. package/tsconfig.json +32 -0
  329. package/typedoc.json +5 -0
@@ -0,0 +1,209 @@
1
+ [beignet](../README.md) / IWallet
2
+
3
+ # Interface: IWallet
4
+
5
+ ## Table of contents
6
+
7
+ ### Properties
8
+
9
+ - [addressType](IWallet.md#addresstype)
10
+ - [customGetAddress](IWallet.md#customgetaddress)
11
+ - [customGetScriptHash](IWallet.md#customgetscripthash)
12
+ - [data](IWallet.md#data)
13
+ - [electrumOptions](IWallet.md#electrumoptions)
14
+ - [id](IWallet.md#id)
15
+ - [mnemonic](IWallet.md#mnemonic)
16
+ - [name](IWallet.md#name)
17
+ - [network](IWallet.md#network)
18
+ - [onMessage](IWallet.md#onmessage)
19
+ - [passphrase](IWallet.md#passphrase)
20
+ - [rbf](IWallet.md#rbf)
21
+ - [remainOffline](IWallet.md#remainoffline)
22
+ - [selectedFeeId](IWallet.md#selectedfeeid)
23
+ - [storage](IWallet.md#storage)
24
+
25
+ ## Properties
26
+
27
+ ### addressType
28
+
29
+ • `Optional` **addressType**: [`EAddressType`](../enums/EAddressType.md)
30
+
31
+ #### Defined in
32
+
33
+ [types/wallet.ts:187](https://github.com/synonymdev/beignet/blob/7c83290/src/types/wallet.ts#L187)
34
+
35
+ ___
36
+
37
+ ### customGetAddress
38
+
39
+ • `Optional` **customGetAddress**: (`data`: [`ICustomGetAddress`](ICustomGetAddress.md)) => `Promise`\<[`Result`](../README.md#result)\<[`IGetAddressResponse`](IGetAddressResponse.md)\>\>
40
+
41
+ #### Type declaration
42
+
43
+ ▸ (`data`): `Promise`\<[`Result`](../README.md#result)\<[`IGetAddressResponse`](IGetAddressResponse.md)\>\>
44
+
45
+ ##### Parameters
46
+
47
+ | Name | Type |
48
+ | :------ | :------ |
49
+ | `data` | [`ICustomGetAddress`](ICustomGetAddress.md) |
50
+
51
+ ##### Returns
52
+
53
+ `Promise`\<[`Result`](../README.md#result)\<[`IGetAddressResponse`](IGetAddressResponse.md)\>\>
54
+
55
+ #### Defined in
56
+
57
+ [types/wallet.ts:197](https://github.com/synonymdev/beignet/blob/7c83290/src/types/wallet.ts#L197)
58
+
59
+ ___
60
+
61
+ ### customGetScriptHash
62
+
63
+ • `Optional` **customGetScriptHash**: (`data`: [`ICustomGetScriptHash`](ICustomGetScriptHash.md)) => `Promise`\<`string`\>
64
+
65
+ #### Type declaration
66
+
67
+ ▸ (`data`): `Promise`\<`string`\>
68
+
69
+ ##### Parameters
70
+
71
+ | Name | Type |
72
+ | :------ | :------ |
73
+ | `data` | [`ICustomGetScriptHash`](ICustomGetScriptHash.md) |
74
+
75
+ ##### Returns
76
+
77
+ `Promise`\<`string`\>
78
+
79
+ #### Defined in
80
+
81
+ [types/wallet.ts:200](https://github.com/synonymdev/beignet/blob/7c83290/src/types/wallet.ts#L200)
82
+
83
+ ___
84
+
85
+ ### data
86
+
87
+ • `Optional` **data**: [`IWalletData`](IWalletData.md)
88
+
89
+ #### Defined in
90
+
91
+ [types/wallet.ts:188](https://github.com/synonymdev/beignet/blob/7c83290/src/types/wallet.ts#L188)
92
+
93
+ ___
94
+
95
+ ### electrumOptions
96
+
97
+ • `Optional` **electrumOptions**: `Object`
98
+
99
+ #### Type declaration
100
+
101
+ | Name | Type |
102
+ | :------ | :------ |
103
+ | `net?` | `Server` |
104
+ | `servers?` | [`TServer`](../README.md#tserver) \| [`TServer`](../README.md#tserver)[] |
105
+ | `tls?` | `TLSSocket` |
106
+
107
+ #### Defined in
108
+
109
+ [types/wallet.ts:190](https://github.com/synonymdev/beignet/blob/7c83290/src/types/wallet.ts#L190)
110
+
111
+ ___
112
+
113
+ ### id
114
+
115
+ • `Optional` **id**: `string`
116
+
117
+ #### Defined in
118
+
119
+ [types/wallet.ts:183](https://github.com/synonymdev/beignet/blob/7c83290/src/types/wallet.ts#L183)
120
+
121
+ ___
122
+
123
+ ### mnemonic
124
+
125
+ • **mnemonic**: `string`
126
+
127
+ #### Defined in
128
+
129
+ [types/wallet.ts:182](https://github.com/synonymdev/beignet/blob/7c83290/src/types/wallet.ts#L182)
130
+
131
+ ___
132
+
133
+ ### name
134
+
135
+ • `Optional` **name**: `string`
136
+
137
+ #### Defined in
138
+
139
+ [types/wallet.ts:184](https://github.com/synonymdev/beignet/blob/7c83290/src/types/wallet.ts#L184)
140
+
141
+ ___
142
+
143
+ ### network
144
+
145
+ • `Optional` **network**: [`EAvailableNetworks`](../enums/EAvailableNetworks.md)
146
+
147
+ #### Defined in
148
+
149
+ [types/wallet.ts:186](https://github.com/synonymdev/beignet/blob/7c83290/src/types/wallet.ts#L186)
150
+
151
+ ___
152
+
153
+ ### onMessage
154
+
155
+ • `Optional` **onMessage**: [`TOnMessage`](../README.md#tonmessage)
156
+
157
+ #### Defined in
158
+
159
+ [types/wallet.ts:196](https://github.com/synonymdev/beignet/blob/7c83290/src/types/wallet.ts#L196)
160
+
161
+ ___
162
+
163
+ ### passphrase
164
+
165
+ • `Optional` **passphrase**: `string`
166
+
167
+ #### Defined in
168
+
169
+ [types/wallet.ts:185](https://github.com/synonymdev/beignet/blob/7c83290/src/types/wallet.ts#L185)
170
+
171
+ ___
172
+
173
+ ### rbf
174
+
175
+ • `Optional` **rbf**: `boolean`
176
+
177
+ #### Defined in
178
+
179
+ [types/wallet.ts:201](https://github.com/synonymdev/beignet/blob/7c83290/src/types/wallet.ts#L201)
180
+
181
+ ___
182
+
183
+ ### remainOffline
184
+
185
+ • `Optional` **remainOffline**: `boolean`
186
+
187
+ #### Defined in
188
+
189
+ [types/wallet.ts:195](https://github.com/synonymdev/beignet/blob/7c83290/src/types/wallet.ts#L195)
190
+
191
+ ___
192
+
193
+ ### selectedFeeId
194
+
195
+ • `Optional` **selectedFeeId**: [`EFeeId`](../enums/EFeeId.md)
196
+
197
+ #### Defined in
198
+
199
+ [types/wallet.ts:202](https://github.com/synonymdev/beignet/blob/7c83290/src/types/wallet.ts#L202)
200
+
201
+ ___
202
+
203
+ ### storage
204
+
205
+ • `Optional` **storage**: [`TStorage`](../README.md#tstorage)
206
+
207
+ #### Defined in
208
+
209
+ [types/wallet.ts:189](https://github.com/synonymdev/beignet/blob/7c83290/src/types/wallet.ts#L189)
@@ -0,0 +1,217 @@
1
+ [beignet](../README.md) / IWalletData
2
+
3
+ # Interface: IWalletData
4
+
5
+ ## Table of contents
6
+
7
+ ### Properties
8
+
9
+ - [addressIndex](IWalletData.md#addressindex)
10
+ - [addressType](IWalletData.md#addresstype)
11
+ - [addresses](IWalletData.md#addresses)
12
+ - [balance](IWalletData.md#balance)
13
+ - [blacklistedUtxos](IWalletData.md#blacklistedutxos)
14
+ - [boostedTransactions](IWalletData.md#boostedtransactions)
15
+ - [changeAddressIndex](IWalletData.md#changeaddressindex)
16
+ - [changeAddresses](IWalletData.md#changeaddresses)
17
+ - [exchangeRates](IWalletData.md#exchangerates)
18
+ - [feeEstimates](IWalletData.md#feeestimates)
19
+ - [header](IWalletData.md#header)
20
+ - [id](IWalletData.md#id)
21
+ - [lastUsedAddressIndex](IWalletData.md#lastusedaddressindex)
22
+ - [lastUsedChangeAddressIndex](IWalletData.md#lastusedchangeaddressindex)
23
+ - [selectedFeeId](IWalletData.md#selectedfeeid)
24
+ - [transaction](IWalletData.md#transaction)
25
+ - [transactions](IWalletData.md#transactions)
26
+ - [unconfirmedTransactions](IWalletData.md#unconfirmedtransactions)
27
+ - [utxos](IWalletData.md#utxos)
28
+
29
+ ## Properties
30
+
31
+ ### addressIndex
32
+
33
+ • **addressIndex**: [`TAddressTypeContent`](../README.md#taddresstypecontent)\<[`IAddress`](IAddress.md)\>
34
+
35
+ #### Defined in
36
+
37
+ [types/wallet.ts:155](https://github.com/synonymdev/beignet/blob/7c83290/src/types/wallet.ts#L155)
38
+
39
+ ___
40
+
41
+ ### addressType
42
+
43
+ • **addressType**: [`EAddressType`](../enums/EAddressType.md)
44
+
45
+ #### Defined in
46
+
47
+ [types/wallet.ts:151](https://github.com/synonymdev/beignet/blob/7c83290/src/types/wallet.ts#L151)
48
+
49
+ ___
50
+
51
+ ### addresses
52
+
53
+ • **addresses**: [`TAddressTypeContent`](../README.md#taddresstypecontent)\<[`IAddresses`](IAddresses.md)\>
54
+
55
+ #### Defined in
56
+
57
+ [types/wallet.ts:153](https://github.com/synonymdev/beignet/blob/7c83290/src/types/wallet.ts#L153)
58
+
59
+ ___
60
+
61
+ ### balance
62
+
63
+ • **balance**: `number`
64
+
65
+ #### Defined in
66
+
67
+ [types/wallet.ts:165](https://github.com/synonymdev/beignet/blob/7c83290/src/types/wallet.ts#L165)
68
+
69
+ ___
70
+
71
+ ### blacklistedUtxos
72
+
73
+ • **blacklistedUtxos**: [`IUtxo`](IUtxo.md)[]
74
+
75
+ #### Defined in
76
+
77
+ [types/wallet.ts:160](https://github.com/synonymdev/beignet/blob/7c83290/src/types/wallet.ts#L160)
78
+
79
+ ___
80
+
81
+ ### boostedTransactions
82
+
83
+ • **boostedTransactions**: [`IBoostedTransactions`](IBoostedTransactions.md)
84
+
85
+ #### Defined in
86
+
87
+ [types/wallet.ts:163](https://github.com/synonymdev/beignet/blob/7c83290/src/types/wallet.ts#L163)
88
+
89
+ ___
90
+
91
+ ### changeAddressIndex
92
+
93
+ • **changeAddressIndex**: [`TAddressTypeContent`](../README.md#taddresstypecontent)\<[`IAddress`](IAddress.md)\>
94
+
95
+ #### Defined in
96
+
97
+ [types/wallet.ts:156](https://github.com/synonymdev/beignet/blob/7c83290/src/types/wallet.ts#L156)
98
+
99
+ ___
100
+
101
+ ### changeAddresses
102
+
103
+ • **changeAddresses**: [`TAddressTypeContent`](../README.md#taddresstypecontent)\<[`IAddresses`](IAddresses.md)\>
104
+
105
+ #### Defined in
106
+
107
+ [types/wallet.ts:154](https://github.com/synonymdev/beignet/blob/7c83290/src/types/wallet.ts#L154)
108
+
109
+ ___
110
+
111
+ ### exchangeRates
112
+
113
+ • **exchangeRates**: [`IExchangeRates`](IExchangeRates.md)
114
+
115
+ #### Defined in
116
+
117
+ [types/wallet.ts:167](https://github.com/synonymdev/beignet/blob/7c83290/src/types/wallet.ts#L167)
118
+
119
+ ___
120
+
121
+ ### feeEstimates
122
+
123
+ • **feeEstimates**: [`IOnchainFees`](IOnchainFees.md)
124
+
125
+ #### Defined in
126
+
127
+ [types/wallet.ts:168](https://github.com/synonymdev/beignet/blob/7c83290/src/types/wallet.ts#L168)
128
+
129
+ ___
130
+
131
+ ### header
132
+
133
+ • **header**: [`IHeader`](IHeader.md)
134
+
135
+ #### Defined in
136
+
137
+ [types/wallet.ts:152](https://github.com/synonymdev/beignet/blob/7c83290/src/types/wallet.ts#L152)
138
+
139
+ ___
140
+
141
+ ### id
142
+
143
+ • **id**: `string`
144
+
145
+ #### Defined in
146
+
147
+ [types/wallet.ts:150](https://github.com/synonymdev/beignet/blob/7c83290/src/types/wallet.ts#L150)
148
+
149
+ ___
150
+
151
+ ### lastUsedAddressIndex
152
+
153
+ • **lastUsedAddressIndex**: [`TAddressTypeContent`](../README.md#taddresstypecontent)\<[`IAddress`](IAddress.md)\>
154
+
155
+ #### Defined in
156
+
157
+ [types/wallet.ts:157](https://github.com/synonymdev/beignet/blob/7c83290/src/types/wallet.ts#L157)
158
+
159
+ ___
160
+
161
+ ### lastUsedChangeAddressIndex
162
+
163
+ • **lastUsedChangeAddressIndex**: [`TAddressTypeContent`](../README.md#taddresstypecontent)\<[`IAddress`](IAddress.md)\>
164
+
165
+ #### Defined in
166
+
167
+ [types/wallet.ts:158](https://github.com/synonymdev/beignet/blob/7c83290/src/types/wallet.ts#L158)
168
+
169
+ ___
170
+
171
+ ### selectedFeeId
172
+
173
+ • **selectedFeeId**: [`EFeeId`](../enums/EFeeId.md)
174
+
175
+ #### Defined in
176
+
177
+ [types/wallet.ts:166](https://github.com/synonymdev/beignet/blob/7c83290/src/types/wallet.ts#L166)
178
+
179
+ ___
180
+
181
+ ### transaction
182
+
183
+ • **transaction**: [`ISendTransaction`](ISendTransaction.md)
184
+
185
+ #### Defined in
186
+
187
+ [types/wallet.ts:164](https://github.com/synonymdev/beignet/blob/7c83290/src/types/wallet.ts#L164)
188
+
189
+ ___
190
+
191
+ ### transactions
192
+
193
+ • **transactions**: [`IFormattedTransactions`](IFormattedTransactions.md)
194
+
195
+ #### Defined in
196
+
197
+ [types/wallet.ts:162](https://github.com/synonymdev/beignet/blob/7c83290/src/types/wallet.ts#L162)
198
+
199
+ ___
200
+
201
+ ### unconfirmedTransactions
202
+
203
+ • **unconfirmedTransactions**: [`IFormattedTransactions`](IFormattedTransactions.md)
204
+
205
+ #### Defined in
206
+
207
+ [types/wallet.ts:161](https://github.com/synonymdev/beignet/blob/7c83290/src/types/wallet.ts#L161)
208
+
209
+ ___
210
+
211
+ ### utxos
212
+
213
+ • **utxos**: [`IUtxo`](IUtxo.md)[]
214
+
215
+ #### Defined in
216
+
217
+ [types/wallet.ts:159](https://github.com/synonymdev/beignet/blob/7c83290/src/types/wallet.ts#L159)
@@ -0,0 +1,76 @@
1
+ import { promises as fs } from 'fs';
2
+ import {
3
+ TGetData,
4
+ TSetData,
5
+ IWalletData,
6
+ EAvailableNetworks,
7
+ EProtocol
8
+ } from '../src';
9
+ import { err, Result, ok } from '../src';
10
+ import { getDefaultWalletData } from '../src';
11
+
12
+ export const getData: TGetData = async <K extends keyof IWalletData>(
13
+ key: string
14
+ ): Promise<Result<IWalletData[K]>> => {
15
+ try {
16
+ const data = await fs.readFile(`example/walletData/${key}.json`, 'utf8');
17
+ const walletData: IWalletData[K] = JSON.parse(data);
18
+ if (walletData) return ok(walletData);
19
+ const defaultWalletData = getDefaultWalletData();
20
+ return ok(defaultWalletData[key]);
21
+ } catch (e) {
22
+ const defaultWalletData = getDefaultWalletData();
23
+ return ok(defaultWalletData[key]);
24
+ }
25
+ };
26
+
27
+ export const setData: TSetData = async <K extends keyof IWalletData>(
28
+ key: string,
29
+ value: IWalletData[K]
30
+ ): Promise<Result<boolean>> => {
31
+ try {
32
+ const dir = 'example/walletData';
33
+ // Ensure that the directory exists
34
+ await fs.mkdir(dir, { recursive: true });
35
+
36
+ await fs.writeFile(`${dir}/${key}.json`, JSON.stringify(value, null, 2));
37
+ return ok(true);
38
+ } catch (e) {
39
+ return err(e);
40
+ }
41
+ };
42
+
43
+ export const deleteDirectory = async (
44
+ dir = 'example/walletData'
45
+ ): Promise<void> => {
46
+ try {
47
+ await fs.rm(dir, { recursive: true, force: true });
48
+ } catch (e) {
49
+ console.error(`Error deleting directory ${dir}: ${e}`);
50
+ }
51
+ };
52
+
53
+ export const onMessage = (id, data): void => {
54
+ console.log(id);
55
+ console.dir(data, { depth: null });
56
+ };
57
+
58
+ export const servers = {
59
+ [EAvailableNetworks.mainnet]: [
60
+ {
61
+ host: '35.187.18.233',
62
+ ssl: 8900,
63
+ tcp: 8911,
64
+ protocol: EProtocol.ssl
65
+ }
66
+ ],
67
+ [EAvailableNetworks.testnet]: [],
68
+ [EAvailableNetworks.regtest]: [
69
+ {
70
+ host: '35.233.47.252',
71
+ ssl: 18484,
72
+ tcp: 18483,
73
+ protocol: EProtocol.tcp
74
+ }
75
+ ]
76
+ };
@@ -0,0 +1,77 @@
1
+ import { EAvailableNetworks, Wallet } from '../src';
2
+ import { getData, onMessage, servers, setData } from './helpers';
3
+ import * as repl from 'repl';
4
+ //import { generateMnemonic } from 'bip39';
5
+ //const mnemonic = generateMnemonic();
6
+
7
+ const mnemonic =
8
+ 'develop under powder delay tunnel kite finger spend deal tiger pluck cherry';
9
+
10
+ const network: EAvailableNetworks = EAvailableNetworks.regtest;
11
+
12
+ const runExample = async (): Promise<void> => {
13
+ // Create Wallet
14
+ const createWalletResponse = await Wallet.create({
15
+ mnemonic,
16
+ onMessage,
17
+ network,
18
+ storage: {
19
+ getData,
20
+ setData
21
+ },
22
+ electrumOptions: {
23
+ servers: servers[network]
24
+ }
25
+ });
26
+ if (createWalletResponse.isErr()) return;
27
+ const wallet = createWalletResponse.value;
28
+
29
+ // Get the wallet's balance.
30
+ const balance = wallet.getBalance();
31
+ console.log('\nBalance: ', balance);
32
+
33
+ // Get a receiving address.
34
+ const address = await wallet.getAddress();
35
+ console.log('\nAddress:', address);
36
+
37
+ // Get fee information to perform a transaction.
38
+ // const feeInfo = wallet.getFeeInfo({ satsPerByte: 5 });
39
+ // if (feeInfo.isErr()) return;
40
+ // console.log('\nFee Info:', feeInfo.value);
41
+
42
+ // Get fee estimate in sats for a given satsPerByte to perform a transaction.
43
+ // This is useful for quickly calculating how many sats are needed to perform a transaction when using a slider.
44
+ // const txFeeInSats = getTxFee({
45
+ // satsPerByte: 5,
46
+ // transactionByteCount: feeInfo.value.transactionByteCount
47
+ // });
48
+ // console.log('\nFee In Sats:', txFeeInSats);
49
+
50
+ // Create a transaction.
51
+ // const sendRes = await wallet.send({
52
+ // address,
53
+ // amount: 5000,
54
+ // satsPerByte: 5,
55
+ // broadcast: false // Mostly set to false for testing, but can also be used to return the raw transaction hex.
56
+ // });
57
+ // if (sendRes.isErr()) return;
58
+ // console.log('\nSend Res:', sendRes.value);
59
+
60
+ // Decode the transaction to verify prior to broadcasting.
61
+ // const decodeRes = decodeRawTransaction(sendRes.value, network);
62
+ // if (decodeRes.isErr()) return;
63
+ // console.log('\nDecode Transaction:');
64
+ // console.dir(decodeRes.value, { depth: null });
65
+
66
+ // Broadcast the transaction.
67
+ // const broadcastRes = await wallet.electrum.broadcastTransaction({
68
+ // rawTx: createRes.value.hex
69
+ // });
70
+ // console.log('\nBroadcast Response:', broadcastRes);
71
+ // if (broadcastRes.isErr()) return;
72
+
73
+ const r = repl.start('> ');
74
+ r.context.wallet = wallet;
75
+ };
76
+
77
+ runExample().then();
package/package.json ADDED
@@ -0,0 +1,69 @@
1
+ {
2
+ "name": "beignet",
3
+ "version": "0.0.1",
4
+ "description": "A self-custodial, JS Bitcoin wallet management library.",
5
+ "main": "dist/index.js",
6
+ "scripts": {
7
+ "test": "yarn build && env mocha --exit -r ts-node/register 'tests/**/*.ts'",
8
+ "test:wallet": "yarn build && env mocha --exit -r ts-node/register 'tests/wallet.test.ts'",
9
+ "test:electrum": "yarn build && env mocha --exit -r ts-node/register 'tests/electrum.test.ts'",
10
+ "test:derivation": " yarn build && env mocha --exit -r ts-node/register 'tests/derivation.test.ts'",
11
+ "test:transaction": " yarn build && env mocha --exit -r ts-node/register 'tests/transaction.test.ts'",
12
+ "test:storage": "yarn build && env mocha --exit -r ts-node/register 'tests/storage.test.ts'",
13
+ "example": "ts-node example",
14
+ "lint": "eslint . --ext .js,.jsx,.ts,.tsx",
15
+ "lint:check": "eslint . --ext .js,.jsx,.ts,.tsx",
16
+ "lint:fix": "eslint . --fix --ext .js,.jsx,.ts,.tsx",
17
+ "build": "tsc",
18
+ "docs:markdown": "npx typedoc --plugin typedoc-plugin-markdown --out docs/markdown src/index.ts",
19
+ "docs:html": "npx typedoc --out docs/html",
20
+ "docs": "npm run build && npm run docs:markdown && npm run docs:html"
21
+ },
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "git+https://github.com/synonymdev/beignet.git",
25
+ "baseUrl": "https://github.com/synonymdev/beignet"
26
+ },
27
+ "keywords": [
28
+ "Bitcoin",
29
+ "wallet"
30
+ ],
31
+ "types": "dist/types/index.d.ts",
32
+ "author": "synonymdev",
33
+ "license": "MIT",
34
+ "bugs": {
35
+ "url": "https://github.com/synonymdev/beignet/issues"
36
+ },
37
+ "homepage": "https://github.com/synonymdev/beignet#readme",
38
+ "dependencies": {
39
+ "@bitcoinerlab/secp256k1": "^1.0.5",
40
+ "bech32": "^2.0.0",
41
+ "bip21": "^2.0.3",
42
+ "bip32": "^4.0.0",
43
+ "bip39": "^3.1.0",
44
+ "bitcoin-address-validation": "^2.2.3",
45
+ "bitcoin-units": "^0.3.0",
46
+ "bitcoinjs-lib": "6.1.4",
47
+ "ecpair": "^2.1.0",
48
+ "lodash.clonedeep": "^4.5.0",
49
+ "net": "^1.0.2",
50
+ "rn-electrum-client": "^0.0.10"
51
+ },
52
+ "devDependencies": {
53
+ "@types/chai": "^4.3.0",
54
+ "@types/mocha": "^9.0.0",
55
+ "@types/node": "^20.4.10",
56
+ "@typescript-eslint/eslint-plugin": "^5.6.0",
57
+ "@typescript-eslint/parser": "^5.6.0",
58
+ "chai": "^4.3.4",
59
+ "eslint": "^8.4.1",
60
+ "eslint-config-prettier": "^9.0.0",
61
+ "eslint-plugin-prettier": "^5.0.0",
62
+ "mocha": "10.1.0",
63
+ "prettier": "^3.0.2",
64
+ "ts-node": "^10.4.0",
65
+ "typedoc": "^0.24.8",
66
+ "typedoc-plugin-markdown": "^3.15.4",
67
+ "typescript": "4.9"
68
+ }
69
+ }
@@ -0,0 +1,28 @@
1
+ export const TEST_MNEMONIC =
2
+ 'decorate grass round powder swarm syrup identify resemble mass online grunt cruise';
3
+ export const TESTNET_PEERS = [
4
+ {
5
+ host: 'testnet.hsmiths.com',
6
+ ssl: 53012,
7
+ tcp: 53012,
8
+ protocol: 'ssl'
9
+ },
10
+ {
11
+ host: 'tn.not.fyi',
12
+ ssl: 55002,
13
+ tcp: 55002,
14
+ protocol: 'ssl'
15
+ },
16
+ {
17
+ host: 'testnet.aranguren.org',
18
+ ssl: 51002,
19
+ tcp: 51001,
20
+ protocol: 'ssl'
21
+ },
22
+ {
23
+ host: 'blackie.c3-soft.com',
24
+ ssl: 57006,
25
+ tcp: 57006,
26
+ protocol: 'ssl'
27
+ }
28
+ ];