@bsv/sdk 1.3.12 → 1.3.14

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 (607) hide show
  1. package/dist/cjs/package.json +15 -3
  2. package/dist/cjs/src/auth/Peer.js +83 -57
  3. package/dist/cjs/src/auth/Peer.js.map +1 -1
  4. package/dist/cjs/src/auth/SessionManager.js +14 -9
  5. package/dist/cjs/src/auth/SessionManager.js.map +1 -1
  6. package/dist/cjs/src/auth/certificates/Certificate.js +16 -10
  7. package/dist/cjs/src/auth/certificates/Certificate.js.map +1 -1
  8. package/dist/cjs/src/auth/certificates/MasterCertificate.js +25 -23
  9. package/dist/cjs/src/auth/certificates/MasterCertificate.js.map +1 -1
  10. package/dist/cjs/src/auth/certificates/VerifiableCertificate.js +2 -2
  11. package/dist/cjs/src/auth/certificates/VerifiableCertificate.js.map +1 -1
  12. package/dist/cjs/src/auth/certificates/__tests/CompletedProtoWallet.js +62 -46
  13. package/dist/cjs/src/auth/certificates/__tests/CompletedProtoWallet.js.map +1 -1
  14. package/dist/cjs/src/auth/clients/AuthFetch.js +1 -0
  15. package/dist/cjs/src/auth/clients/AuthFetch.js.map +1 -1
  16. package/dist/cjs/src/auth/transports/SimplifiedFetchTransport.js +70 -43
  17. package/dist/cjs/src/auth/transports/SimplifiedFetchTransport.js.map +1 -1
  18. package/dist/cjs/src/auth/utils/createNonce.js +2 -1
  19. package/dist/cjs/src/auth/utils/createNonce.js.map +1 -1
  20. package/dist/cjs/src/auth/utils/getVerifiableCertificates.js.map +1 -1
  21. package/dist/cjs/src/auth/utils/validateCertificates.js +5 -2
  22. package/dist/cjs/src/auth/utils/validateCertificates.js.map +1 -1
  23. package/dist/cjs/src/auth/utils/verifyNonce.js +2 -1
  24. package/dist/cjs/src/auth/utils/verifyNonce.js.map +1 -1
  25. package/dist/cjs/src/compat/BSM.js +7 -17
  26. package/dist/cjs/src/compat/BSM.js.map +1 -1
  27. package/dist/cjs/src/compat/ECIES.js +172 -133
  28. package/dist/cjs/src/compat/ECIES.js.map +1 -1
  29. package/dist/cjs/src/compat/HD.js +63 -73
  30. package/dist/cjs/src/compat/HD.js.map +1 -1
  31. package/dist/cjs/src/compat/Mnemonic.js +102 -106
  32. package/dist/cjs/src/compat/Mnemonic.js.map +1 -1
  33. package/dist/cjs/src/compat/Utxo.js +2 -2
  34. package/dist/cjs/src/compat/Utxo.js.map +1 -1
  35. package/dist/cjs/src/compat/index.js +7 -17
  36. package/dist/cjs/src/compat/index.js.map +1 -1
  37. package/dist/cjs/src/messages/EncryptedMessage.js +3 -1
  38. package/dist/cjs/src/messages/EncryptedMessage.js.map +1 -1
  39. package/dist/cjs/src/messages/SignedMessage.js +1 -0
  40. package/dist/cjs/src/messages/SignedMessage.js.map +1 -1
  41. package/dist/cjs/src/messages/index.js +7 -17
  42. package/dist/cjs/src/messages/index.js.map +1 -1
  43. package/dist/cjs/src/overlay-tools/LookupResolver.js +54 -35
  44. package/dist/cjs/src/overlay-tools/LookupResolver.js.map +1 -1
  45. package/dist/cjs/src/overlay-tools/OverlayAdminTokenTemplate.js +32 -20
  46. package/dist/cjs/src/overlay-tools/OverlayAdminTokenTemplate.js.map +1 -1
  47. package/dist/cjs/src/overlay-tools/SHIPBroadcaster.js +40 -28
  48. package/dist/cjs/src/overlay-tools/SHIPBroadcaster.js.map +1 -1
  49. package/dist/cjs/src/primitives/AESGCM.js +6 -5
  50. package/dist/cjs/src/primitives/AESGCM.js.map +1 -1
  51. package/dist/cjs/src/primitives/BasePoint.js +1 -1
  52. package/dist/cjs/src/primitives/BasePoint.js.map +1 -1
  53. package/dist/cjs/src/primitives/BigNumber.js +50 -62
  54. package/dist/cjs/src/primitives/BigNumber.js.map +1 -1
  55. package/dist/cjs/src/primitives/Curve.js +46 -22
  56. package/dist/cjs/src/primitives/Curve.js.map +1 -1
  57. package/dist/cjs/src/primitives/DRBG.js +2 -8
  58. package/dist/cjs/src/primitives/DRBG.js.map +1 -1
  59. package/dist/cjs/src/primitives/ECDSA.js +51 -35
  60. package/dist/cjs/src/primitives/ECDSA.js.map +1 -1
  61. package/dist/cjs/src/primitives/Hash.js +191 -216
  62. package/dist/cjs/src/primitives/Hash.js.map +1 -1
  63. package/dist/cjs/src/primitives/JacobianPoint.js +19 -5
  64. package/dist/cjs/src/primitives/JacobianPoint.js.map +1 -1
  65. package/dist/cjs/src/primitives/K256.js.map +1 -1
  66. package/dist/cjs/src/primitives/Mersenne.js.map +1 -1
  67. package/dist/cjs/src/primitives/MontgomoryMethod.js.map +1 -1
  68. package/dist/cjs/src/primitives/Point.js +117 -88
  69. package/dist/cjs/src/primitives/Point.js.map +1 -1
  70. package/dist/cjs/src/primitives/Polynomial.js +4 -2
  71. package/dist/cjs/src/primitives/Polynomial.js.map +1 -1
  72. package/dist/cjs/src/primitives/PrivateKey.js +32 -33
  73. package/dist/cjs/src/primitives/PrivateKey.js.map +1 -1
  74. package/dist/cjs/src/primitives/PublicKey.js.map +1 -1
  75. package/dist/cjs/src/primitives/Random.js +6 -5
  76. package/dist/cjs/src/primitives/Random.js.map +1 -1
  77. package/dist/cjs/src/primitives/ReductionContext.js +1 -1
  78. package/dist/cjs/src/primitives/ReductionContext.js.map +1 -1
  79. package/dist/cjs/src/primitives/Schnorr.js +21 -15
  80. package/dist/cjs/src/primitives/Schnorr.js.map +1 -1
  81. package/dist/cjs/src/primitives/Signature.js +8 -7
  82. package/dist/cjs/src/primitives/Signature.js.map +1 -1
  83. package/dist/cjs/src/primitives/SymmetricKey.js +13 -13
  84. package/dist/cjs/src/primitives/SymmetricKey.js.map +1 -1
  85. package/dist/cjs/src/primitives/TransactionSignature.js +31 -29
  86. package/dist/cjs/src/primitives/TransactionSignature.js.map +1 -1
  87. package/dist/cjs/src/primitives/index.js +7 -17
  88. package/dist/cjs/src/primitives/index.js.map +1 -1
  89. package/dist/cjs/src/primitives/utils.js +79 -68
  90. package/dist/cjs/src/primitives/utils.js.map +1 -1
  91. package/dist/cjs/src/script/OP.js +3 -3
  92. package/dist/cjs/src/script/OP.js.map +1 -1
  93. package/dist/cjs/src/script/Script.js +12 -10
  94. package/dist/cjs/src/script/Script.js.map +1 -1
  95. package/dist/cjs/src/script/Spend.js +47 -49
  96. package/dist/cjs/src/script/Spend.js.map +1 -1
  97. package/dist/cjs/src/script/templates/P2PKH.js +24 -12
  98. package/dist/cjs/src/script/templates/P2PKH.js.map +1 -1
  99. package/dist/cjs/src/script/templates/PushDrop.js +28 -23
  100. package/dist/cjs/src/script/templates/PushDrop.js.map +1 -1
  101. package/dist/cjs/src/script/templates/RPuzzle.js +10 -6
  102. package/dist/cjs/src/script/templates/RPuzzle.js.map +1 -1
  103. package/dist/cjs/src/totp/totp.js +2 -1
  104. package/dist/cjs/src/totp/totp.js.map +1 -1
  105. package/dist/cjs/src/transaction/Beef.js +177 -154
  106. package/dist/cjs/src/transaction/Beef.js.map +1 -1
  107. package/dist/cjs/src/transaction/BeefParty.js +24 -24
  108. package/dist/cjs/src/transaction/BeefParty.js.map +1 -1
  109. package/dist/cjs/src/transaction/BeefTx.js +26 -18
  110. package/dist/cjs/src/transaction/BeefTx.js.map +1 -1
  111. package/dist/cjs/src/transaction/Broadcaster.js +3 -2
  112. package/dist/cjs/src/transaction/Broadcaster.js.map +1 -1
  113. package/dist/cjs/src/transaction/MerklePath.js +64 -37
  114. package/dist/cjs/src/transaction/MerklePath.js.map +1 -1
  115. package/dist/cjs/src/transaction/Transaction.js +111 -137
  116. package/dist/cjs/src/transaction/Transaction.js.map +1 -1
  117. package/dist/cjs/src/transaction/broadcasters/ARC.js +25 -16
  118. package/dist/cjs/src/transaction/broadcasters/ARC.js.map +1 -1
  119. package/dist/cjs/src/transaction/broadcasters/DefaultBroadcaster.js +2 -1
  120. package/dist/cjs/src/transaction/broadcasters/DefaultBroadcaster.js.map +1 -1
  121. package/dist/cjs/src/transaction/broadcasters/WhatsOnChainBroadcaster.js.map +1 -1
  122. package/dist/cjs/src/transaction/chaintrackers/DefaultChainTracker.js +2 -1
  123. package/dist/cjs/src/transaction/chaintrackers/DefaultChainTracker.js.map +1 -1
  124. package/dist/cjs/src/transaction/chaintrackers/WhatsOnChain.js +3 -3
  125. package/dist/cjs/src/transaction/chaintrackers/WhatsOnChain.js.map +1 -1
  126. package/dist/cjs/src/transaction/fee-models/SatoshisPerKilobyte.js.map +1 -1
  127. package/dist/cjs/src/transaction/http/DefaultHttpClient.js +5 -3
  128. package/dist/cjs/src/transaction/http/DefaultHttpClient.js.map +1 -1
  129. package/dist/cjs/src/transaction/http/FetchHttpClient.js +5 -2
  130. package/dist/cjs/src/transaction/http/FetchHttpClient.js.map +1 -1
  131. package/dist/cjs/src/transaction/http/NodejsHttpClient.js +5 -3
  132. package/dist/cjs/src/transaction/http/NodejsHttpClient.js.map +1 -1
  133. package/dist/cjs/src/transaction/http/index.js.map +1 -1
  134. package/dist/cjs/src/transaction/index.js.map +1 -1
  135. package/dist/cjs/src/wallet/CachedKeyDeriver.js +91 -66
  136. package/dist/cjs/src/wallet/CachedKeyDeriver.js.map +1 -1
  137. package/dist/cjs/src/wallet/KeyDeriver.js +61 -52
  138. package/dist/cjs/src/wallet/KeyDeriver.js.map +1 -1
  139. package/dist/cjs/src/wallet/ProtoWallet.js +79 -29
  140. package/dist/cjs/src/wallet/ProtoWallet.js.map +1 -1
  141. package/dist/cjs/src/wallet/WalletClient.js +7 -2
  142. package/dist/cjs/src/wallet/WalletClient.js.map +1 -1
  143. package/dist/cjs/src/wallet/WalletError.js +2 -2
  144. package/dist/cjs/src/wallet/WalletError.js.map +1 -1
  145. package/dist/cjs/src/wallet/substrates/HTTPWalletJSON.js +4 -3
  146. package/dist/cjs/src/wallet/substrates/HTTPWalletJSON.js.map +1 -1
  147. package/dist/cjs/src/wallet/substrates/HTTPWalletWire.js +2 -2
  148. package/dist/cjs/src/wallet/substrates/HTTPWalletWire.js.map +1 -1
  149. package/dist/cjs/src/wallet/substrates/WalletWireProcessor.js +1239 -1261
  150. package/dist/cjs/src/wallet/substrates/WalletWireProcessor.js.map +1 -1
  151. package/dist/cjs/src/wallet/substrates/WalletWireTransceiver.js +102 -43
  152. package/dist/cjs/src/wallet/substrates/WalletWireTransceiver.js.map +1 -1
  153. package/dist/cjs/src/wallet/substrates/XDM.js +8 -3
  154. package/dist/cjs/src/wallet/substrates/XDM.js.map +1 -1
  155. package/dist/cjs/src/wallet/substrates/window.CWI.js +28 -28
  156. package/dist/cjs/src/wallet/substrates/window.CWI.js.map +1 -1
  157. package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
  158. package/dist/esm/mod.js +15 -15
  159. package/dist/esm/src/auth/Peer.js +75 -54
  160. package/dist/esm/src/auth/Peer.js.map +1 -1
  161. package/dist/esm/src/auth/SessionManager.js +14 -9
  162. package/dist/esm/src/auth/SessionManager.js.map +1 -1
  163. package/dist/esm/src/auth/certificates/Certificate.js +15 -11
  164. package/dist/esm/src/auth/certificates/Certificate.js.map +1 -1
  165. package/dist/esm/src/auth/certificates/MasterCertificate.js +25 -23
  166. package/dist/esm/src/auth/certificates/MasterCertificate.js.map +1 -1
  167. package/dist/esm/src/auth/certificates/VerifiableCertificate.js +2 -2
  168. package/dist/esm/src/auth/certificates/VerifiableCertificate.js.map +1 -1
  169. package/dist/esm/src/auth/certificates/__tests/CompletedProtoWallet.js +64 -47
  170. package/dist/esm/src/auth/certificates/__tests/CompletedProtoWallet.js.map +1 -1
  171. package/dist/esm/src/auth/clients/AuthFetch.js +1 -0
  172. package/dist/esm/src/auth/clients/AuthFetch.js.map +1 -1
  173. package/dist/esm/src/auth/transports/SimplifiedFetchTransport.js +69 -43
  174. package/dist/esm/src/auth/transports/SimplifiedFetchTransport.js.map +1 -1
  175. package/dist/esm/src/auth/utils/createNonce.js.map +1 -1
  176. package/dist/esm/src/auth/utils/getVerifiableCertificates.js +1 -1
  177. package/dist/esm/src/auth/utils/getVerifiableCertificates.js.map +1 -1
  178. package/dist/esm/src/auth/utils/validateCertificates.js +6 -3
  179. package/dist/esm/src/auth/utils/validateCertificates.js.map +1 -1
  180. package/dist/esm/src/auth/utils/verifyNonce.js.map +1 -1
  181. package/dist/esm/src/compat/BSM.js.map +1 -1
  182. package/dist/esm/src/compat/ECIES.js +165 -116
  183. package/dist/esm/src/compat/ECIES.js.map +1 -1
  184. package/dist/esm/src/compat/HD.js +56 -56
  185. package/dist/esm/src/compat/HD.js.map +1 -1
  186. package/dist/esm/src/compat/Mnemonic.js +95 -89
  187. package/dist/esm/src/compat/Mnemonic.js.map +1 -1
  188. package/dist/esm/src/compat/Utxo.js +1 -1
  189. package/dist/esm/src/compat/Utxo.js.map +1 -1
  190. package/dist/esm/src/messages/EncryptedMessage.js +3 -1
  191. package/dist/esm/src/messages/EncryptedMessage.js.map +1 -1
  192. package/dist/esm/src/messages/SignedMessage.js +1 -0
  193. package/dist/esm/src/messages/SignedMessage.js.map +1 -1
  194. package/dist/esm/src/overlay-tools/LookupResolver.js +53 -35
  195. package/dist/esm/src/overlay-tools/LookupResolver.js.map +1 -1
  196. package/dist/esm/src/overlay-tools/OverlayAdminTokenTemplate.js +32 -20
  197. package/dist/esm/src/overlay-tools/OverlayAdminTokenTemplate.js.map +1 -1
  198. package/dist/esm/src/overlay-tools/SHIPBroadcaster.js +40 -28
  199. package/dist/esm/src/overlay-tools/SHIPBroadcaster.js.map +1 -1
  200. package/dist/esm/src/primitives/AESGCM.js +1 -0
  201. package/dist/esm/src/primitives/AESGCM.js.map +1 -1
  202. package/dist/esm/src/primitives/BasePoint.js +1 -1
  203. package/dist/esm/src/primitives/BasePoint.js.map +1 -1
  204. package/dist/esm/src/primitives/BigNumber.js +50 -62
  205. package/dist/esm/src/primitives/BigNumber.js.map +1 -1
  206. package/dist/esm/src/primitives/Curve.js +45 -22
  207. package/dist/esm/src/primitives/Curve.js.map +1 -1
  208. package/dist/esm/src/primitives/DRBG.js +2 -8
  209. package/dist/esm/src/primitives/DRBG.js.map +1 -1
  210. package/dist/esm/src/primitives/ECDSA.js +50 -35
  211. package/dist/esm/src/primitives/ECDSA.js.map +1 -1
  212. package/dist/esm/src/primitives/Hash.js +188 -213
  213. package/dist/esm/src/primitives/Hash.js.map +1 -1
  214. package/dist/esm/src/primitives/JacobianPoint.js +18 -5
  215. package/dist/esm/src/primitives/JacobianPoint.js.map +1 -1
  216. package/dist/esm/src/primitives/K256.js.map +1 -1
  217. package/dist/esm/src/primitives/Mersenne.js.map +1 -1
  218. package/dist/esm/src/primitives/MontgomoryMethod.js.map +1 -1
  219. package/dist/esm/src/primitives/Point.js +107 -88
  220. package/dist/esm/src/primitives/Point.js.map +1 -1
  221. package/dist/esm/src/primitives/Polynomial.js +4 -2
  222. package/dist/esm/src/primitives/Polynomial.js.map +1 -1
  223. package/dist/esm/src/primitives/PrivateKey.js +25 -16
  224. package/dist/esm/src/primitives/PrivateKey.js.map +1 -1
  225. package/dist/esm/src/primitives/PublicKey.js.map +1 -1
  226. package/dist/esm/src/primitives/Random.js +7 -6
  227. package/dist/esm/src/primitives/Random.js.map +1 -1
  228. package/dist/esm/src/primitives/ReductionContext.js +1 -1
  229. package/dist/esm/src/primitives/ReductionContext.js.map +1 -1
  230. package/dist/esm/src/primitives/Schnorr.js +21 -15
  231. package/dist/esm/src/primitives/Schnorr.js.map +1 -1
  232. package/dist/esm/src/primitives/Signature.js +8 -7
  233. package/dist/esm/src/primitives/Signature.js.map +1 -1
  234. package/dist/esm/src/primitives/SymmetricKey.js +13 -13
  235. package/dist/esm/src/primitives/SymmetricKey.js.map +1 -1
  236. package/dist/esm/src/primitives/TransactionSignature.js +22 -12
  237. package/dist/esm/src/primitives/TransactionSignature.js.map +1 -1
  238. package/dist/esm/src/primitives/utils.js +76 -66
  239. package/dist/esm/src/primitives/utils.js.map +1 -1
  240. package/dist/esm/src/script/OP.js +3 -3
  241. package/dist/esm/src/script/OP.js.map +1 -1
  242. package/dist/esm/src/script/Script.js +12 -10
  243. package/dist/esm/src/script/Script.js.map +1 -1
  244. package/dist/esm/src/script/Spend.js +39 -32
  245. package/dist/esm/src/script/Spend.js.map +1 -1
  246. package/dist/esm/src/script/templates/P2PKH.js +26 -11
  247. package/dist/esm/src/script/templates/P2PKH.js.map +1 -1
  248. package/dist/esm/src/script/templates/PushDrop.js +29 -22
  249. package/dist/esm/src/script/templates/PushDrop.js.map +1 -1
  250. package/dist/esm/src/script/templates/RPuzzle.js +11 -6
  251. package/dist/esm/src/script/templates/RPuzzle.js.map +1 -1
  252. package/dist/esm/src/totp/totp.js +2 -1
  253. package/dist/esm/src/totp/totp.js.map +1 -1
  254. package/dist/esm/src/transaction/Beef.js +176 -154
  255. package/dist/esm/src/transaction/Beef.js.map +1 -1
  256. package/dist/esm/src/transaction/BeefParty.js +24 -24
  257. package/dist/esm/src/transaction/BeefParty.js.map +1 -1
  258. package/dist/esm/src/transaction/BeefTx.js +26 -18
  259. package/dist/esm/src/transaction/BeefTx.js.map +1 -1
  260. package/dist/esm/src/transaction/Broadcaster.js.map +1 -1
  261. package/dist/esm/src/transaction/MerklePath.js +61 -36
  262. package/dist/esm/src/transaction/MerklePath.js.map +1 -1
  263. package/dist/esm/src/transaction/Transaction.js +105 -138
  264. package/dist/esm/src/transaction/Transaction.js.map +1 -1
  265. package/dist/esm/src/transaction/broadcasters/ARC.js +25 -16
  266. package/dist/esm/src/transaction/broadcasters/ARC.js.map +1 -1
  267. package/dist/esm/src/transaction/broadcasters/DefaultBroadcaster.js.map +1 -1
  268. package/dist/esm/src/transaction/broadcasters/WhatsOnChainBroadcaster.js.map +1 -1
  269. package/dist/esm/src/transaction/chaintrackers/WhatsOnChain.js +3 -3
  270. package/dist/esm/src/transaction/chaintrackers/WhatsOnChain.js.map +1 -1
  271. package/dist/esm/src/transaction/fee-models/SatoshisPerKilobyte.js.map +1 -1
  272. package/dist/esm/src/transaction/http/DefaultHttpClient.js +3 -2
  273. package/dist/esm/src/transaction/http/DefaultHttpClient.js.map +1 -1
  274. package/dist/esm/src/transaction/http/FetchHttpClient.js +4 -2
  275. package/dist/esm/src/transaction/http/FetchHttpClient.js.map +1 -1
  276. package/dist/esm/src/transaction/http/NodejsHttpClient.js +5 -3
  277. package/dist/esm/src/transaction/http/NodejsHttpClient.js.map +1 -1
  278. package/dist/esm/src/transaction/http/index.js.map +1 -1
  279. package/dist/esm/src/transaction/index.js.map +1 -1
  280. package/dist/esm/src/wallet/CachedKeyDeriver.js +91 -66
  281. package/dist/esm/src/wallet/CachedKeyDeriver.js.map +1 -1
  282. package/dist/esm/src/wallet/KeyDeriver.js +60 -52
  283. package/dist/esm/src/wallet/KeyDeriver.js.map +1 -1
  284. package/dist/esm/src/wallet/ProtoWallet.js +75 -29
  285. package/dist/esm/src/wallet/ProtoWallet.js.map +1 -1
  286. package/dist/esm/src/wallet/WalletClient.js +7 -2
  287. package/dist/esm/src/wallet/WalletClient.js.map +1 -1
  288. package/dist/esm/src/wallet/WalletError.js +2 -2
  289. package/dist/esm/src/wallet/WalletError.js.map +1 -1
  290. package/dist/esm/src/wallet/substrates/HTTPWalletJSON.js +4 -4
  291. package/dist/esm/src/wallet/substrates/HTTPWalletJSON.js.map +1 -1
  292. package/dist/esm/src/wallet/substrates/HTTPWalletWire.js +2 -2
  293. package/dist/esm/src/wallet/substrates/HTTPWalletWire.js.map +1 -1
  294. package/dist/esm/src/wallet/substrates/WalletWireProcessor.js +1239 -1261
  295. package/dist/esm/src/wallet/substrates/WalletWireProcessor.js.map +1 -1
  296. package/dist/esm/src/wallet/substrates/WalletWireTransceiver.js +95 -43
  297. package/dist/esm/src/wallet/substrates/WalletWireTransceiver.js.map +1 -1
  298. package/dist/esm/src/wallet/substrates/XDM.js +8 -3
  299. package/dist/esm/src/wallet/substrates/XDM.js.map +1 -1
  300. package/dist/esm/src/wallet/substrates/window.CWI.js +28 -28
  301. package/dist/esm/src/wallet/substrates/window.CWI.js.map +1 -1
  302. package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
  303. package/dist/types/mod.d.ts +15 -15
  304. package/dist/types/src/auth/Peer.d.ts +10 -10
  305. package/dist/types/src/auth/Peer.d.ts.map +1 -1
  306. package/dist/types/src/auth/SessionManager.d.ts +4 -4
  307. package/dist/types/src/auth/SessionManager.d.ts.map +1 -1
  308. package/dist/types/src/auth/certificates/Certificate.d.ts +6 -6
  309. package/dist/types/src/auth/certificates/Certificate.d.ts.map +1 -1
  310. package/dist/types/src/auth/certificates/MasterCertificate.d.ts +5 -5
  311. package/dist/types/src/auth/certificates/MasterCertificate.d.ts.map +1 -1
  312. package/dist/types/src/auth/certificates/VerifiableCertificate.d.ts.map +1 -1
  313. package/dist/types/src/auth/certificates/__tests/CompletedProtoWallet.d.ts +23 -22
  314. package/dist/types/src/auth/certificates/__tests/CompletedProtoWallet.d.ts.map +1 -1
  315. package/dist/types/src/auth/clients/AuthFetch.d.ts.map +1 -1
  316. package/dist/types/src/auth/transports/SimplifiedFetchTransport.d.ts +1 -1
  317. package/dist/types/src/auth/transports/SimplifiedFetchTransport.d.ts.map +1 -1
  318. package/dist/types/src/auth/utils/createNonce.d.ts.map +1 -1
  319. package/dist/types/src/auth/utils/getVerifiableCertificates.d.ts +3 -3
  320. package/dist/types/src/auth/utils/getVerifiableCertificates.d.ts.map +1 -1
  321. package/dist/types/src/auth/utils/validateCertificates.d.ts +2 -2
  322. package/dist/types/src/auth/utils/validateCertificates.d.ts.map +1 -1
  323. package/dist/types/src/auth/utils/verifyNonce.d.ts +1 -1
  324. package/dist/types/src/auth/utils/verifyNonce.d.ts.map +1 -1
  325. package/dist/types/src/compat/BSM.d.ts +1 -1
  326. package/dist/types/src/compat/BSM.d.ts.map +1 -1
  327. package/dist/types/src/compat/ECIES.d.ts +36 -36
  328. package/dist/types/src/compat/ECIES.d.ts.map +1 -1
  329. package/dist/types/src/compat/HD.d.ts +51 -51
  330. package/dist/types/src/compat/HD.d.ts.map +1 -1
  331. package/dist/types/src/compat/Mnemonic.d.ts +79 -79
  332. package/dist/types/src/compat/Mnemonic.d.ts.map +1 -1
  333. package/dist/types/src/compat/Utxo.d.ts.map +1 -1
  334. package/dist/types/src/messages/EncryptedMessage.d.ts.map +1 -1
  335. package/dist/types/src/messages/SignedMessage.d.ts.map +1 -1
  336. package/dist/types/src/overlay-tools/LookupResolver.d.ts +9 -9
  337. package/dist/types/src/overlay-tools/LookupResolver.d.ts.map +1 -1
  338. package/dist/types/src/overlay-tools/OverlayAdminTokenTemplate.d.ts +17 -17
  339. package/dist/types/src/overlay-tools/OverlayAdminTokenTemplate.d.ts.map +1 -1
  340. package/dist/types/src/overlay-tools/SHIPBroadcaster.d.ts +14 -14
  341. package/dist/types/src/overlay-tools/SHIPBroadcaster.d.ts.map +1 -1
  342. package/dist/types/src/primitives/AESGCM.d.ts.map +1 -1
  343. package/dist/types/src/primitives/BasePoint.d.ts +8 -8
  344. package/dist/types/src/primitives/BasePoint.d.ts.map +1 -1
  345. package/dist/types/src/primitives/BigNumber.d.ts.map +1 -1
  346. package/dist/types/src/primitives/Curve.d.ts +14 -7
  347. package/dist/types/src/primitives/Curve.d.ts.map +1 -1
  348. package/dist/types/src/primitives/DRBG.d.ts.map +1 -1
  349. package/dist/types/src/primitives/ECDSA.d.ts +1 -1
  350. package/dist/types/src/primitives/ECDSA.d.ts.map +1 -1
  351. package/dist/types/src/primitives/Hash.d.ts +11 -11
  352. package/dist/types/src/primitives/Hash.d.ts.map +1 -1
  353. package/dist/types/src/primitives/JacobianPoint.d.ts.map +1 -1
  354. package/dist/types/src/primitives/Point.d.ts +14 -10
  355. package/dist/types/src/primitives/Point.d.ts.map +1 -1
  356. package/dist/types/src/primitives/Polynomial.d.ts.map +1 -1
  357. package/dist/types/src/primitives/PrivateKey.d.ts +2 -2
  358. package/dist/types/src/primitives/PrivateKey.d.ts.map +1 -1
  359. package/dist/types/src/primitives/PublicKey.d.ts.map +1 -1
  360. package/dist/types/src/primitives/Random.d.ts.map +1 -1
  361. package/dist/types/src/primitives/Schnorr.d.ts +14 -14
  362. package/dist/types/src/primitives/Schnorr.d.ts.map +1 -1
  363. package/dist/types/src/primitives/Signature.d.ts +1 -1
  364. package/dist/types/src/primitives/Signature.d.ts.map +1 -1
  365. package/dist/types/src/primitives/SymmetricKey.d.ts +13 -13
  366. package/dist/types/src/primitives/SymmetricKey.d.ts.map +1 -1
  367. package/dist/types/src/primitives/TransactionSignature.d.ts +4 -4
  368. package/dist/types/src/primitives/TransactionSignature.d.ts.map +1 -1
  369. package/dist/types/src/primitives/utils.d.ts +3 -6
  370. package/dist/types/src/primitives/utils.d.ts.map +1 -1
  371. package/dist/types/src/script/Script.d.ts +3 -3
  372. package/dist/types/src/script/Script.d.ts.map +1 -1
  373. package/dist/types/src/script/ScriptTemplate.d.ts +2 -2
  374. package/dist/types/src/script/ScriptTemplate.d.ts.map +1 -1
  375. package/dist/types/src/script/Spend.d.ts.map +1 -1
  376. package/dist/types/src/script/templates/P2PKH.d.ts.map +1 -1
  377. package/dist/types/src/script/templates/PushDrop.d.ts +1 -2
  378. package/dist/types/src/script/templates/PushDrop.d.ts.map +1 -1
  379. package/dist/types/src/script/templates/RPuzzle.d.ts.map +1 -1
  380. package/dist/types/src/totp/totp.d.ts.map +1 -1
  381. package/dist/types/src/transaction/Beef.d.ts +96 -96
  382. package/dist/types/src/transaction/Beef.d.ts.map +1 -1
  383. package/dist/types/src/transaction/BeefParty.d.ts +22 -22
  384. package/dist/types/src/transaction/BeefParty.d.ts.map +1 -1
  385. package/dist/types/src/transaction/BeefTx.d.ts +5 -5
  386. package/dist/types/src/transaction/BeefTx.d.ts.map +1 -1
  387. package/dist/types/src/transaction/Broadcaster.d.ts.map +1 -1
  388. package/dist/types/src/transaction/ChainTracker.d.ts +2 -2
  389. package/dist/types/src/transaction/FeeModel.d.ts.map +1 -1
  390. package/dist/types/src/transaction/MerklePath.d.ts.map +1 -1
  391. package/dist/types/src/transaction/Transaction.d.ts +4 -12
  392. package/dist/types/src/transaction/Transaction.d.ts.map +1 -1
  393. package/dist/types/src/transaction/TransactionOutput.d.ts.map +1 -1
  394. package/dist/types/src/transaction/broadcasters/ARC.d.ts +1 -1
  395. package/dist/types/src/transaction/broadcasters/ARC.d.ts.map +1 -1
  396. package/dist/types/src/transaction/broadcasters/DefaultBroadcaster.d.ts.map +1 -1
  397. package/dist/types/src/transaction/broadcasters/WhatsOnChainBroadcaster.d.ts.map +1 -1
  398. package/dist/types/src/transaction/chaintrackers/DefaultChainTracker.d.ts.map +1 -1
  399. package/dist/types/src/transaction/chaintrackers/WhatsOnChain.d.ts.map +1 -1
  400. package/dist/types/src/transaction/fee-models/SatoshisPerKilobyte.d.ts.map +1 -1
  401. package/dist/types/src/transaction/http/DefaultHttpClient.d.ts +1 -1
  402. package/dist/types/src/transaction/http/DefaultHttpClient.d.ts.map +1 -1
  403. package/dist/types/src/transaction/http/FetchHttpClient.d.ts +5 -5
  404. package/dist/types/src/transaction/http/FetchHttpClient.d.ts.map +1 -1
  405. package/dist/types/src/transaction/http/HttpClient.d.ts +4 -4
  406. package/dist/types/src/transaction/http/HttpClient.d.ts.map +1 -1
  407. package/dist/types/src/transaction/http/NodejsHttpClient.d.ts +3 -3
  408. package/dist/types/src/transaction/http/NodejsHttpClient.d.ts.map +1 -1
  409. package/dist/types/src/transaction/http/index.d.ts.map +1 -1
  410. package/dist/types/src/transaction/index.d.ts.map +1 -1
  411. package/dist/types/src/wallet/CachedKeyDeriver.d.ts +58 -58
  412. package/dist/types/src/wallet/CachedKeyDeriver.d.ts.map +1 -1
  413. package/dist/types/src/wallet/KeyDeriver.d.ts +78 -78
  414. package/dist/types/src/wallet/KeyDeriver.d.ts.map +1 -1
  415. package/dist/types/src/wallet/ProtoWallet.d.ts +10 -10
  416. package/dist/types/src/wallet/ProtoWallet.d.ts.map +1 -1
  417. package/dist/types/src/wallet/Wallet.interfaces.d.ts +151 -152
  418. package/dist/types/src/wallet/Wallet.interfaces.d.ts.map +1 -1
  419. package/dist/types/src/wallet/WalletClient.d.ts +5 -5
  420. package/dist/types/src/wallet/WalletClient.d.ts.map +1 -1
  421. package/dist/types/src/wallet/substrates/HTTPWalletJSON.d.ts +6 -6
  422. package/dist/types/src/wallet/substrates/HTTPWalletJSON.d.ts.map +1 -1
  423. package/dist/types/src/wallet/substrates/HTTPWalletWire.d.ts.map +1 -1
  424. package/dist/types/src/wallet/substrates/WalletWireProcessor.d.ts.map +1 -1
  425. package/dist/types/src/wallet/substrates/WalletWireTransceiver.d.ts.map +1 -1
  426. package/dist/types/src/wallet/substrates/XDM.d.ts +1 -1
  427. package/dist/types/src/wallet/substrates/XDM.d.ts.map +1 -1
  428. package/dist/types/src/wallet/substrates/window.CWI.d.ts +6 -6
  429. package/dist/types/src/wallet/substrates/window.CWI.d.ts.map +1 -1
  430. package/dist/types/tsconfig.types.tsbuildinfo +1 -1
  431. package/dist/umd/bundle.js +1 -1
  432. package/docs/auth.md +92 -82
  433. package/docs/compat.md +24 -24
  434. package/docs/messages.md +7 -5
  435. package/docs/overlay-tools.md +21 -21
  436. package/docs/primitives.md +336 -315
  437. package/docs/script.md +35 -35
  438. package/docs/swagger/dist/swagger-initializer.js +7 -7
  439. package/docs/swagger/dist/swagger-ui-bundle.js +1 -1
  440. package/docs/swagger/dist/swagger-ui-es-bundle-core.js +2 -2
  441. package/docs/swagger/dist/swagger-ui-es-bundle.js +1 -1
  442. package/docs/swagger/dist/swagger-ui-standalone-preset.js +1 -1
  443. package/docs/swagger/dist/swagger-ui.js +2 -2
  444. package/docs/totp.md +5 -5
  445. package/docs/transaction.md +103 -105
  446. package/docs/wallet-substrates.md +17 -17
  447. package/docs/wallet.md +202 -204
  448. package/mod.ts +15 -15
  449. package/package.json +15 -3
  450. package/src/auth/Peer.ts +271 -121
  451. package/src/auth/SessionManager.ts +17 -10
  452. package/src/auth/__tests/Peer.test.ts +361 -179
  453. package/src/auth/__tests/SessionManager.test.ts +67 -19
  454. package/src/auth/__tests/build.test.ts +11 -0
  455. package/src/auth/certificates/Certificate.ts +27 -14
  456. package/src/auth/certificates/MasterCertificate.ts +106 -62
  457. package/src/auth/certificates/VerifiableCertificate.ts +30 -8
  458. package/src/auth/certificates/__tests/Certificate.test.ts +32 -17
  459. package/src/auth/certificates/__tests/CompletedProtoWallet.ts +171 -68
  460. package/src/auth/certificates/__tests/MasterCertificate.test.ts +63 -47
  461. package/src/auth/certificates/__tests/VerifiableCertificate.test.ts +42 -31
  462. package/src/auth/certificates/index.ts +1 -1
  463. package/src/auth/clients/AuthFetch.ts +1 -0
  464. package/src/auth/clients/index.ts +1 -1
  465. package/src/auth/transports/SimplifiedFetchTransport.ts +145 -72
  466. package/src/auth/transports/index.ts +1 -1
  467. package/src/auth/utils/__tests/cryptononce.test.ts +52 -23
  468. package/src/auth/utils/__tests/getVerifiableCertificates.test.ts +56 -30
  469. package/src/auth/utils/__tests/validateCertificates.test.ts +53 -31
  470. package/src/auth/utils/createNonce.ts +11 -3
  471. package/src/auth/utils/getVerifiableCertificates.ts +12 -7
  472. package/src/auth/utils/validateCertificates.ts +57 -39
  473. package/src/auth/utils/verifyNonce.ts +6 -2
  474. package/src/compat/BSM.ts +10 -2
  475. package/src/compat/ECIES.ts +265 -141
  476. package/src/compat/HD.ts +81 -63
  477. package/src/compat/Mnemonic.ts +104 -91
  478. package/src/compat/Utxo.ts +8 -5
  479. package/src/compat/__tests/BSM.test.ts +42 -16
  480. package/src/compat/__tests/ECIES.test.ts +117 -52
  481. package/src/compat/__tests/HD.test.ts +55 -42
  482. package/src/compat/__tests/Mnemonic.test.ts +11 -12
  483. package/src/compat/__tests/Mnemonic.vectors.ts +110 -55
  484. package/src/messages/EncryptedMessage.ts +6 -2
  485. package/src/messages/SignedMessage.ts +14 -8
  486. package/src/messages/__tests/EncryptedMessage.test.ts +23 -24
  487. package/src/messages/__tests/SignedMessage.test.ts +17 -11
  488. package/src/overlay-tools/LookupResolver.ts +108 -56
  489. package/src/overlay-tools/OverlayAdminTokenTemplate.ts +52 -23
  490. package/src/overlay-tools/SHIPBroadcaster.ts +135 -59
  491. package/src/overlay-tools/__tests/LookupResolver.test.ts +723 -323
  492. package/src/overlay-tools/__tests/OverlayAdminTokenTemplate.test.ts +50 -22
  493. package/src/overlay-tools/__tests/SHIPBroadcaster.test.ts +607 -290
  494. package/src/primitives/AESGCM.ts +2 -0
  495. package/src/primitives/BasePoint.ts +4 -4
  496. package/src/primitives/BigNumber.ts +99 -90
  497. package/src/primitives/Curve.ts +117 -46
  498. package/src/primitives/DRBG.ts +9 -11
  499. package/src/primitives/ECDSA.ts +109 -63
  500. package/src/primitives/Hash.ts +492 -321
  501. package/src/primitives/JacobianPoint.ts +67 -19
  502. package/src/primitives/Point.ts +254 -152
  503. package/src/primitives/Polynomial.ts +8 -3
  504. package/src/primitives/PrivateKey.ts +41 -17
  505. package/src/primitives/PublicKey.ts +13 -3
  506. package/src/primitives/Random.ts +14 -8
  507. package/src/primitives/ReductionContext.ts +1 -1
  508. package/src/primitives/Schnorr.ts +40 -18
  509. package/src/primitives/Signature.ts +26 -16
  510. package/src/primitives/SymmetricKey.ts +14 -14
  511. package/src/primitives/TransactionSignature.ts +41 -17
  512. package/src/primitives/__tests/AESGCM.test.ts +457 -151
  513. package/src/primitives/__tests/BRC42.private.vectors.ts +30 -15
  514. package/src/primitives/__tests/BRC42.public.vectors.ts +30 -15
  515. package/src/primitives/__tests/BigNumber.arithmatic.test.ts +344 -125
  516. package/src/primitives/__tests/BigNumber.binary.test.ts +148 -67
  517. package/src/primitives/__tests/BigNumber.constructor.test.ts +65 -25
  518. package/src/primitives/__tests/BigNumber.dhGroup.test.ts +15 -11
  519. package/src/primitives/__tests/BigNumber.fixtures.ts +16 -8
  520. package/src/primitives/__tests/BigNumber.serializers.test.ts +41 -15
  521. package/src/primitives/__tests/BigNumber.utils.test.ts +132 -42
  522. package/src/primitives/__tests/Curve.unit.test.ts +75 -53
  523. package/src/primitives/__tests/DRBG.test.ts +1 -1
  524. package/src/primitives/__tests/DRBG.vectors.ts +45 -75
  525. package/src/primitives/__tests/ECDH.test.ts +15 -8
  526. package/src/primitives/__tests/ECDSA.test.ts +12 -6
  527. package/src/primitives/__tests/HMAC.test.ts +24 -18
  528. package/src/primitives/__tests/Hash.test.ts +57 -46
  529. package/src/primitives/__tests/PBKDF2.vectors.ts +130 -117
  530. package/src/primitives/__tests/PrivateKey.split.test.ts +33 -11
  531. package/src/primitives/__tests/PrivateKey.test.ts +11 -10
  532. package/src/primitives/__tests/PublicKey.test.ts +64 -53
  533. package/src/primitives/__tests/Random.test.ts +1 -1
  534. package/src/primitives/__tests/Reader.test.ts +240 -219
  535. package/src/primitives/__tests/ReductionContext.test.ts +98 -61
  536. package/src/primitives/__tests/Schnorr.test.ts +249 -237
  537. package/src/primitives/__tests/SymmetricKey.test.ts +18 -15
  538. package/src/primitives/__tests/SymmetricKey.vectors.ts +16 -8
  539. package/src/primitives/__tests/Writer.test.ts +23 -13
  540. package/src/primitives/__tests/bug-31.test.ts +6 -10
  541. package/src/primitives/__tests/utils.test.ts +70 -19
  542. package/src/primitives/utils.ts +103 -79
  543. package/src/script/Script.ts +18 -12
  544. package/src/script/ScriptTemplate.ts +3 -5
  545. package/src/script/Spend.ts +306 -108
  546. package/src/script/__tests/Script.test.ts +73 -55
  547. package/src/script/__tests/Spend.test.ts +208 -83
  548. package/src/script/__tests/SpendComplex.test.ts +19 -13
  549. package/src/script/__tests/script.invalid.vectors.ts +428 -1796
  550. package/src/script/__tests/script.valid.vectors.ts +728 -2764
  551. package/src/script/templates/P2PKH.ts +34 -12
  552. package/src/script/templates/PushDrop.ts +65 -31
  553. package/src/script/templates/RPuzzle.ts +29 -8
  554. package/src/script/templates/__tests/PushDrop.test.ts +146 -41
  555. package/src/totp/__tests/totp.test.ts +45 -44
  556. package/src/totp/totp.ts +3 -2
  557. package/src/transaction/Beef.ts +269 -174
  558. package/src/transaction/BeefParty.ts +41 -31
  559. package/src/transaction/BeefTx.ts +36 -26
  560. package/src/transaction/Broadcaster.ts +10 -6
  561. package/src/transaction/ChainTracker.ts +2 -2
  562. package/src/transaction/FeeModel.ts +0 -1
  563. package/src/transaction/MerklePath.ts +124 -59
  564. package/src/transaction/Transaction.ts +188 -187
  565. package/src/transaction/TransactionOutput.ts +0 -1
  566. package/src/transaction/__tests/Beef.test.ts +390 -287
  567. package/src/transaction/__tests/MerklePath.test.ts +59 -26
  568. package/src/transaction/__tests/Transaction.benchmarks.test.ts +231 -201
  569. package/src/transaction/__tests/Transaction.test.ts +758 -482
  570. package/src/transaction/__tests/bigtx.vectors.ts +2 -1
  571. package/src/transaction/__tests/bump.invalid.vectors.ts +24 -6
  572. package/src/transaction/__tests/bump.valid.vectors.ts +6 -2
  573. package/src/transaction/__tests/tx.invalid.vectors.ts +881 -185
  574. package/src/transaction/__tests/tx.valid.vectors.ts +1210 -257
  575. package/src/transaction/broadcasters/ARC.ts +69 -38
  576. package/src/transaction/broadcasters/DefaultBroadcaster.ts +9 -3
  577. package/src/transaction/broadcasters/WhatsOnChainBroadcaster.ts +20 -7
  578. package/src/transaction/broadcasters/__tests/ARC.test.ts +127 -59
  579. package/src/transaction/broadcasters/__tests/WhatsOnChainBroadcaster.test.ts +27 -18
  580. package/src/transaction/chaintrackers/DefaultChainTracker.ts +1 -1
  581. package/src/transaction/chaintrackers/WhatsOnChain.ts +27 -11
  582. package/src/transaction/chaintrackers/__tests/WhatsOnChainChainTracker.test.ts +59 -23
  583. package/src/transaction/fee-models/SatoshisPerKilobyte.ts +9 -5
  584. package/src/transaction/http/DefaultHttpClient.ts +5 -4
  585. package/src/transaction/http/FetchHttpClient.ts +18 -9
  586. package/src/transaction/http/HttpClient.ts +27 -22
  587. package/src/transaction/http/NodejsHttpClient.ts +23 -9
  588. package/src/transaction/http/index.ts +5 -1
  589. package/src/transaction/index.ts +5 -1
  590. package/src/wallet/CachedKeyDeriver.ts +151 -82
  591. package/src/wallet/KeyDeriver.ts +186 -105
  592. package/src/wallet/ProtoWallet.ts +121 -52
  593. package/src/wallet/Wallet.interfaces.ts +167 -156
  594. package/src/wallet/WalletClient.ts +314 -59
  595. package/src/wallet/WalletError.ts +2 -2
  596. package/src/wallet/__tests/CachedKeyDeriver.test.ts +86 -27
  597. package/src/wallet/__tests/KeyDeriver.test.ts +136 -33
  598. package/src/wallet/__tests/ProtoWallet.test.ts +190 -102
  599. package/src/wallet/substrates/HTTPWalletJSON.ts +250 -67
  600. package/src/wallet/substrates/HTTPWalletWire.ts +7 -3
  601. package/src/wallet/substrates/WalletWireCalls.ts +2 -2
  602. package/src/wallet/substrates/WalletWireProcessor.ts +1412 -1277
  603. package/src/wallet/substrates/WalletWireTransceiver.ts +713 -138
  604. package/src/wallet/substrates/XDM.ts +425 -36
  605. package/src/wallet/substrates/__tests/WalletWire.integration.test.ts +488 -225
  606. package/src/wallet/substrates/__tests/XDM.test.ts +232 -234
  607. package/src/wallet/substrates/window.CWI.ts +520 -61
package/src/compat/HD.ts CHANGED
@@ -1,4 +1,12 @@
1
- import { fromBase58Check, toBase58Check, Writer, Reader, toArray, toHex } from '../primitives/utils.js'
1
+ // @ts-nocheck
2
+ import {
3
+ fromBase58Check,
4
+ toBase58Check,
5
+ Writer,
6
+ Reader,
7
+ toArray,
8
+ toHex
9
+ } from '../primitives/utils.js'
2
10
  import * as Hash from '../primitives/Hash.js'
3
11
  import Curve from '../primitives/Curve.js'
4
12
  import PrivateKey from '../primitives/PrivateKey.js'
@@ -30,16 +38,16 @@ export default class HD {
30
38
  }
31
39
 
32
40
  /**
33
- * Constructor for the BIP32 HD wallet.
34
- * Initializes an HD wallet with optional parameters for version bytes, depth, parent fingerprint, child index, chain code, private key, and public key.
35
- * @param versionBytesNum - Version bytes number for the wallet.
36
- * @param depth - Depth of the key in the hierarchy.
37
- * @param parentFingerPrint - Fingerprint of the parent key.
38
- * @param childIndex - Index of the child key.
39
- * @param chainCode - Chain code for key derivation.
40
- * @param privKey - Private key of the wallet.
41
- * @param pubKey - Public key of the wallet.
42
- */
41
+ * Constructor for the BIP32 HD wallet.
42
+ * Initializes an HD wallet with optional parameters for version bytes, depth, parent fingerprint, child index, chain code, private key, and public key.
43
+ * @param versionBytesNum - Version bytes number for the wallet.
44
+ * @param depth - Depth of the key in the hierarchy.
45
+ * @param parentFingerPrint - Fingerprint of the parent key.
46
+ * @param childIndex - Index of the child key.
47
+ * @param chainCode - Chain code for key derivation.
48
+ * @param privKey - Private key of the wallet.
49
+ * @param pubKey - Public key of the wallet.
50
+ */
43
51
  constructor (
44
52
  versionBytesNum?: number,
45
53
  depth?: number,
@@ -59,10 +67,10 @@ export default class HD {
59
67
  }
60
68
 
61
69
  /**
62
- * Generates a new HD wallet with random keys.
63
- * This method creates a root HD wallet with randomly generated private and public keys.
64
- * @returns {HD} The current HD instance with generated keys.
65
- */
70
+ * Generates a new HD wallet with random keys.
71
+ * This method creates a root HD wallet with randomly generated private and public keys.
72
+ * @returns {HD} The current HD instance with generated keys.
73
+ */
66
74
  public fromRandom (): this {
67
75
  this.versionBytesNum = this.constants.privKey
68
76
  this.depth = 0x00
@@ -75,11 +83,11 @@ export default class HD {
75
83
  }
76
84
 
77
85
  /**
78
- * Generates a new HD wallet with random keys.
79
- * This method creates a root HD wallet with randomly generated private and public keys.
80
- * @returns {HD} A new HD instance with generated keys.
81
- * @static
82
- */
86
+ * Generates a new HD wallet with random keys.
87
+ * This method creates a root HD wallet with randomly generated private and public keys.
88
+ * @returns {HD} A new HD instance with generated keys.
89
+ * @static
90
+ */
83
91
  public static fromRandom (): HD {
84
92
  return new this().fromRandom()
85
93
  }
@@ -95,11 +103,11 @@ export default class HD {
95
103
  }
96
104
 
97
105
  /**
98
- * Initializes the HD wallet from a given base58 encoded string.
99
- * This method decodes a provided string to set up the HD wallet's properties.
100
- * @param str - A base58 encoded string representing the wallet.
101
- * @returns {HD} The current instance with properties set from the string.
102
- */
106
+ * Initializes the HD wallet from a given base58 encoded string.
107
+ * This method decodes a provided string to set up the HD wallet's properties.
108
+ * @param str - A base58 encoded string representing the wallet.
109
+ * @returns {HD} The current instance with properties set from the string.
110
+ */
103
111
  public fromString (str: string): this {
104
112
  const decoded = fromBase58Check(str)
105
113
  return this.fromBinary([...decoded.prefix, ...decoded.data] as number[])
@@ -116,11 +124,11 @@ export default class HD {
116
124
  }
117
125
 
118
126
  /**
119
- * Initializes the HD wallet from a seed.
120
- * This method generates keys and other properties from a given seed, conforming to the BIP32 specification.
121
- * @param bytes - An array of bytes representing the seed.
122
- * @returns {HD} The current instance with properties set from the seed.
123
- */
127
+ * Initializes the HD wallet from a seed.
128
+ * This method generates keys and other properties from a given seed, conforming to the BIP32 specification.
129
+ * @param bytes - An array of bytes representing the seed.
130
+ * @returns {HD} The current instance with properties set from the seed.
131
+ */
124
132
  public fromSeed (bytes: number[]): this {
125
133
  if (bytes.length < 128 / 8) {
126
134
  throw new Error('Need more than 128 bits of entropy')
@@ -128,7 +136,10 @@ export default class HD {
128
136
  if (bytes.length > 512 / 8) {
129
137
  throw new Error('More than 512 bits of entropy is nonstandard')
130
138
  }
131
- const hash: number[] = Hash.sha512hmac(toArray('Bitcoin seed', 'utf8'), bytes)
139
+ const hash: number[] = Hash.sha512hmac(
140
+ toArray('Bitcoin seed', 'utf8'),
141
+ bytes
142
+ )
132
143
 
133
144
  this.depth = 0x00
134
145
  this.parentFingerPrint = [0, 0, 0, 0]
@@ -197,11 +208,11 @@ export default class HD {
197
208
  }
198
209
 
199
210
  /**
200
- * Derives a child HD wallet based on a given path.
201
- * The path specifies the hierarchy of the child key to be derived.
202
- * @param path - A string representing the derivation path (e.g., 'm/0'/1).
203
- * @returns {HD} A new HD instance representing the derived child wallet.
204
- */
211
+ * Derives a child HD wallet based on a given path.
212
+ * The path specifies the hierarchy of the child key to be derived.
213
+ * @param path - A string representing the derivation path (e.g., 'm/0'/1).
214
+ * @returns {HD} A new HD instance representing the derived child wallet.
215
+ */
205
216
  public derive (path: string): HD {
206
217
  if (path === 'm') {
207
218
  return this
@@ -211,10 +222,8 @@ export default class HD {
211
222
 
212
223
  // eslint-disable-next-line @typescript-eslint/no-this-alias
213
224
  let bip32: HD = this
214
- for (const i in e) {
215
- const c = e[i]
216
-
217
- if (i === '0') {
225
+ for (const [i, c] of e.entries()) {
226
+ if (i === 0) { // Since `i` is now a number, compare it to 0
218
227
  if (c !== 'm') {
219
228
  throw new Error('invalid path')
220
229
  }
@@ -226,7 +235,8 @@ export default class HD {
226
235
  }
227
236
 
228
237
  const usePrivate = c.length > 1 && c[c.length - 1] === "'"
229
- let childIndex = parseInt(usePrivate ? c.slice(0, c.length - 1) : c, 10) & 0x7fffffff
238
+ let childIndex =
239
+ parseInt(usePrivate ? c.slice(0, c.length - 1) : c, 10) & 0x7fffffff
230
240
 
231
241
  if (usePrivate) {
232
242
  childIndex += 0x80000000
@@ -239,11 +249,11 @@ export default class HD {
239
249
  }
240
250
 
241
251
  /**
242
- * Derives a child HD wallet from the current wallet based on an index.
243
- * This method generates either a private or public child key depending on the current wallet's state.
244
- * @param i - The index of the child key to derive.
245
- * @returns {HD} A new HD instance representing the derived child wallet.
246
- */
252
+ * Derives a child HD wallet from the current wallet based on an index.
253
+ * This method generates either a private or public child key depending on the current wallet's state.
254
+ * @param i - The index of the child key to derive.
255
+ * @returns {HD} A new HD instance representing the derived child wallet.
256
+ */
247
257
  public deriveChild (i: number): HD {
248
258
  if (typeof i !== 'number') {
249
259
  throw new Error('i must be a number')
@@ -260,18 +270,18 @@ export default class HD {
260
270
 
261
271
  const isPrivate = this.versionBytesNum === this.constants.privKey
262
272
 
263
- if (usePrivate && (!this.privKey || !isPrivate)) {
273
+ if (usePrivate && (this.privKey === null || this.privKey === undefined || !isPrivate)) {
264
274
  throw new Error('Cannot do private key derivation without private key')
265
275
  }
266
276
 
267
277
  let ret = null
268
- if (this.privKey) {
278
+ if (this.privKey !== null && this.privKey !== undefined) {
269
279
  let data = null
270
280
 
271
281
  if (usePrivate) {
272
282
  data = [0, ...this.privKey.toArray('be', 32), ...ib]
273
283
  } else {
274
- data = [...this.pubKey.encode(true) as number[], ...ib]
284
+ data = [...(this.pubKey.encode(true) as number[]), ...ib]
275
285
  }
276
286
 
277
287
  const hash = Hash.sha512hmac(this.chainCode, data)
@@ -287,7 +297,7 @@ export default class HD {
287
297
  ret.privKey = new PrivateKey(k.toArray())
288
298
  ret.pubKey = ret.privKey.toPublicKey()
289
299
  } else {
290
- const data = [...this.pubKey.encode(true) as number[], ...ib]
300
+ const data = [...(this.pubKey.encode(true) as number[]), ...ib]
291
301
  const hash = Hash.sha512hmac(this.chainCode, data)
292
302
  const il = new BigNumber(hash.slice(0, 32))
293
303
  const ir = hash.slice(32, 64)
@@ -314,22 +324,30 @@ export default class HD {
314
324
  }
315
325
 
316
326
  /**
317
- * Converts the current HD wallet to a public-only wallet.
318
- * This method strips away the private key information, leaving only the public part.
319
- * @returns {HD} A new HD instance representing the public-only wallet.
320
- */
327
+ * Converts the current HD wallet to a public-only wallet.
328
+ * This method strips away the private key information, leaving only the public part.
329
+ * @returns {HD} A new HD instance representing the public-only wallet.
330
+ */
321
331
  public toPublic (): HD {
322
- const bip32 = new HD(this.versionBytesNum, this.depth, this.parentFingerPrint, this.childIndex, this.chainCode, this.privKey, this.pubKey)
332
+ const bip32 = new HD(
333
+ this.versionBytesNum,
334
+ this.depth,
335
+ this.parentFingerPrint,
336
+ this.childIndex,
337
+ this.chainCode,
338
+ this.privKey,
339
+ this.pubKey
340
+ )
323
341
  bip32.versionBytesNum = this.constants.pubKey
324
342
  bip32.privKey = undefined
325
343
  return bip32
326
344
  }
327
345
 
328
346
  /**
329
- * Converts the HD wallet into a binary representation.
330
- * This method serializes the wallet's properties into a binary format.
331
- * @returns {number[]} An array of numbers representing the binary data of the wallet.
332
- */
347
+ * Converts the HD wallet into a binary representation.
348
+ * This method serializes the wallet's properties into a binary format.
349
+ * @returns {number[]} An array of numbers representing the binary data of the wallet.
350
+ */
333
351
  public toBinary (): number[] {
334
352
  const isPrivate = this.versionBytesNum === this.constants.privKey
335
353
  const isPublic = this.versionBytesNum === this.constants.pubKey
@@ -358,10 +376,10 @@ export default class HD {
358
376
  }
359
377
 
360
378
  /**
361
- * Checks if the HD wallet contains a private key.
362
- * This method determines whether the wallet is a private key wallet or a public key only wallet.
363
- * @returns {boolean} A boolean value indicating whether the wallet has a private key (true) or not (false).
364
- */
379
+ * Checks if the HD wallet contains a private key.
380
+ * This method determines whether the wallet is a private key wallet or a public key only wallet.
381
+ * @returns {boolean} A boolean value indicating whether the wallet has a private key (true) or not (false).
382
+ */
365
383
  public isPrivate (): boolean {
366
384
  return this.versionBytesNum === this.constants.privKey
367
385
  }
@@ -18,31 +18,31 @@ export default class Mnemonic {
18
18
  public Wordlist: { value: string[], space: string }
19
19
 
20
20
  /**
21
- * Constructs a Mnemonic object.
22
- * @param {string} [mnemonic] - An optional mnemonic phrase.
23
- * @param {number[]} [seed] - An optional seed derived from the mnemonic.
24
- * @param {object} [wordlist=wordList] - An object containing a list of words and space character used in the mnemonic.
25
- */
21
+ * Constructs a Mnemonic object.
22
+ * @param {string} [mnemonic] - An optional mnemonic phrase.
23
+ * @param {number[]} [seed] - An optional seed derived from the mnemonic.
24
+ * @param {object} [wordlist=wordList] - An object containing a list of words and space character used in the mnemonic.
25
+ */
26
26
  constructor (mnemonic?: string, seed?: number[], wordlist = wordList) {
27
- this.mnemonic = mnemonic
28
- this.seed = seed
27
+ this.mnemonic = mnemonic ?? '' // Default to empty string if undefined
28
+ this.seed = seed ?? [] // Default to empty array if undefined
29
29
  this.Wordlist = wordlist
30
30
  }
31
31
 
32
32
  /**
33
- * Converts the mnemonic and seed into a binary representation.
34
- * @returns {number[]} The binary representation of the mnemonic and seed.
35
- */
33
+ * Converts the mnemonic and seed into a binary representation.
34
+ * @returns {number[]} The binary representation of the mnemonic and seed.
35
+ */
36
36
  public toBinary (): number[] {
37
37
  const bw = new Writer()
38
- if (this.mnemonic) {
38
+ if (this.mnemonic !== '') {
39
39
  const buf = toArray(this.mnemonic, 'utf8')
40
40
  bw.writeVarIntNum(buf.length)
41
41
  bw.write(buf)
42
42
  } else {
43
43
  bw.writeVarIntNum(0)
44
44
  }
45
- if (this.seed) {
45
+ if (this.seed.length > 0) {
46
46
  bw.writeVarIntNum(this.seed.length)
47
47
  bw.write(this.seed)
48
48
  } else {
@@ -52,10 +52,10 @@ export default class Mnemonic {
52
52
  }
53
53
 
54
54
  /**
55
- * Loads a mnemonic and seed from a binary representation.
56
- * @param {number[]} bin - The binary representation of a mnemonic and seed.
57
- * @returns {this} The Mnemonic instance with loaded mnemonic and seed.
58
- */
55
+ * Loads a mnemonic and seed from a binary representation.
56
+ * @param {number[]} bin - The binary representation of a mnemonic and seed.
57
+ * @returns {this} The Mnemonic instance with loaded mnemonic and seed.
58
+ */
59
59
  public fromBinary (bin: number[]): this {
60
60
  const br = new Reader(bin)
61
61
  const mnemoniclen = br.readVarIntNum()
@@ -70,13 +70,13 @@ export default class Mnemonic {
70
70
  }
71
71
 
72
72
  /**
73
- * Generates a random mnemonic from a given bit length.
74
- * @param {number} [bits=128] - The bit length for the random mnemonic (must be a multiple of 32 and at least 128).
75
- * @returns {this} The Mnemonic instance with the new random mnemonic.
76
- * @throws {Error} If the bit length is not a multiple of 32 or is less than 128.
77
- */
73
+ * Generates a random mnemonic from a given bit length.
74
+ * @param {number} [bits=128] - The bit length for the random mnemonic (must be a multiple of 32 and at least 128).
75
+ * @returns {this} The Mnemonic instance with the new random mnemonic.
76
+ * @throws {Error} If the bit length is not a multiple of 32 or is less than 128.
77
+ */
78
78
  public fromRandom (bits?: number): this {
79
- if (!bits) {
79
+ if (bits === undefined || bits === null || isNaN(bits) || bits === 0) {
80
80
  bits = 128
81
81
  }
82
82
  if (bits % 32 !== 0) {
@@ -92,86 +92,88 @@ export default class Mnemonic {
92
92
  }
93
93
 
94
94
  /**
95
- * Static method to generate a Mnemonic instance with a random mnemonic.
96
- * @param {number} [bits=128] - The bit length for the random mnemonic.
97
- * @returns {Mnemonic} A new Mnemonic instance.
98
- */
95
+ * Static method to generate a Mnemonic instance with a random mnemonic.
96
+ * @param {number} [bits=128] - The bit length for the random mnemonic.
97
+ * @returns {Mnemonic} A new Mnemonic instance.
98
+ */
99
99
  public static fromRandom (bits?: number): Mnemonic {
100
100
  return new this().fromRandom(bits)
101
101
  }
102
102
 
103
103
  /**
104
- * Converts given entropy into a mnemonic phrase.
105
- * This method is used to generate a mnemonic from a specific entropy source.
106
- * @param {number[]} buf - The entropy buffer, must be at least 128 bits.
107
- * @returns {this} The Mnemonic instance with the mnemonic set from the given entropy.
108
- * @throws {Error} If the entropy is less than 128 bits.
109
- */
104
+ * Converts given entropy into a mnemonic phrase.
105
+ * This method is used to generate a mnemonic from a specific entropy source.
106
+ * @param {number[]} buf - The entropy buffer, must be at least 128 bits.
107
+ * @returns {this} The Mnemonic instance with the mnemonic set from the given entropy.
108
+ * @throws {Error} If the entropy is less than 128 bits.
109
+ */
110
110
  public fromEntropy (buf: number[]): this {
111
111
  this.entropy2Mnemonic(buf)
112
112
  return this
113
113
  }
114
114
 
115
115
  /**
116
- * Static method to create a Mnemonic instance from a given entropy.
117
- * @param {number[]} buf - The entropy buffer.
118
- * @returns {Mnemonic} A new Mnemonic instance.
119
- */
116
+ * Static method to create a Mnemonic instance from a given entropy.
117
+ * @param {number[]} buf - The entropy buffer.
118
+ * @returns {Mnemonic} A new Mnemonic instance.
119
+ */
120
120
  public static fromEntropy (buf: number[]): Mnemonic {
121
121
  return new this().fromEntropy(buf)
122
122
  }
123
123
 
124
124
  /**
125
- * Sets the mnemonic for the instance from a string.
126
- * @param {string} mnemonic - The mnemonic phrase as a string.
127
- * @returns {this} The Mnemonic instance with the set mnemonic.
128
- */
125
+ * Sets the mnemonic for the instance from a string.
126
+ * @param {string} mnemonic - The mnemonic phrase as a string.
127
+ * @returns {this} The Mnemonic instance with the set mnemonic.
128
+ */
129
129
  public fromString (mnemonic: string): this {
130
130
  this.mnemonic = mnemonic
131
131
  return this
132
132
  }
133
133
 
134
134
  /**
135
- * Static method to create a Mnemonic instance from a mnemonic string.
136
- * @param {string} str - The mnemonic phrase.
137
- * @returns {Mnemonic} A new Mnemonic instance.
138
- */
135
+ * Static method to create a Mnemonic instance from a mnemonic string.
136
+ * @param {string} str - The mnemonic phrase.
137
+ * @returns {Mnemonic} A new Mnemonic instance.
138
+ */
139
139
  public static fromString (str: string): Mnemonic {
140
140
  return new this().fromString(str)
141
141
  }
142
142
 
143
143
  /**
144
- * Converts the instance's mnemonic to a string representation.
145
- * @returns {string} The mnemonic phrase as a string.
146
- */
144
+ * Converts the instance's mnemonic to a string representation.
145
+ * @returns {string} The mnemonic phrase as a string.
146
+ */
147
147
  public toString (): string {
148
148
  return this.mnemonic
149
149
  }
150
150
 
151
151
  /**
152
- * Converts the mnemonic to a seed.
153
- * The mnemonic must pass the validity check before conversion.
154
- * @param {string} [passphrase=''] - An optional passphrase for additional security.
155
- * @returns {number[]} The generated seed.
156
- * @throws {Error} If the mnemonic is invalid.
157
- */
152
+ * Converts the mnemonic to a seed.
153
+ * The mnemonic must pass the validity check before conversion.
154
+ * @param {string} [passphrase=''] - An optional passphrase for additional security.
155
+ * @returns {number[]} The generated seed.
156
+ * @throws {Error} If the mnemonic is invalid.
157
+ */
158
158
  public toSeed (passphrase?: string): number[] {
159
159
  this.mnemonic2Seed(passphrase)
160
160
  return this.seed
161
161
  }
162
162
 
163
163
  /**
164
- * Converts entropy to a mnemonic phrase.
165
- * This method takes a buffer of entropy and converts it into a corresponding
166
- * mnemonic phrase based on the Mnemonic wordlist. The entropy should be at least 128 bits.
167
- * The method applies a checksum and maps the entropy to words in the wordlist.
168
- * @param {number[]} buf - The entropy buffer to convert. Must be at least 128 bits.
169
- * @returns {this} The Mnemonic instance with the mnemonic set from the entropy.
170
- * @throws {Error} If the entropy is less than 128 bits or if it's not an even multiple of 11 bits.
171
- */
164
+ * Converts entropy to a mnemonic phrase.
165
+ * This method takes a buffer of entropy and converts it into a corresponding
166
+ * mnemonic phrase based on the Mnemonic wordlist. The entropy should be at least 128 bits.
167
+ * The method applies a checksum and maps the entropy to words in the wordlist.
168
+ * @param {number[]} buf - The entropy buffer to convert. Must be at least 128 bits.
169
+ * @returns {this} The Mnemonic instance with the mnemonic set from the entropy.
170
+ * @throws {Error} If the entropy is less than 128 bits or if it's not an even multiple of 11 bits.
171
+ */
172
172
  public entropy2Mnemonic (buf: number[]): this {
173
173
  if (buf.length < 128 / 8) {
174
- throw new Error('Entropy is less than 128 bits. It must be 128 bits or more.')
174
+ throw new Error(
175
+ 'Entropy is less than 128 bits. It must be 128 bits or more.'
176
+ )
175
177
  }
176
178
 
177
179
  const hash = Hash.sha256(buf)
@@ -185,7 +187,10 @@ export default class Mnemonic {
185
187
  bin = bin + hashbits
186
188
 
187
189
  if (bin.length % 11 !== 0) {
188
- throw new Error('internal error - entropy not an even multiple of 11 bits - ' + bin.length)
190
+ throw new Error(
191
+ 'internal error - entropy not an even multiple of 11 bits - ' +
192
+ bin.length.toString()
193
+ )
189
194
  }
190
195
 
191
196
  let mnemonic = ''
@@ -202,11 +207,11 @@ export default class Mnemonic {
202
207
  }
203
208
 
204
209
  /**
205
- * Validates the mnemonic phrase.
206
- * Checks for correct length, absence of invalid words, and proper checksum.
207
- * @returns {boolean} True if the mnemonic is valid, false otherwise.
208
- * @throws {Error} If the mnemonic is not an even multiple of 11 bits.
209
- */
210
+ * Validates the mnemonic phrase.
211
+ * Checks for correct length, absence of invalid words, and proper checksum.
212
+ * @returns {boolean} True if the mnemonic is valid, false otherwise.
213
+ * @throws {Error} If the mnemonic is not an even multiple of 11 bits.
214
+ */
210
215
  public check (): boolean {
211
216
  const mnemonic = this.mnemonic
212
217
 
@@ -222,14 +227,18 @@ export default class Mnemonic {
222
227
  }
223
228
 
224
229
  if (bin.length % 11 !== 0) {
225
- throw new Error('internal error - entropy not an even multiple of 11 bits - ' + bin.length)
230
+ throw new Error(
231
+ 'internal error - entropy not an even multiple of 11 bits - ' +
232
+ bin.length.toString()
233
+ )
226
234
  }
227
235
 
228
236
  // confirm checksum
229
237
  const cs = bin.length / 33
230
238
  const hashBits = bin.slice(-cs)
231
239
  const nonhashBits = bin.slice(0, bin.length - cs)
232
- const buf = []
240
+ const buf: number[] = []
241
+
233
242
  for (let i = 0; i < nonhashBits.length / 8; i++) {
234
243
  buf.push(parseInt(bin.slice(i * 8, (i + 1) * 8), 2))
235
244
  }
@@ -241,14 +250,14 @@ export default class Mnemonic {
241
250
  }
242
251
 
243
252
  /**
244
- * Converts a mnemonic to a seed.
245
- * This method takes the instance's mnemonic phrase, combines it with a passphrase (if provided),
246
- * and uses PBKDF2 to generate a seed. It also validates the mnemonic before conversion.
247
- * This seed can then be used for generating deterministic keys.
248
- * @param {string} [passphrase=''] - An optional passphrase for added security.
249
- * @returns {this} The Mnemonic instance with the seed generated from the mnemonic.
250
- * @throws {Error} If the mnemonic does not pass validation or if the passphrase is not a string.
251
- */
253
+ * Converts a mnemonic to a seed.
254
+ * This method takes the instance's mnemonic phrase, combines it with a passphrase (if provided),
255
+ * and uses PBKDF2 to generate a seed. It also validates the mnemonic before conversion.
256
+ * This seed can then be used for generating deterministic keys.
257
+ * @param {string} [passphrase=''] - An optional passphrase for added security.
258
+ * @returns {this} The Mnemonic instance with the seed generated from the mnemonic.
259
+ * @throws {Error} If the mnemonic does not pass validation or if the passphrase is not a string.
260
+ */
252
261
  public mnemonic2Seed (passphrase = ''): this {
253
262
  let mnemonic = this.mnemonic
254
263
  if (!this.check()) {
@@ -262,33 +271,37 @@ export default class Mnemonic {
262
271
  mnemonic = mnemonic.normalize('NFKD')
263
272
  passphrase = passphrase.normalize('NFKD')
264
273
  const mbuf = toArray(mnemonic, 'utf8')
265
- const pbuf = [...toArray('mnemonic', 'utf8'), ...toArray(passphrase, 'utf8')]
274
+ const pbuf = [
275
+ ...toArray('mnemonic', 'utf8'),
276
+ ...toArray(passphrase, 'utf8')
277
+ ]
266
278
  this.seed = Hash.pbkdf2(mbuf, pbuf, 2048, 64, 'sha512')
267
279
  return this
268
280
  }
269
281
 
270
282
  /**
271
- * Determines the validity of a given passphrase with the mnemonic.
272
- * This method is useful for checking if a passphrase matches with the mnemonic.
273
- * @param {string} [passphrase=''] - The passphrase to validate.
274
- * @returns {boolean} True if the mnemonic and passphrase combination is valid, false otherwise.
275
- */
283
+ * Determines the validity of a given passphrase with the mnemonic.
284
+ * This method is useful for checking if a passphrase matches with the mnemonic.
285
+ * @param {string} [passphrase=''] - The passphrase to validate.
286
+ * @returns {boolean} True if the mnemonic and passphrase combination is valid, false otherwise.
287
+ */
276
288
  public isValid (passphrase = ''): boolean {
277
289
  let isValid
278
290
  try {
279
- isValid = !!this.mnemonic2Seed(passphrase)
280
- } catch (err) {
291
+ this.mnemonic2Seed(passphrase)
292
+ isValid = true
293
+ } catch {
281
294
  isValid = false
282
295
  }
283
296
  return isValid
284
297
  }
285
298
 
286
299
  /**
287
- * Static method to check the validity of a given mnemonic and passphrase combination.
288
- * @param {string} mnemonic - The mnemonic phrase.
289
- * @param {string} [passphrase=''] - The passphrase to validate.
290
- * @returns {boolean} True if the combination is valid, false otherwise.
291
- */
300
+ * Static method to check the validity of a given mnemonic and passphrase combination.
301
+ * @param {string} mnemonic - The mnemonic phrase.
302
+ * @param {string} [passphrase=''] - The passphrase to validate.
303
+ * @returns {boolean} True if the combination is valid, false otherwise.
304
+ */
292
305
  public static isValid (mnemonic: string, passphrase = ''): boolean {
293
306
  return new Mnemonic(mnemonic).isValid(passphrase)
294
307
  }
@@ -36,10 +36,13 @@ interface jsonUtxo {
36
36
  * @param unlockingScriptTemplate: { sign: (tx: Transaction, inputIndex: number) => Promise<UnlockingScript>, estimateLength: (tx: Transaction, inputIndex: number) => Promise<number> }
37
37
  * @returns
38
38
  */
39
- export default function fromUtxo (utxo: jsonUtxo, unlockingScriptTemplate: {
40
- sign: (tx: Transaction, inputIndex: number) => Promise<UnlockingScript>
41
- estimateLength: (tx: Transaction, inputIndex: number) => Promise<number>
42
- }): TransactionInput {
39
+ export default function fromUtxo (
40
+ utxo: jsonUtxo,
41
+ unlockingScriptTemplate: {
42
+ sign: (tx: Transaction, inputIndex: number) => Promise<UnlockingScript>
43
+ estimateLength: (tx: Transaction, inputIndex: number) => Promise<number>
44
+ }
45
+ ): TransactionInput {
43
46
  const sourceTransaction = new Transaction(0, [], [], 0)
44
47
  sourceTransaction.outputs = Array(utxo.vout + 1).fill(null)
45
48
  sourceTransaction.outputs[utxo.vout] = {
@@ -51,6 +54,6 @@ export default function fromUtxo (utxo: jsonUtxo, unlockingScriptTemplate: {
51
54
  sourceTXID: utxo.txid,
52
55
  sourceOutputIndex: utxo.vout,
53
56
  unlockingScriptTemplate,
54
- sequence: 0xFFFFFFFF
57
+ sequence: 0xffffffff
55
58
  }
56
59
  }