beignet 0.0.53 → 0.1.0

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 (771) hide show
  1. package/README.md +477 -140
  2. package/dist/cli/beignet-node.js +2392 -0
  3. package/dist/cli/beignet-node.js.map +1 -0
  4. package/dist/cli/cli.js +648 -0
  5. package/dist/cli/cli.js.map +1 -0
  6. package/dist/cli/config.js +144 -0
  7. package/dist/cli/config.js.map +1 -0
  8. package/dist/cli/daemon.js +770 -0
  9. package/dist/cli/daemon.js.map +1 -0
  10. package/dist/cli/errors.js +143 -0
  11. package/dist/cli/errors.js.map +1 -0
  12. package/dist/cli/http-rate-limiter.js +62 -0
  13. package/dist/cli/http-rate-limiter.js.map +1 -0
  14. package/dist/cli/index.js +40 -0
  15. package/dist/cli/index.js.map +1 -0
  16. package/dist/cli/instance-lock.js +105 -0
  17. package/dist/cli/instance-lock.js.map +1 -0
  18. package/dist/cli/openapi.js +2005 -0
  19. package/dist/cli/openapi.js.map +1 -0
  20. package/dist/cli/payment-queue.js +198 -0
  21. package/dist/cli/payment-queue.js.map +1 -0
  22. package/dist/cli/types.js +3 -0
  23. package/dist/cli/types.js.map +1 -0
  24. package/dist/cli/webhooks.js +181 -0
  25. package/dist/cli/webhooks.js.map +1 -0
  26. package/dist/electrum/index.js +109 -77
  27. package/dist/electrum/index.js.map +1 -1
  28. package/dist/lightning/advisor/channel-suggestions.js +102 -0
  29. package/dist/lightning/advisor/channel-suggestions.js.map +1 -0
  30. package/dist/lightning/advisor/fee-advisor.js +96 -0
  31. package/dist/lightning/advisor/fee-advisor.js.map +1 -0
  32. package/dist/lightning/advisor/index.js +12 -0
  33. package/dist/lightning/advisor/index.js.map +1 -0
  34. package/dist/lightning/advisor/liquidity-advisor.js +153 -0
  35. package/dist/lightning/advisor/liquidity-advisor.js.map +1 -0
  36. package/dist/lightning/async-payments/manager.js +63 -0
  37. package/dist/lightning/async-payments/manager.js.map +1 -0
  38. package/dist/lightning/async-payments/types.js +6 -0
  39. package/dist/lightning/async-payments/types.js.map +1 -0
  40. package/dist/lightning/bootstrap/dns.js +115 -0
  41. package/dist/lightning/bootstrap/dns.js.map +1 -0
  42. package/dist/lightning/bootstrap/index.js +20 -0
  43. package/dist/lightning/bootstrap/index.js.map +1 -0
  44. package/dist/lightning/bootstrap/seeds.js +35 -0
  45. package/dist/lightning/bootstrap/seeds.js.map +1 -0
  46. package/dist/lightning/bootstrap/types.js +3 -0
  47. package/dist/lightning/bootstrap/types.js.map +1 -0
  48. package/dist/lightning/chain/chain-monitor.js +702 -0
  49. package/dist/lightning/chain/chain-monitor.js.map +1 -0
  50. package/dist/lightning/chain/chain-watcher.js +424 -0
  51. package/dist/lightning/chain/chain-watcher.js.map +1 -0
  52. package/dist/lightning/chain/closing.js +194 -0
  53. package/dist/lightning/chain/closing.js.map +1 -0
  54. package/dist/lightning/chain/electrum-backend.js +254 -0
  55. package/dist/lightning/chain/electrum-backend.js.map +1 -0
  56. package/dist/lightning/chain/index.js +24 -0
  57. package/dist/lightning/chain/index.js.map +1 -0
  58. package/dist/lightning/chain/output-resolver.js +1316 -0
  59. package/dist/lightning/chain/output-resolver.js.map +1 -0
  60. package/dist/lightning/chain/sweep.js +291 -0
  61. package/dist/lightning/chain/sweep.js.map +1 -0
  62. package/dist/lightning/chain/types.js +56 -0
  63. package/dist/lightning/chain/types.js.map +1 -0
  64. package/dist/lightning/channel/channel-actions.js +24 -0
  65. package/dist/lightning/channel/channel-actions.js.map +1 -0
  66. package/dist/lightning/channel/channel-manager.js +2253 -0
  67. package/dist/lightning/channel/channel-manager.js.map +1 -0
  68. package/dist/lightning/channel/channel-state.js +158 -0
  69. package/dist/lightning/channel/channel-state.js.map +1 -0
  70. package/dist/lightning/channel/channel.js +4903 -0
  71. package/dist/lightning/channel/channel.js.map +1 -0
  72. package/dist/lightning/channel/commitment-builder.js +565 -0
  73. package/dist/lightning/channel/commitment-builder.js.map +1 -0
  74. package/dist/lightning/channel/commitment-musig.js +40 -0
  75. package/dist/lightning/channel/commitment-musig.js.map +1 -0
  76. package/dist/lightning/channel/dual-funding.js +567 -0
  77. package/dist/lightning/channel/dual-funding.js.map +1 -0
  78. package/dist/lightning/channel/index.js +29 -0
  79. package/dist/lightning/channel/index.js.map +1 -0
  80. package/dist/lightning/channel/liquidity-ads.js +52 -0
  81. package/dist/lightning/channel/liquidity-ads.js.map +1 -0
  82. package/dist/lightning/channel/quiescence.js +74 -0
  83. package/dist/lightning/channel/quiescence.js.map +1 -0
  84. package/dist/lightning/channel/splice-tx.js +93 -0
  85. package/dist/lightning/channel/splice-tx.js.map +1 -0
  86. package/dist/lightning/channel/splice-weight.js +30 -0
  87. package/dist/lightning/channel/splice-weight.js.map +1 -0
  88. package/dist/lightning/channel/splice.js +347 -0
  89. package/dist/lightning/channel/splice.js.map +1 -0
  90. package/dist/lightning/channel/types.js +70 -0
  91. package/dist/lightning/channel/types.js.map +1 -0
  92. package/dist/lightning/channel/validation.js +169 -0
  93. package/dist/lightning/channel/validation.js.map +1 -0
  94. package/dist/lightning/channel/zero-conf.js +28 -0
  95. package/dist/lightning/channel/zero-conf.js.map +1 -0
  96. package/dist/lightning/crypto/chacha20poly1305.js +57 -0
  97. package/dist/lightning/crypto/chacha20poly1305.js.map +1 -0
  98. package/dist/lightning/crypto/ecdh.js +131 -0
  99. package/dist/lightning/crypto/ecdh.js.map +1 -0
  100. package/dist/lightning/crypto/hkdf.js +56 -0
  101. package/dist/lightning/crypto/hkdf.js.map +1 -0
  102. package/dist/lightning/crypto/index.js +20 -0
  103. package/dist/lightning/crypto/index.js.map +1 -0
  104. package/dist/lightning/crypto/musig.js +168 -0
  105. package/dist/lightning/crypto/musig.js.map +1 -0
  106. package/dist/lightning/features/flags.js +150 -0
  107. package/dist/lightning/features/flags.js.map +1 -0
  108. package/dist/lightning/features/index.js +18 -0
  109. package/dist/lightning/features/index.js.map +1 -0
  110. package/dist/lightning/gossip/gossip-queries.js +141 -0
  111. package/dist/lightning/gossip/gossip-queries.js.map +1 -0
  112. package/dist/lightning/gossip/gossip-sync.js +161 -0
  113. package/dist/lightning/gossip/gossip-sync.js.map +1 -0
  114. package/dist/lightning/gossip/index.js +27 -0
  115. package/dist/lightning/gossip/index.js.map +1 -0
  116. package/dist/lightning/gossip/messages.js +362 -0
  117. package/dist/lightning/gossip/messages.js.map +1 -0
  118. package/dist/lightning/gossip/mission-control.js +123 -0
  119. package/dist/lightning/gossip/mission-control.js.map +1 -0
  120. package/dist/lightning/gossip/network-graph.js +237 -0
  121. package/dist/lightning/gossip/network-graph.js.map +1 -0
  122. package/dist/lightning/gossip/pathfinding.js +551 -0
  123. package/dist/lightning/gossip/pathfinding.js.map +1 -0
  124. package/dist/lightning/gossip/rapid-sync.js +201 -0
  125. package/dist/lightning/gossip/rapid-sync.js.map +1 -0
  126. package/dist/lightning/gossip/scid-encoding.js +50 -0
  127. package/dist/lightning/gossip/scid-encoding.js.map +1 -0
  128. package/dist/lightning/gossip/types.js +86 -0
  129. package/dist/lightning/gossip/types.js.map +1 -0
  130. package/dist/lightning/gossip/validation.js +71 -0
  131. package/dist/lightning/gossip/validation.js.map +1 -0
  132. package/dist/lightning/index.js +47 -0
  133. package/dist/lightning/index.js.map +1 -0
  134. package/dist/lightning/interactive-tx/builder.js +213 -0
  135. package/dist/lightning/interactive-tx/builder.js.map +1 -0
  136. package/dist/lightning/interactive-tx/index.js +20 -0
  137. package/dist/lightning/interactive-tx/index.js.map +1 -0
  138. package/dist/lightning/interactive-tx/types.js +12 -0
  139. package/dist/lightning/interactive-tx/types.js.map +1 -0
  140. package/dist/lightning/interactive-tx/validation.js +75 -0
  141. package/dist/lightning/interactive-tx/validation.js.map +1 -0
  142. package/dist/lightning/invoice/amount.js +102 -0
  143. package/dist/lightning/invoice/amount.js.map +1 -0
  144. package/dist/lightning/invoice/decode.js +196 -0
  145. package/dist/lightning/invoice/decode.js.map +1 -0
  146. package/dist/lightning/invoice/encode.js +120 -0
  147. package/dist/lightning/invoice/encode.js.map +1 -0
  148. package/dist/lightning/invoice/index.js +26 -0
  149. package/dist/lightning/invoice/index.js.map +1 -0
  150. package/dist/lightning/invoice/signing.js +104 -0
  151. package/dist/lightning/invoice/signing.js.map +1 -0
  152. package/dist/lightning/invoice/types.js +32 -0
  153. package/dist/lightning/invoice/types.js.map +1 -0
  154. package/dist/lightning/invoice/words.js +53 -0
  155. package/dist/lightning/invoice/words.js.map +1 -0
  156. package/dist/lightning/keys/derivation.js +43 -0
  157. package/dist/lightning/keys/derivation.js.map +1 -0
  158. package/dist/lightning/keys/index.js +21 -0
  159. package/dist/lightning/keys/index.js.map +1 -0
  160. package/dist/lightning/keys/shachain.js +110 -0
  161. package/dist/lightning/keys/shachain.js.map +1 -0
  162. package/dist/lightning/keys/signer.js +119 -0
  163. package/dist/lightning/keys/signer.js.map +1 -0
  164. package/dist/lightning/keys/wallet-keys.js +120 -0
  165. package/dist/lightning/keys/wallet-keys.js.map +1 -0
  166. package/dist/lightning/message/channel-close.js +220 -0
  167. package/dist/lightning/message/channel-close.js.map +1 -0
  168. package/dist/lightning/message/channel-commitment.js +133 -0
  169. package/dist/lightning/message/channel-commitment.js.map +1 -0
  170. package/dist/lightning/message/channel-funding.js +159 -0
  171. package/dist/lightning/message/channel-funding.js.map +1 -0
  172. package/dist/lightning/message/channel-open.js +263 -0
  173. package/dist/lightning/message/channel-open.js.map +1 -0
  174. package/dist/lightning/message/channel-reestablish.js +92 -0
  175. package/dist/lightning/message/channel-reestablish.js.map +1 -0
  176. package/dist/lightning/message/channel-update.js +167 -0
  177. package/dist/lightning/message/channel-update.js.map +1 -0
  178. package/dist/lightning/message/codec.js +87 -0
  179. package/dist/lightning/message/codec.js.map +1 -0
  180. package/dist/lightning/message/dual-funding.js +293 -0
  181. package/dist/lightning/message/dual-funding.js.map +1 -0
  182. package/dist/lightning/message/error.js +49 -0
  183. package/dist/lightning/message/error.js.map +1 -0
  184. package/dist/lightning/message/index.js +33 -0
  185. package/dist/lightning/message/index.js.map +1 -0
  186. package/dist/lightning/message/init.js +71 -0
  187. package/dist/lightning/message/init.js.map +1 -0
  188. package/dist/lightning/message/interactive-tx.js +342 -0
  189. package/dist/lightning/message/interactive-tx.js.map +1 -0
  190. package/dist/lightning/message/ping.js +49 -0
  191. package/dist/lightning/message/ping.js.map +1 -0
  192. package/dist/lightning/message/splice.js +195 -0
  193. package/dist/lightning/message/splice.js.map +1 -0
  194. package/dist/lightning/message/stfu.js +21 -0
  195. package/dist/lightning/message/stfu.js.map +1 -0
  196. package/dist/lightning/message/tlv.js +59 -0
  197. package/dist/lightning/message/tlv.js.map +1 -0
  198. package/dist/lightning/message/types.js +67 -0
  199. package/dist/lightning/message/types.js.map +1 -0
  200. package/dist/lightning/node/index.js +20 -0
  201. package/dist/lightning/node/index.js.map +1 -0
  202. package/dist/lightning/node/lightning-node.js +4433 -0
  203. package/dist/lightning/node/lightning-node.js.map +1 -0
  204. package/dist/lightning/node/rate-limiter.js +41 -0
  205. package/dist/lightning/node/rate-limiter.js.map +1 -0
  206. package/dist/lightning/node/types.js +34 -0
  207. package/dist/lightning/node/types.js.map +1 -0
  208. package/dist/lightning/offer/decode.js +54 -0
  209. package/dist/lightning/offer/decode.js.map +1 -0
  210. package/dist/lightning/offer/encode.js +25 -0
  211. package/dist/lightning/offer/encode.js.map +1 -0
  212. package/dist/lightning/offer/index.js +24 -0
  213. package/dist/lightning/offer/index.js.map +1 -0
  214. package/dist/lightning/offer/merkle.js +68 -0
  215. package/dist/lightning/offer/merkle.js.map +1 -0
  216. package/dist/lightning/offer/offer-manager.js +294 -0
  217. package/dist/lightning/offer/offer-manager.js.map +1 -0
  218. package/dist/lightning/offer/schnorr.js +67 -0
  219. package/dist/lightning/offer/schnorr.js.map +1 -0
  220. package/dist/lightning/offer/tlv.js +479 -0
  221. package/dist/lightning/offer/tlv.js.map +1 -0
  222. package/dist/lightning/offer/types.js +3 -0
  223. package/dist/lightning/offer/types.js.map +1 -0
  224. package/dist/lightning/onion/blinded-path.js +274 -0
  225. package/dist/lightning/onion/blinded-path.js.map +1 -0
  226. package/dist/lightning/onion/blinding.js +73 -0
  227. package/dist/lightning/onion/blinding.js.map +1 -0
  228. package/dist/lightning/onion/construct.js +97 -0
  229. package/dist/lightning/onion/construct.js.map +1 -0
  230. package/dist/lightning/onion/failures.js +177 -0
  231. package/dist/lightning/onion/failures.js.map +1 -0
  232. package/dist/lightning/onion/hop-payload.js +148 -0
  233. package/dist/lightning/onion/hop-payload.js.map +1 -0
  234. package/dist/lightning/onion/index.js +25 -0
  235. package/dist/lightning/onion/index.js.map +1 -0
  236. package/dist/lightning/onion/process.js +54 -0
  237. package/dist/lightning/onion/process.js.map +1 -0
  238. package/dist/lightning/onion/sphinx-crypto.js +59 -0
  239. package/dist/lightning/onion/sphinx-crypto.js.map +1 -0
  240. package/dist/lightning/onion/types.js +28 -0
  241. package/dist/lightning/onion/types.js.map +1 -0
  242. package/dist/lightning/onion-message/codec.js +153 -0
  243. package/dist/lightning/onion-message/codec.js.map +1 -0
  244. package/dist/lightning/onion-message/construct.js +150 -0
  245. package/dist/lightning/onion-message/construct.js.map +1 -0
  246. package/dist/lightning/onion-message/index.js +22 -0
  247. package/dist/lightning/onion-message/index.js.map +1 -0
  248. package/dist/lightning/onion-message/manager.js +143 -0
  249. package/dist/lightning/onion-message/manager.js.map +1 -0
  250. package/dist/lightning/onion-message/process.js +98 -0
  251. package/dist/lightning/onion-message/process.js.map +1 -0
  252. package/dist/lightning/onion-message/types.js +10 -0
  253. package/dist/lightning/onion-message/types.js.map +1 -0
  254. package/dist/lightning/script/anchor.js +71 -0
  255. package/dist/lightning/script/anchor.js.map +1 -0
  256. package/dist/lightning/script/commitment-taproot.js +279 -0
  257. package/dist/lightning/script/commitment-taproot.js.map +1 -0
  258. package/dist/lightning/script/commitment.js +216 -0
  259. package/dist/lightning/script/commitment.js.map +1 -0
  260. package/dist/lightning/script/funding-taproot.js +52 -0
  261. package/dist/lightning/script/funding-taproot.js.map +1 -0
  262. package/dist/lightning/script/funding.js +64 -0
  263. package/dist/lightning/script/funding.js.map +1 -0
  264. package/dist/lightning/script/htlc-taproot.js +83 -0
  265. package/dist/lightning/script/htlc-taproot.js.map +1 -0
  266. package/dist/lightning/script/htlc.js +170 -0
  267. package/dist/lightning/script/htlc.js.map +1 -0
  268. package/dist/lightning/script/index.js +22 -0
  269. package/dist/lightning/script/index.js.map +1 -0
  270. package/dist/lightning/script/revocation.js +115 -0
  271. package/dist/lightning/script/revocation.js.map +1 -0
  272. package/dist/lightning/storage/index.js +20 -0
  273. package/dist/lightning/storage/index.js.map +1 -0
  274. package/dist/lightning/storage/serialization.js +588 -0
  275. package/dist/lightning/storage/serialization.js.map +1 -0
  276. package/dist/lightning/storage/sqlite-storage.js +717 -0
  277. package/dist/lightning/storage/sqlite-storage.js.map +1 -0
  278. package/dist/lightning/storage/types.js +3 -0
  279. package/dist/lightning/storage/types.js.map +1 -0
  280. package/dist/lightning/transport/cipher.js +81 -0
  281. package/dist/lightning/transport/cipher.js.map +1 -0
  282. package/dist/lightning/transport/index.js +21 -0
  283. package/dist/lightning/transport/index.js.map +1 -0
  284. package/dist/lightning/transport/noise.js +191 -0
  285. package/dist/lightning/transport/noise.js.map +1 -0
  286. package/dist/lightning/transport/peer-manager.js +279 -0
  287. package/dist/lightning/transport/peer-manager.js.map +1 -0
  288. package/dist/lightning/transport/peer.js +463 -0
  289. package/dist/lightning/transport/peer.js.map +1 -0
  290. package/dist/lightning/transport/wire-capture.js +106 -0
  291. package/dist/lightning/transport/wire-capture.js.map +1 -0
  292. package/dist/lightning/validation/index.js +67 -0
  293. package/dist/lightning/validation/index.js.map +1 -0
  294. package/dist/lightning/wallet/index.js +6 -0
  295. package/dist/lightning/wallet/index.js.map +1 -0
  296. package/dist/lightning/wallet/wallet-funding-provider.js +197 -0
  297. package/dist/lightning/wallet/wallet-funding-provider.js.map +1 -0
  298. package/dist/transaction/index.js +105 -58
  299. package/dist/transaction/index.js.map +1 -1
  300. package/dist/types/cli/beignet-node.d.ts +272 -0
  301. package/dist/types/cli/cli.d.ts +2 -0
  302. package/dist/types/cli/config.d.ts +14 -0
  303. package/dist/types/cli/daemon.d.ts +18 -0
  304. package/dist/types/cli/errors.d.ts +45 -0
  305. package/dist/types/cli/http-rate-limiter.d.ts +15 -0
  306. package/dist/types/cli/index.d.ts +9 -0
  307. package/dist/types/cli/instance-lock.d.ts +11 -0
  308. package/dist/types/cli/openapi.d.ts +1 -0
  309. package/dist/types/cli/payment-queue.d.ts +66 -0
  310. package/dist/types/cli/types.d.ts +400 -0
  311. package/dist/types/cli/webhooks.d.ts +32 -0
  312. package/dist/types/electrum/index.d.ts +3 -1
  313. package/dist/types/lightning/advisor/channel-suggestions.d.ts +17 -0
  314. package/dist/types/lightning/advisor/fee-advisor.d.ts +24 -0
  315. package/dist/types/lightning/advisor/index.d.ts +6 -0
  316. package/dist/types/lightning/advisor/liquidity-advisor.d.ts +59 -0
  317. package/dist/types/lightning/async-payments/manager.d.ts +17 -0
  318. package/dist/types/lightning/async-payments/types.d.ts +8 -0
  319. package/dist/types/lightning/bootstrap/dns.d.ts +20 -0
  320. package/dist/types/lightning/bootstrap/index.d.ts +3 -0
  321. package/dist/types/lightning/bootstrap/seeds.d.ts +3 -0
  322. package/dist/types/lightning/bootstrap/types.d.ts +15 -0
  323. package/dist/types/lightning/chain/chain-monitor.d.ts +52 -0
  324. package/dist/types/lightning/chain/chain-watcher.d.ts +59 -0
  325. package/dist/types/lightning/chain/closing.d.ts +49 -0
  326. package/dist/types/lightning/chain/electrum-backend.d.ts +44 -0
  327. package/dist/types/lightning/chain/index.d.ts +7 -0
  328. package/dist/types/lightning/chain/output-resolver.d.ts +24 -0
  329. package/dist/types/lightning/chain/sweep.d.ts +85 -0
  330. package/dist/types/lightning/chain/types.d.ts +120 -0
  331. package/dist/types/lightning/channel/channel-actions.d.ts +100 -0
  332. package/dist/types/lightning/channel/channel-manager.d.ts +182 -0
  333. package/dist/types/lightning/channel/channel-state.d.ts +144 -0
  334. package/dist/types/lightning/channel/channel.d.ts +261 -0
  335. package/dist/types/lightning/channel/commitment-builder.d.ts +55 -0
  336. package/dist/types/lightning/channel/commitment-musig.d.ts +8 -0
  337. package/dist/types/lightning/channel/dual-funding.d.ts +112 -0
  338. package/dist/types/lightning/channel/index.d.ts +12 -0
  339. package/dist/types/lightning/channel/liquidity-ads.d.ts +8 -0
  340. package/dist/types/lightning/channel/quiescence.d.ts +22 -0
  341. package/dist/types/lightning/channel/splice-tx.d.ts +25 -0
  342. package/dist/types/lightning/channel/splice-weight.d.ts +12 -0
  343. package/dist/types/lightning/channel/splice.d.ts +100 -0
  344. package/dist/types/lightning/channel/types.d.ts +72 -0
  345. package/dist/types/lightning/channel/validation.d.ts +9 -0
  346. package/dist/types/lightning/channel/zero-conf.d.ts +9 -0
  347. package/dist/types/lightning/crypto/chacha20poly1305.d.ts +8 -0
  348. package/dist/types/lightning/crypto/ecdh.d.ts +11 -0
  349. package/dist/types/lightning/crypto/hkdf.d.ts +6 -0
  350. package/dist/types/lightning/crypto/index.d.ts +3 -0
  351. package/dist/types/lightning/crypto/musig.d.ts +34 -0
  352. package/dist/types/lightning/features/flags.d.ts +46 -0
  353. package/dist/types/lightning/features/index.d.ts +1 -0
  354. package/dist/types/lightning/gossip/gossip-queries.d.ts +12 -0
  355. package/dist/types/lightning/gossip/gossip-sync.d.ts +31 -0
  356. package/dist/types/lightning/gossip/index.d.ts +10 -0
  357. package/dist/types/lightning/gossip/messages.d.ts +15 -0
  358. package/dist/types/lightning/gossip/mission-control.d.ts +20 -0
  359. package/dist/types/lightning/gossip/network-graph.d.ts +29 -0
  360. package/dist/types/lightning/gossip/pathfinding.d.ts +23 -0
  361. package/dist/types/lightning/gossip/rapid-sync.d.ts +12 -0
  362. package/dist/types/lightning/gossip/scid-encoding.d.ts +4 -0
  363. package/dist/types/lightning/gossip/types.d.ts +132 -0
  364. package/dist/types/lightning/gossip/validation.d.ts +15 -0
  365. package/dist/types/lightning/index.d.ts +20 -0
  366. package/dist/types/lightning/interactive-tx/builder.d.ts +28 -0
  367. package/dist/types/lightning/interactive-tx/index.d.ts +3 -0
  368. package/dist/types/lightning/interactive-tx/types.d.ts +29 -0
  369. package/dist/types/lightning/interactive-tx/validation.d.ts +8 -0
  370. package/dist/types/lightning/invoice/amount.d.ts +8 -0
  371. package/dist/types/lightning/invoice/decode.d.ts +2 -0
  372. package/dist/types/lightning/invoice/encode.d.ts +2 -0
  373. package/dist/types/lightning/invoice/index.d.ts +6 -0
  374. package/dist/types/lightning/invoice/signing.d.ts +6 -0
  375. package/dist/types/lightning/invoice/types.d.ts +81 -0
  376. package/dist/types/lightning/invoice/words.d.ts +11 -0
  377. package/dist/types/lightning/keys/derivation.d.ts +14 -0
  378. package/dist/types/lightning/keys/index.d.ts +4 -0
  379. package/dist/types/lightning/keys/shachain.d.ts +18 -0
  380. package/dist/types/lightning/keys/signer.d.ts +17 -0
  381. package/dist/types/lightning/keys/wallet-keys.d.ts +31 -0
  382. package/dist/types/lightning/message/channel-close.d.ts +36 -0
  383. package/dist/types/lightning/message/channel-commitment.d.ts +18 -0
  384. package/dist/types/lightning/message/channel-funding.d.ts +25 -0
  385. package/dist/types/lightning/message/channel-open.d.ts +47 -0
  386. package/dist/types/lightning/message/channel-reestablish.d.ts +13 -0
  387. package/dist/types/lightning/message/channel-update.d.ts +40 -0
  388. package/dist/types/lightning/message/codec.d.ts +13 -0
  389. package/dist/types/lightning/message/dual-funding.d.ts +56 -0
  390. package/dist/types/lightning/message/error.d.ts +12 -0
  391. package/dist/types/lightning/message/index.d.ts +16 -0
  392. package/dist/types/lightning/message/init.d.ts +8 -0
  393. package/dist/types/lightning/message/interactive-tx.d.ts +62 -0
  394. package/dist/types/lightning/message/ping.d.ts +12 -0
  395. package/dist/types/lightning/message/splice.d.ts +32 -0
  396. package/dist/types/lightning/message/stfu.d.ts +7 -0
  397. package/dist/types/lightning/message/tlv.d.ts +13 -0
  398. package/dist/types/lightning/message/types.d.ts +52 -0
  399. package/dist/types/lightning/node/index.d.ts +3 -0
  400. package/dist/types/lightning/node/lightning-node.d.ts +339 -0
  401. package/dist/types/lightning/node/rate-limiter.d.ts +14 -0
  402. package/dist/types/lightning/node/types.d.ts +248 -0
  403. package/dist/types/lightning/offer/decode.d.ts +5 -0
  404. package/dist/types/lightning/offer/encode.d.ts +5 -0
  405. package/dist/types/lightning/offer/index.d.ts +7 -0
  406. package/dist/types/lightning/offer/merkle.d.ts +10 -0
  407. package/dist/types/lightning/offer/offer-manager.d.ts +56 -0
  408. package/dist/types/lightning/offer/schnorr.d.ts +5 -0
  409. package/dist/types/lightning/offer/tlv.d.ts +64 -0
  410. package/dist/types/lightning/offer/types.d.ts +61 -0
  411. package/dist/types/lightning/onion/blinded-path.d.ts +61 -0
  412. package/dist/types/lightning/onion/blinding.d.ts +13 -0
  413. package/dist/types/lightning/onion/construct.d.ts +9 -0
  414. package/dist/types/lightning/onion/failures.d.ts +14 -0
  415. package/dist/types/lightning/onion/hop-payload.d.ts +9 -0
  416. package/dist/types/lightning/onion/index.d.ts +8 -0
  417. package/dist/types/lightning/onion/process.d.ts +4 -0
  418. package/dist/types/lightning/onion/sphinx-crypto.d.ts +10 -0
  419. package/dist/types/lightning/onion/types.d.ts +58 -0
  420. package/dist/types/lightning/onion-message/codec.d.ts +13 -0
  421. package/dist/types/lightning/onion-message/construct.d.ts +11 -0
  422. package/dist/types/lightning/onion-message/index.d.ts +5 -0
  423. package/dist/types/lightning/onion-message/manager.d.ts +28 -0
  424. package/dist/types/lightning/onion-message/process.d.ts +3 -0
  425. package/dist/types/lightning/onion-message/types.d.ts +35 -0
  426. package/dist/types/lightning/script/anchor.d.ts +13 -0
  427. package/dist/types/lightning/script/commitment-taproot.d.ts +47 -0
  428. package/dist/types/lightning/script/commitment.d.ts +58 -0
  429. package/dist/types/lightning/script/funding-taproot.d.ts +12 -0
  430. package/dist/types/lightning/script/funding.d.ts +9 -0
  431. package/dist/types/lightning/script/htlc-taproot.d.ts +9 -0
  432. package/dist/types/lightning/script/htlc.d.ts +7 -0
  433. package/dist/types/lightning/script/index.d.ts +5 -0
  434. package/dist/types/lightning/script/revocation.d.ts +16 -0
  435. package/dist/types/lightning/storage/index.d.ts +3 -0
  436. package/dist/types/lightning/storage/serialization.d.ts +213 -0
  437. package/dist/types/lightning/storage/sqlite-storage.d.ts +158 -0
  438. package/dist/types/lightning/storage/types.d.ts +121 -0
  439. package/dist/types/lightning/transport/cipher.d.ts +21 -0
  440. package/dist/types/lightning/transport/index.d.ts +4 -0
  441. package/dist/types/lightning/transport/noise.d.ts +46 -0
  442. package/dist/types/lightning/transport/peer-manager.d.ts +67 -0
  443. package/dist/types/lightning/transport/peer.d.ts +74 -0
  444. package/dist/types/lightning/transport/wire-capture.d.ts +4 -0
  445. package/dist/types/lightning/validation/index.d.ts +9 -0
  446. package/dist/types/lightning/wallet/index.d.ts +1 -0
  447. package/dist/types/lightning/wallet/wallet-funding-provider.d.ts +62 -0
  448. package/dist/types/transaction/index.d.ts +2 -1
  449. package/dist/utils/conversion.js +1 -1
  450. package/dist/utils/conversion.js.map +1 -1
  451. package/dist/utils/electrum.js +3 -4
  452. package/dist/utils/electrum.js.map +1 -1
  453. package/dist/utils/helpers.js +11 -12
  454. package/dist/utils/helpers.js.map +1 -1
  455. package/dist/utils/result.js +0 -1
  456. package/dist/utils/result.js.map +1 -1
  457. package/dist/utils/transaction.js +10 -12
  458. package/dist/utils/transaction.js.map +1 -1
  459. package/dist/utils/wallet.js +2 -2
  460. package/dist/utils/wallet.js.map +1 -1
  461. package/dist/wallet/index.js +173 -121
  462. package/dist/wallet/index.js.map +1 -1
  463. package/docs/AI_AGENT_GUIDE.md +724 -0
  464. package/docs/html/assets/search.js +1 -1
  465. package/docs/html/classes/Electrum.html +115 -55
  466. package/docs/html/classes/Transaction.html +115 -27
  467. package/docs/html/classes/Wallet.html +290 -136
  468. package/docs/html/enums/EAddressType.html +18 -5
  469. package/docs/html/enums/EAvailableNetworks.html +21 -8
  470. package/docs/html/enums/EBoostType.html +16 -3
  471. package/docs/html/enums/ECoinSelectPreference.html +275 -0
  472. package/docs/html/enums/EElectrumNetworks.html +17 -4
  473. package/docs/html/enums/EFeeId.html +19 -6
  474. package/docs/html/enums/EPaymentType.html +16 -3
  475. package/docs/html/enums/EProtocol.html +16 -3
  476. package/docs/html/enums/EScanningStrategy.html +18 -5
  477. package/docs/html/enums/EUnit.html +17 -4
  478. package/docs/html/functions/availableNetworks.html +14 -1
  479. package/docs/html/functions/constructByteCountParam.html +14 -1
  480. package/docs/html/functions/decodeOpReturnMessage.html +14 -1
  481. package/docs/html/functions/decodeRawTransaction.html +14 -1
  482. package/docs/html/functions/err.html +14 -1
  483. package/docs/html/functions/filterAddressesForGapLimit.html +17 -2
  484. package/docs/html/functions/filterAddressesObjForAddressesList.html +241 -0
  485. package/docs/html/functions/filterAddressesObjForGapLimit.html +17 -2
  486. package/docs/html/functions/filterAddressesObjForSingleIndex.html +14 -1
  487. package/docs/html/functions/filterAddressesObjForStartingIndex.html +14 -1
  488. package/docs/html/functions/formatKeyDerivationPath.html +14 -1
  489. package/docs/html/functions/formatPeerData.html +14 -1
  490. package/docs/html/functions/generateMnemonic.html +14 -1
  491. package/docs/html/functions/generateWalletId.html +14 -1
  492. package/docs/html/functions/getAddressFromKeyPair.html +14 -1
  493. package/docs/html/functions/getAddressFromScriptPubKey.html +14 -1
  494. package/docs/html/functions/getAddressIndexDiff.html +14 -1
  495. package/docs/html/functions/getAddressTypeFromPath.html +14 -1
  496. package/docs/html/functions/getAddressesFromPrivateKey.html +14 -1
  497. package/docs/html/functions/getByteCount.html +14 -1
  498. package/docs/html/functions/getDataFallback.html +14 -1
  499. package/docs/html/functions/getDefaultPort.html +14 -1
  500. package/docs/html/functions/getDefaultWalletData.html +14 -1
  501. package/docs/html/functions/getDefaultWalletDataKeys.html +14 -1
  502. package/docs/html/functions/getElectrumNetwork.html +14 -1
  503. package/docs/html/functions/getHighestUsedIndexFromTxHashes.html +14 -1
  504. package/docs/html/functions/getKeyDerivationPath.html +14 -1
  505. package/docs/html/functions/getKeyDerivationPathObject.html +14 -1
  506. package/docs/html/functions/getKeyDerivationPathString.html +14 -1
  507. package/docs/html/functions/getKeyValue.html +14 -1
  508. package/docs/html/functions/getPeers.html +14 -1
  509. package/docs/html/functions/getProtocolForPort.html +14 -1
  510. package/docs/html/functions/getScriptHash.html +14 -1
  511. package/docs/html/functions/getSeed.html +14 -1
  512. package/docs/html/functions/getSeedHash.html +14 -1
  513. package/docs/html/functions/getSha256.html +14 -1
  514. package/docs/html/functions/getStorageKeyValues.html +14 -1
  515. package/docs/html/functions/getTapRootAddressFromPublicKey.html +14 -1
  516. package/docs/html/functions/getTxFee.html +14 -1
  517. package/docs/html/functions/getWalletDataStorageKey.html +14 -1
  518. package/docs/html/functions/isP2trPrefix.html +14 -1
  519. package/docs/html/functions/isPositive.html +14 -1
  520. package/docs/html/functions/isValidBech32mEncodedString.html +14 -1
  521. package/docs/html/functions/objectKeys-1.html +14 -1
  522. package/docs/html/functions/objectsMatch.html +14 -1
  523. package/docs/html/functions/ok.html +14 -1
  524. package/docs/html/functions/parseOnChainPaymentRequest.html +14 -1
  525. package/docs/html/functions/reduceValue.html +14 -1
  526. package/docs/html/functions/removeDustOutputs.html +14 -1
  527. package/docs/html/functions/removeDustUtxos.html +240 -0
  528. package/docs/html/functions/setReplaceByFee.html +14 -1
  529. package/docs/html/functions/shuffleArray.html +14 -1
  530. package/docs/html/functions/sleep.html +14 -1
  531. package/docs/html/functions/splitAddresses.html +243 -0
  532. package/docs/html/functions/validateAddress.html +14 -1
  533. package/docs/html/functions/validateMnemonic.html +14 -1
  534. package/docs/html/functions/validateTransaction.html +14 -1
  535. package/docs/html/index.html +26 -0
  536. package/docs/html/interfaces/IAddInput.html +17 -4
  537. package/docs/html/interfaces/IAddress.html +19 -6
  538. package/docs/html/interfaces/IAddressData.html +17 -4
  539. package/docs/html/interfaces/IAddressType.html +14 -1
  540. package/docs/html/interfaces/IAddressTypeData.html +20 -7
  541. package/docs/html/interfaces/IAddressTypesIO.html +280 -0
  542. package/docs/html/interfaces/IAddresses.html +14 -1
  543. package/docs/html/interfaces/IBoostedTransaction.html +18 -5
  544. package/docs/html/interfaces/IBoostedTransactions.html +14 -1
  545. package/docs/html/interfaces/IBtInfo.html +372 -0
  546. package/docs/html/interfaces/ICanBoostResponse.html +265 -0
  547. package/docs/html/interfaces/ICoinSelectResponse.html +265 -0
  548. package/docs/html/interfaces/ICreateTransaction.html +25 -5
  549. package/docs/html/interfaces/ICustomGetAddress.html +17 -4
  550. package/docs/html/interfaces/ICustomGetScriptHash.html +16 -3
  551. package/docs/html/interfaces/IElectrumGetAddressBalanceRes.html +17 -4
  552. package/docs/html/interfaces/IFormattedPeerData.html +19 -6
  553. package/docs/html/interfaces/IFormattedTransaction.html +43 -23
  554. package/docs/html/interfaces/IFormattedTransactions.html +14 -1
  555. package/docs/html/interfaces/IGenerateAddresses.html +21 -8
  556. package/docs/html/interfaces/IGenerateAddressesResponse.html +16 -3
  557. package/docs/html/interfaces/IGetAddress.html +17 -4
  558. package/docs/html/interfaces/IGetAddressBalanceRes.html +16 -3
  559. package/docs/html/interfaces/IGetAddressByPath.html +16 -3
  560. package/docs/html/interfaces/IGetAddressHistoryResponse.html +21 -8
  561. package/docs/html/interfaces/IGetAddressResponse.html +17 -4
  562. package/docs/html/interfaces/IGetAddressScriptHashBalances.html +19 -6
  563. package/docs/html/interfaces/IGetAddressScriptHashesHistoryResponse.html +19 -6
  564. package/docs/html/interfaces/IGetAddressTxResponse.html +19 -6
  565. package/docs/html/interfaces/IGetAddressesFromKeyPair.html +16 -3
  566. package/docs/html/interfaces/IGetAddressesFromPrivateKey.html +16 -3
  567. package/docs/html/interfaces/IGetDerivationPath.html +20 -7
  568. package/docs/html/interfaces/IGetFeeEstimatesResponse.html +18 -5
  569. package/docs/html/interfaces/IGetHeaderResponse.html +19 -6
  570. package/docs/html/interfaces/IGetNextAvailableAddressResponse.html +18 -5
  571. package/docs/html/interfaces/IGetTransactions.html +19 -6
  572. package/docs/html/interfaces/IGetTransactionsFromInputs.html +19 -6
  573. package/docs/html/interfaces/IGetUtxosResponse.html +16 -3
  574. package/docs/html/interfaces/IHeader.html +17 -4
  575. package/docs/html/interfaces/IIndexes.html +18 -5
  576. package/docs/html/interfaces/IKeyDerivationPath.html +19 -6
  577. package/docs/html/interfaces/IKeyDerivationPathData.html +16 -3
  578. package/docs/html/interfaces/INewBlock.html +16 -3
  579. package/docs/html/interfaces/IOnchainFees.html +19 -6
  580. package/docs/html/interfaces/IOutput.html +17 -4
  581. package/docs/html/interfaces/IPeerData.html +17 -4
  582. package/docs/html/interfaces/IPrivateKeyInfo.html +18 -5
  583. package/docs/html/interfaces/IRbfData.html +27 -7
  584. package/docs/html/interfaces/ISend.html +16 -3
  585. package/docs/html/interfaces/ISendTransaction.html +30 -17
  586. package/docs/html/interfaces/ISendTx.html +17 -4
  587. package/docs/html/interfaces/ISetupTransaction.html +19 -6
  588. package/docs/html/interfaces/ISubscribeToAddress.html +18 -5
  589. package/docs/html/interfaces/ISubscribeToHeader.html +18 -5
  590. package/docs/html/interfaces/ISweepPrivateKey.html +19 -6
  591. package/docs/html/interfaces/ISweepPrivateKeyRes.html +17 -4
  592. package/docs/html/interfaces/ITargets.html +18 -5
  593. package/docs/html/interfaces/ITransaction.html +20 -7
  594. package/docs/html/interfaces/ITxHash.html +15 -2
  595. package/docs/html/interfaces/ITxHashes.html +17 -4
  596. package/docs/html/interfaces/IUtxo.html +24 -11
  597. package/docs/html/interfaces/IVin.html +19 -6
  598. package/docs/html/interfaces/IVout.html +17 -4
  599. package/docs/html/interfaces/IWallet.html +47 -27
  600. package/docs/html/interfaces/IWalletData.html +32 -19
  601. package/docs/html/types/ElectrumConnectionPubSub.html +14 -1
  602. package/docs/html/types/ElectrumConnectionSubscription.html +15 -2
  603. package/docs/html/types/InputData.html +14 -1
  604. package/docs/html/types/Net.html +227 -0
  605. package/docs/html/types/ObjectKeys.html +14 -1
  606. package/docs/html/types/Result.html +14 -1
  607. package/docs/html/types/TAddressIndexInfo.html +14 -1
  608. package/docs/html/types/TAddressLabel.html +14 -1
  609. package/docs/html/types/TAddressTxResponse.html +14 -1
  610. package/docs/html/types/TAddressType.html +14 -1
  611. package/docs/html/types/TAddressTypeContent.html +14 -1
  612. package/docs/html/types/TAddressTypes.html +14 -1
  613. package/docs/html/types/TAvailableNetworks.html +14 -1
  614. package/docs/html/types/TConnectToElectrumRes.html +14 -1
  615. package/docs/html/types/TDecodeRawTx.html +14 -1
  616. package/docs/html/types/TElectrumNetworks.html +14 -1
  617. package/docs/html/types/TGapLimitOptions.html +20 -3
  618. package/docs/html/types/TGetAddressHistory.html +14 -1
  619. package/docs/html/types/TGetByteCountInput.html +14 -1
  620. package/docs/html/types/TGetByteCountInputs.html +14 -1
  621. package/docs/html/types/TGetByteCountOutput.html +14 -1
  622. package/docs/html/types/TGetByteCountOutputs.html +14 -1
  623. package/docs/html/types/TGetData.html +14 -1
  624. package/docs/html/types/TGetTotalFeeObj.html +14 -1
  625. package/docs/html/types/TKeyDerivationAccount.html +14 -1
  626. package/docs/html/types/TKeyDerivationChange.html +14 -1
  627. package/docs/html/types/TKeyDerivationCoinType.html +14 -1
  628. package/docs/html/types/TKeyDerivationIndex.html +14 -1
  629. package/docs/html/types/TKeyDerivationPurpose.html +14 -1
  630. package/docs/html/types/TMessageDataMap.html +14 -1
  631. package/docs/html/types/TMessageKeys.html +14 -1
  632. package/docs/html/types/TOnMessage.html +14 -1
  633. package/docs/html/types/TProcessUnconfirmedTransactions.html +14 -1
  634. package/docs/html/types/TProtocol.html +14 -1
  635. package/docs/html/types/TServer.html +14 -1
  636. package/docs/html/types/TSetData.html +14 -1
  637. package/docs/html/types/TSetupTransactionResponse.html +14 -1
  638. package/docs/html/types/TStorage.html +14 -1
  639. package/docs/html/types/TSubscribedReceive.html +14 -1
  640. package/docs/html/types/TTransactionMessage.html +14 -1
  641. package/docs/html/types/TTxDetails.html +17 -4
  642. package/docs/html/types/TTxResponse.html +14 -1
  643. package/docs/html/types/TTxResult.html +14 -1
  644. package/docs/html/types/TUnspentAddressScriptHash.html +238 -0
  645. package/docs/html/types/TUnspentAddressScriptHashData.html +14 -1
  646. package/docs/html/types/TUnspentAddressScriptHashResponse.html +240 -0
  647. package/docs/html/types/TUnspentAddressScriptHashResult.html +240 -0
  648. package/docs/html/types/TWalletDataKeys.html +14 -1
  649. package/docs/html/types/Tls.html +227 -0
  650. package/docs/html/variables/defaultElectrumPorts.html +14 -1
  651. package/docs/html/variables/electrumConnection.html +14 -1
  652. package/docs/markdown/README.md +265 -102
  653. package/docs/markdown/classes/Electrum.md +104 -52
  654. package/docs/markdown/classes/Transaction.md +101 -24
  655. package/docs/markdown/classes/Wallet.md +286 -129
  656. package/docs/markdown/enums/EAddressType.md +4 -4
  657. package/docs/markdown/enums/EAvailableNetworks.md +7 -7
  658. package/docs/markdown/enums/EBoostType.md +2 -2
  659. package/docs/markdown/enums/ECoinSelectPreference.md +63 -0
  660. package/docs/markdown/enums/EElectrumNetworks.md +3 -3
  661. package/docs/markdown/enums/EFeeId.md +5 -5
  662. package/docs/markdown/enums/EPaymentType.md +2 -2
  663. package/docs/markdown/enums/EProtocol.md +2 -2
  664. package/docs/markdown/enums/EScanningStrategy.md +4 -4
  665. package/docs/markdown/enums/EUnit.md +3 -3
  666. package/docs/markdown/interfaces/IAddInput.md +3 -3
  667. package/docs/markdown/interfaces/IAddress.md +5 -5
  668. package/docs/markdown/interfaces/IAddressData.md +3 -3
  669. package/docs/markdown/interfaces/IAddressTypeData.md +6 -6
  670. package/docs/markdown/interfaces/IAddressTypesIO.md +48 -0
  671. package/docs/markdown/interfaces/IBoostedTransaction.md +4 -4
  672. package/docs/markdown/interfaces/IBtInfo.md +102 -0
  673. package/docs/markdown/interfaces/ICanBoostResponse.md +41 -0
  674. package/docs/markdown/interfaces/ICoinSelectResponse.md +41 -0
  675. package/docs/markdown/interfaces/ICreateTransaction.md +13 -2
  676. package/docs/markdown/interfaces/ICustomGetAddress.md +3 -3
  677. package/docs/markdown/interfaces/ICustomGetScriptHash.md +2 -2
  678. package/docs/markdown/interfaces/IElectrumGetAddressBalanceRes.md +3 -3
  679. package/docs/markdown/interfaces/IFormattedPeerData.md +5 -5
  680. package/docs/markdown/interfaces/IFormattedTransaction.md +31 -20
  681. package/docs/markdown/interfaces/IGenerateAddresses.md +7 -7
  682. package/docs/markdown/interfaces/IGenerateAddressesResponse.md +2 -2
  683. package/docs/markdown/interfaces/IGetAddress.md +3 -3
  684. package/docs/markdown/interfaces/IGetAddressBalanceRes.md +2 -2
  685. package/docs/markdown/interfaces/IGetAddressByPath.md +2 -2
  686. package/docs/markdown/interfaces/IGetAddressHistoryResponse.md +7 -7
  687. package/docs/markdown/interfaces/IGetAddressResponse.md +3 -3
  688. package/docs/markdown/interfaces/IGetAddressScriptHashBalances.md +5 -5
  689. package/docs/markdown/interfaces/IGetAddressScriptHashesHistoryResponse.md +5 -5
  690. package/docs/markdown/interfaces/IGetAddressTxResponse.md +5 -5
  691. package/docs/markdown/interfaces/IGetAddressesFromKeyPair.md +2 -2
  692. package/docs/markdown/interfaces/IGetAddressesFromPrivateKey.md +2 -2
  693. package/docs/markdown/interfaces/IGetDerivationPath.md +6 -6
  694. package/docs/markdown/interfaces/IGetFeeEstimatesResponse.md +4 -4
  695. package/docs/markdown/interfaces/IGetHeaderResponse.md +5 -5
  696. package/docs/markdown/interfaces/IGetNextAvailableAddressResponse.md +4 -4
  697. package/docs/markdown/interfaces/IGetTransactions.md +5 -5
  698. package/docs/markdown/interfaces/IGetTransactionsFromInputs.md +5 -5
  699. package/docs/markdown/interfaces/IGetUtxosResponse.md +2 -2
  700. package/docs/markdown/interfaces/IHeader.md +3 -3
  701. package/docs/markdown/interfaces/IIndexes.md +4 -4
  702. package/docs/markdown/interfaces/IKeyDerivationPath.md +5 -5
  703. package/docs/markdown/interfaces/IKeyDerivationPathData.md +2 -2
  704. package/docs/markdown/interfaces/INewBlock.md +2 -2
  705. package/docs/markdown/interfaces/IOnchainFees.md +5 -5
  706. package/docs/markdown/interfaces/IOutput.md +3 -3
  707. package/docs/markdown/interfaces/IPeerData.md +3 -3
  708. package/docs/markdown/interfaces/IPrivateKeyInfo.md +4 -4
  709. package/docs/markdown/interfaces/IRbfData.md +17 -6
  710. package/docs/markdown/interfaces/ISend.md +2 -2
  711. package/docs/markdown/interfaces/ISendTransaction.md +16 -16
  712. package/docs/markdown/interfaces/ISendTx.md +3 -3
  713. package/docs/markdown/interfaces/ISetupTransaction.md +5 -5
  714. package/docs/markdown/interfaces/ISubscribeToAddress.md +4 -4
  715. package/docs/markdown/interfaces/ISubscribeToHeader.md +4 -4
  716. package/docs/markdown/interfaces/ISweepPrivateKey.md +5 -5
  717. package/docs/markdown/interfaces/ISweepPrivateKeyRes.md +3 -3
  718. package/docs/markdown/interfaces/ITargets.md +4 -4
  719. package/docs/markdown/interfaces/ITransaction.md +6 -6
  720. package/docs/markdown/interfaces/ITxHash.md +1 -1
  721. package/docs/markdown/interfaces/ITxHashes.md +3 -3
  722. package/docs/markdown/interfaces/IUtxo.md +10 -10
  723. package/docs/markdown/interfaces/IVin.md +5 -5
  724. package/docs/markdown/interfaces/IVout.md +3 -3
  725. package/docs/markdown/interfaces/IWallet.md +35 -24
  726. package/docs/markdown/interfaces/IWalletData.md +18 -18
  727. package/package.json +57 -10
  728. package/.eslintignore +0 -4
  729. package/.eslintrc +0 -40
  730. package/.github/workflows/lint-check.yml +0 -28
  731. package/.github/workflows/tests.yml +0 -43
  732. package/.github/workflows/type-check.yml +0 -28
  733. package/.prettierrc +0 -9
  734. package/dist/index.d.ts +0 -1188
  735. package/docker/docker-compose.yml +0 -77
  736. package/docker/electrs.toml +0 -1
  737. package/example/helpers.ts +0 -83
  738. package/example/index.ts +0 -89
  739. package/src/electrum/constants.ts +0 -2
  740. package/src/electrum/index.ts +0 -1019
  741. package/src/index.ts +0 -6
  742. package/src/shapes/electrum.ts +0 -13
  743. package/src/shapes/index.ts +0 -2
  744. package/src/shapes/wallet.ts +0 -144
  745. package/src/transaction/index.ts +0 -1563
  746. package/src/types/electrum.ts +0 -211
  747. package/src/types/index.ts +0 -3
  748. package/src/types/transaction.ts +0 -98
  749. package/src/types/wallet.ts +0 -622
  750. package/src/utils/conversion.ts +0 -23
  751. package/src/utils/derivation-path.ts +0 -173
  752. package/src/utils/electrum.ts +0 -233
  753. package/src/utils/helpers.ts +0 -347
  754. package/src/utils/index.ts +0 -6
  755. package/src/utils/result.ts +0 -79
  756. package/src/utils/transaction.ts +0 -440
  757. package/src/utils/wallet.ts +0 -477
  758. package/src/wallet/constants.ts +0 -28
  759. package/src/wallet/index.ts +0 -4055
  760. package/tests/boost.test.ts +0 -257
  761. package/tests/constants.ts +0 -13
  762. package/tests/derivation.test.ts +0 -132
  763. package/tests/electrum.test.ts +0 -87
  764. package/tests/expected-results.ts +0 -252
  765. package/tests/receive.test.ts +0 -216
  766. package/tests/storage.test.ts +0 -182
  767. package/tests/transaction.test.ts +0 -438
  768. package/tests/utils.ts +0 -142
  769. package/tests/wallet.test.ts +0 -388
  770. package/tsconfig.json +0 -32
  771. package/typedoc.json +0 -5
package/README.md CHANGED
@@ -1,220 +1,557 @@
1
1
  # Beignet
2
2
 
3
- :warning: This is pre-alpha software and not suitable for production apps yet.
3
+ A self-custodial Bitcoin wallet library for JavaScript/TypeScript, with a full Lightning Network implementation.
4
4
 
5
- ## Description
5
+ ## Overview
6
6
 
7
- An instant, self-custodial Bitcoin wallet for JS devs.
7
+ Beignet provides two layers of Bitcoin wallet functionality:
8
8
 
9
- This Typescript library offers JS developers a way to incorporate an on-chain, self-custodial Bitcoin wallet into their projects.
9
+ - **On-chain wallet** — HD key management, address generation, UTXO tracking, transaction building, and Electrum server connectivity.
10
+ - **Lightning Network** — A complete BOLT-compliant Lightning implementation in TypeScript, supporting channel management, onion-routed payments, BOLT 11 invoices, gossip-based routing, and real TCP transport. Tested against LND, CLN, and Eclair on regtest.
10
11
 
11
12
  ## Table of Contents
12
13
 
13
14
  1. [Getting Started](#getting-started)
14
- 2. [Running Tests & Examples](#running-tests--examples)
15
- - [Clone the Repository](#clone-the-repository)
16
- - [Install Dependencies & Build](#install-dependencies--build)
17
- - [Run Tests](#run-tests)
18
- - [Run Example Project](#run-example-project)
19
- 3. [Implementation](#implementation)
20
- 4. [Advanced Usage](#advanced-usage)
21
- 5. [Documentation](#documentation)
22
- 6. [Support](#support)
15
+ 2. [On-Chain Wallet](#on-chain-wallet)
16
+ 3. [Lightning Network](#lightning-network)
17
+ - [Lightning Quick Start (BeignetNode)](#lightning-quick-start-beignetnode)
18
+ - [Decision-Support APIs](#decision-support-apis)
19
+ - [HTTP Daemon](#http-daemon)
20
+ - [Advanced API (LightningNode)](#advanced-api-lightningnode)
21
+ - [Architecture](#architecture)
22
+ - [BOLT Coverage](#bolt-coverage)
23
+ - [Module Reference](#module-reference)
24
+ 4. [Running Tests](#running-tests)
25
+ 5. [Interop Testing](#interop-testing)
26
+ 6. [React Native](#react-native)
27
+ 7. [Documentation](#documentation)
28
+ 8. [Support](#support)
23
29
 
24
30
  ## Getting Started
25
31
 
26
32
  ```bash
33
+ # Using npm
34
+ npm install beignet
35
+
27
36
  # Using Yarn
28
37
  yarn add beignet
29
-
30
- # Or, using NPM
31
- npm i -S beignet
32
38
  ```
33
39
 
34
- ## Running Tests & Examples
40
+ > Requires **Node.js 18+**
35
41
 
36
- ### Clone the Repository
42
+ ### Build from source
37
43
 
38
44
  ```bash
39
- git clone git@github.com:synonymdev/beignet.git && cd beignet
45
+ git clone git@github.com:coreyphillips/beignet.git && cd beignet
46
+ npm install && npm run build
40
47
  ```
41
48
 
42
- ### Install Dependencies & Build
49
+ ### Run the examples
50
+
51
+ Both examples launch an interactive REPL with a live wallet/node instance:
43
52
 
44
53
  ```bash
45
- npm i && npm run build
46
- ```
54
+ # On-chain wallet REPL
55
+ npm run example
47
56
 
48
- ### Run tests:
57
+ # Lightning node REPL (recommended — uses BeignetNode)
58
+ npm run example:lightning
49
59
 
50
- ```bash
51
- npm run test
52
- ```
60
+ # Low-level Lightning node REPL (uses LightningNode directly)
61
+ npm run example:lightning -- --low-level
53
62
 
54
- ### Run example project:
55
- ```bash
56
- npm run example
63
+ # Lightning node with a specific mnemonic and alias
64
+ npm run example:lightning -- abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about --alias mynode
65
+
66
+ # Two-node payment flow demo (shows complete lifecycle)
67
+ npm run example:lightning -- --payment-flow
57
68
  ```
58
69
 
59
- ## Implementation
70
+ ## On-Chain Wallet
71
+
60
72
  ```javascript
61
73
  import { Wallet, generateMnemonic } from 'beignet';
62
74
 
63
- // Generate a mnemonic phrase
64
75
  const mnemonic = generateMnemonic();
65
76
 
66
- // Create a wallet instance
67
- const createWalletRes = await Wallet.create({ mnemonic });
68
- if (createWalletRes.isErr()) return;
69
- const wallet = createWalletRes.value;
77
+ const createRes = await Wallet.create({ mnemonic });
78
+ if (createRes.isErr()) return;
79
+ const wallet = createRes.value;
70
80
 
71
- // View wallet data (addresses, indexes, utxos, transactions, etc.)
72
- const walletData = wallet.data;
73
-
74
81
  // Get receiving address
75
82
  const address = await wallet.getAddress();
76
83
 
77
- // Get address balance
78
- const addressBalanceRes = await wallet.getAddressBalance(address);
79
- if (addressBalance.isErr()) return;
80
- const addressBalance = addressBalanceRes.value;
81
-
82
84
  // Get wallet balance
83
- const walletBalance = wallet.getBalance();
84
-
85
- // Refresh Wallet
86
- const walletRefresh = await wallet.refreshWallet();
87
-
88
- // Get fee information to perform a transaction.
89
- const feeInfo = wallet.getFeeInfo();
85
+ const balance = wallet.getBalance();
90
86
 
91
87
  // Send sats
92
- const sendRes = await wallet.send({ address: 'address to send sats to', amount: 1000, satPerByte: 2 });
88
+ const sendRes = await wallet.send({
89
+ address: 'bc1q...',
90
+ amount: 50000,
91
+ satPerByte: 2,
92
+ });
93
93
 
94
- // Send all sats to an address
95
- const sendMaxRes = await wallet.sendMax({ address: 'address to send sats to', satPerByte: 2 });
94
+ // Refresh wallet state from Electrum
95
+ await wallet.refreshWallet();
96
96
  ```
97
97
 
98
- ## Advanced Usage
98
+ ### Advanced On-Chain Usage
99
99
 
100
100
  ```typescript
101
101
  import { Wallet, generateMnemonic } from 'beignet';
102
- import net from 'net'
103
- import tls from 'tls'
104
- import { TStorage } from './wallet';
105
- import { ECoinSelectPreference } from "./transaction";
102
+ import net from 'net';
103
+ import tls from 'tls';
106
104
 
107
- // Generate a mnemonic phrase
108
- const mnemonic = generateMnemonic();
105
+ const wallet = await Wallet.create({
106
+ mnemonic: generateMnemonic(),
107
+ passphrase: 'optional-passphrase',
108
+ electrumOptions: {
109
+ servers: { host: '127.0.0.1', ssl: 50002, tcp: 50001, protocol: 'ssl' },
110
+ net,
111
+ tls,
112
+ },
113
+ network: 'mainnet',
114
+ addressType: 'p2wpkh',
115
+ coinSelectPreference: 'consolidate',
116
+ });
109
117
 
110
- // Add a bip39 passphrase
111
- const passphrase = 'passphrase';
118
+ // Send to multiple outputs
119
+ await wallet.value.sendMany({
120
+ txs: [
121
+ { address: 'addr1', amount: 1000 },
122
+ { address: 'addr2', amount: 2000 },
123
+ ],
124
+ });
112
125
 
113
- // Connect to custom electrum server
114
- const servers: TServer = {
115
- host: '35.233.47.252',
116
- ssl: 18484,
117
- tcp: 18483,
118
- protocol: EProtocol.ssl,
119
- };
126
+ // Sweep a private key
127
+ await wallet.value.sweepPrivateKey({
128
+ privateKey: 'L...',
129
+ toAddress: 'bc1q...',
130
+ satsPerByte: 5,
131
+ });
132
+
133
+ // List UTXOs
134
+ const utxos = wallet.value.listUtxos();
120
135
 
121
- // Use a specific network (Defaults to mainnet)
122
- const network = ENetworks.mainnet;
136
+ // Get transaction history
137
+ const history = await wallet.value.getAddressHistory('bc1q...');
138
+ ```
123
139
 
124
- // Use a specific address type. (Defaults to EAddressType.p2wpkh)
125
- const addressType = EAddressType.p2tr;
140
+ ## Lightning Network
126
141
 
127
- // Monitor certain address types. (Defaults to Object.values(EAddressType))
128
- const addressTypesToMonitor = [EAddressType.p2tr, EAddressType.p2wpkh];
142
+ ### Lightning Quick Start (BeignetNode)
129
143
 
130
- // Subscribe to server messages (TOnMessage)
131
- const onMessage: TOnMessage = (id, data) => {
132
- console.log(id);
133
- console.dir(data, { depth: null });
134
- }
144
+ `BeignetNode` (from `beignet/cli`) is the recommended API — it wraps the protocol layer with a simpler, JSON-friendly interface: satoshi-denominated amounts, string channel IDs, and structured error codes.
135
145
 
136
- // Disable startup messages. Messages resume once startup is complete. (Defaults to false)
137
- const disableMessagesOnCreate = true;
146
+ For detailed deployment guidance, see [AI Agent Deployment Guide](docs/AI_AGENT_GUIDE.md).
138
147
 
139
- // Persist sessions by getting and setting data from storage
140
- const storage: TStorage = {
141
- async getData<K extends keyof IWalletData>(
142
- key: string
143
- ): Promise<Result<IWalletData[K]>> {
144
- // Add your logic here
145
- },
146
- async setData<K extends keyof IWalletData>(
147
- key: string,
148
- value: IWalletData[K]
149
- ): Promise<Result<boolean>> {
150
- // Add your logic here
148
+ ```typescript
149
+ import { BeignetNode, isRetryableError } from 'beignet/cli';
150
+
151
+ // Create a node (auto-creates wallet, storage, funding provider)
152
+ const node = await BeignetNode.create({
153
+ mnemonic: 'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about',
154
+ network: 'regtest',
155
+ electrumHost: '127.0.0.1',
156
+ electrumPort: 60001,
157
+ });
158
+
159
+ // Get node info and health
160
+ console.log(node.getInfo()); // { nodeId, network, alias, ... }
161
+ console.log(node.getHealth()); // { status: 'ready', peers, channels, ... }
162
+ console.log(node.isReady()); // true when node has active channels
163
+
164
+ // Create an invoice
165
+ const inv = node.createInvoice(1000, 'coffee');
166
+ console.log(inv.bolt11);
167
+
168
+ // Pay an invoice with automatic retry logic
169
+ try {
170
+ const payment = await node.payInvoice('lnbcrt10n1...');
171
+ console.log(payment.status); // 'COMPLETED'
172
+ } catch (err) {
173
+ if (isRetryableError(err)) {
174
+ // Transient failure — safe to retry (no route, timeout, etc.)
175
+ } else {
176
+ // Permanent failure — do not retry (invalid invoice, expired, etc.)
151
177
  }
152
- };
178
+ }
179
+
180
+ // List channels, payments, invoices
181
+ console.log(node.listChannels());
182
+ console.log(node.listPayments());
183
+ console.log(node.listInvoices());
184
+
185
+ // Clean shutdown
186
+ await node.destroy();
187
+ ```
188
+
189
+ ### Decision-Support APIs
190
+
191
+ Beignet includes built-in advisors that differentiate it from other Lightning libraries:
192
+
193
+ ```typescript
194
+ // Channel balance analysis with actionable recommendations
195
+ const liquidity = node.getLiquiditySnapshot();
196
+ console.log('Outbound:', liquidity.outboundLiquidityPct + '%');
197
+ for (const rec of liquidity.recommendations) {
198
+ console.log(`[${rec.priority}] ${rec.type}: ${rec.reason}`);
199
+ }
200
+
201
+ // Graph-based peer suggestions for channel opens
202
+ const suggestions = node.getChannelSuggestions(3);
203
+
204
+ // On-chain fee trend analysis (OPEN_NOW / WAIT / NEUTRAL)
205
+ const fees = node.getFeeSnapshot();
206
+
207
+ // Payment success probability + estimated fee before sending
208
+ const estimate = node.estimatePayment(bolt11);
209
+
210
+ // 11-check mainnet readiness report with weighted score
211
+ const readiness = node.getMainnetReadiness();
212
+ console.log('Score:', readiness.score + '/100', 'Ready:', readiness.ready);
213
+ ```
214
+
215
+ ### HTTP Daemon
216
+
217
+ BeignetNode can also run as an HTTP/SSE daemon for language-agnostic integrations:
218
+
219
+ ```bash
220
+ # Start the daemon (generates OpenAPI spec at /openapi.json)
221
+ npx beignet --mnemonic "abandon ..." --network regtest --electrum-host 127.0.0.1 --electrum-port 60001
222
+
223
+ # Create an invoice
224
+ curl -X POST http://localhost:2112/invoice/create -H 'Authorization: Bearer <token>' \
225
+ -H 'Content-Type: application/json' -d '{"amountSats": 1000, "description": "coffee"}'
226
+
227
+ # Pay an invoice
228
+ curl -X POST http://localhost:2112/invoice/pay -H 'Authorization: Bearer <token>' \
229
+ -H 'Content-Type: application/json' -d '{"bolt11": "lnbcrt10n1..."}'
230
+
231
+ # Stream events (payments, channel state changes)
232
+ curl -N http://localhost:2112/events -H 'Authorization: Bearer <token>'
233
+
234
+ # Simple readiness check (auth-exempt, for load balancers)
235
+ curl http://localhost:2112/ready
236
+ ```
237
+
238
+ #### Response Format
153
239
 
154
- // Set the auto coin selection preference. (Defaults to ECoinSelectPreference.consolidate)
155
- const coinSelectPreference = ECoinSelectPreference.small;
240
+ All responses use: `{ "ok": true, "result": {...} }` or `{ "ok": false, "error": { "code": "...", "message": "..." } }`.
241
+ Full spec: `GET /openapi.json` (no auth required).
156
242
 
157
- // Create a wallet instance
158
- const createWalletRes = await Wallet.create({
243
+ ### Advanced API (LightningNode)
244
+
245
+ Most users should use `BeignetNode` above. Use `LightningNode` only if you need direct access to the protocol layer (bigint amounts, Buffer IDs, raw BOLT messages).
246
+
247
+ ```typescript
248
+ import { Wallet, generateMnemonic } from 'beignet';
249
+ import { LightningNode, WalletFundingProvider, Network } from 'beignet/lightning';
250
+ import net from 'net';
251
+ import tls from 'tls';
252
+
253
+ const mnemonic = generateMnemonic();
254
+
255
+ // 1. Create an on-chain wallet (same mnemonic funds both layers)
256
+ const wallet = (await Wallet.create({
159
257
  mnemonic,
160
- passphrase,
161
- electrumOptions: {
162
- servers,
163
- net,
164
- tls
165
- },
166
- network,
167
- onMessage,
168
- storage,
169
- addressType,
170
- addressTypesToMonitor,
171
- disableMessagesOnCreate,
172
- coinSelectPreference
258
+ electrumOptions: { net, tls },
259
+ })).value;
260
+
261
+ // 2. Create a Lightning node with auto-funding from the wallet
262
+ const fundingProvider = new WalletFundingProvider(wallet);
263
+ const node = LightningNode.fromMnemonic(mnemonic, {
264
+ network: Network.REGTEST,
265
+ enableNetworking: true,
266
+ fundingProvider,
173
267
  });
174
- if (createWalletRes.isErr()) return;
175
- const wallet = createWalletRes.value;
176
-
177
- // List UTXO's
178
- const utxos = wallet.listUtxos();
179
-
180
- // Send sats to multiple outputs
181
- const txs = [
182
- { address: 'address1', amount: 1000 },
183
- { address: 'address2', amount: 2000 },
184
- { address: 'address3', amount: 3000 },
185
- ];
186
- const sendManyRes = await wallet.sendMany({ txs });
187
-
188
- // Sweep from a private key
189
- const sweepPrivateKeyRes = await wallet.sweepPrivateKey({
190
- privateKey: 'privateKey',
191
- toAddress: 'toAddress',
192
- satsPerByte: 5,
193
- broadcast: false
268
+
269
+ // 3. Connect to a peer and open a channel — fully automatic
270
+ await node.connectPeer('03...pubkey', '127.0.0.1', 9735);
271
+ node.openChannel('03...pubkey', 100_000n);
272
+
273
+ // 4. Create a BOLT 11 invoice
274
+ const invoice = node.createInvoice({
275
+ amountMsat: 50_000n,
276
+ description: 'Payment for coffee',
194
277
  });
195
278
 
196
- // Get tx history for a given address. { tx_hash: string; height: number; }[]
197
- const history = await wallet.getAddressHistory('address');
279
+ // 5. Pay a BOLT 11 invoice
280
+ node.sendPayment(invoiceString);
198
281
 
199
- // Get transaction details for a given transaction id. TTxDetails
200
- const txDetails = await wallet.getTransactionDetails('txid');
282
+ // 6. Listen for events
283
+ node.on('channel:ready', (channelId) => {
284
+ console.log('Channel ready:', channelId.toString('hex'));
285
+ });
286
+ node.on('payment:received', (payment) => {
287
+ console.log('Received:', payment.amountMsat, 'msat');
288
+ });
289
+ node.on('node:error', (err) => {
290
+ console.error(`[${err.code}]`, err.message);
291
+ });
292
+ ```
293
+
294
+ **Without a wallet** — you can skip `fundingProvider` and handle funding manually:
295
+
296
+ ```typescript
297
+ const node = LightningNode.fromMnemonic(mnemonic, {
298
+ network: Network.REGTEST,
299
+ enableNetworking: true,
300
+ });
301
+
302
+ const channel = node.openChannel('03...pubkey', 100_000n);
303
+ // Build your own funding tx, then:
304
+ const channelId = node.createFunding(channel, fundingTxid, outputIndex, signature);
305
+ ```
306
+
307
+ ### Architecture
308
+
309
+ Beignet's Lightning implementation follows a layered, transport-agnostic design:
310
+
311
+ ```
312
+ LightningNode ← High-level API (EventEmitter)
313
+ ├── ChannelManager ← Multiplexes messages to Channel instances
314
+ │ └── Channel ← BOLT 2 state machine (returns ChannelAction[])
315
+ ├── PeerManager ← TCP connections + Noise_XK encrypted transport
316
+ │ └── Peer ← Per-connection BOLT 8 handshake + message framing
317
+ ├── NetworkGraph ← BOLT 7 gossip topology + Dijkstra pathfinding
318
+ ├── InvoiceManager ← BOLT 11 encode/decode/sign
319
+ ├── ChainMonitor ← BOLT 5 force-close detection + sweep
320
+ └── FundingProvider? ← Auto-builds + broadcasts funding txs (via Wallet)
201
321
  ```
202
322
 
323
+ **Key design principle:** The `Channel` class is fully transport-agnostic. Every method returns `ChannelAction[]` arrays (send message, broadcast tx, watch output, etc.) that the `ChannelManager` maps to real transport or chain operations. This makes the state machine fully testable without network I/O.
324
+
325
+ ### BOLT Coverage
326
+
327
+ | BOLT | Specification | Status |
328
+ |------|--------------|--------|
329
+ | 1 | Base Protocol | Peer messaging, init, error, ping/pong, feature negotiation |
330
+ | 2 | Channel Management | Full state machine: open, fund, normal operation, shutdown, close, reestablish; v2 dual-funded opens (interactive-tx), splicing, quiescence |
331
+ | 3 | Transactions | Commitment txs, HTLC scripts, funding scripts, anchor outputs, fee calculation; simple taproot channels (MuSig2 funding, Schnorr HTLC sigs) |
332
+ | 4 | Onion Routing | Sphinx encryption, TLV hop payloads, payment_secret, failure codes, route blinding, onion messages |
333
+ | 5 | On-Chain | Force-close detection, HTLC sweep, output resolution, chain monitoring, wallet-funded anchor fee bumping (commitment CPFP + zero-fee HTLC fee-attach) |
334
+ | 7 | Gossip | Channel/node announcements, network graph, Dijkstra routing, gossip sync |
335
+ | 8 | Transport | Noise_XK handshake, encrypted transport, key rotation |
336
+ | 9 | Features | DATA_LOSS_PROTECT, STATIC_REMOTE_KEY, PAYMENT_SECRET, TLV_ONION, BASIC_MPP, CHANNEL_TYPE, GOSSIP_QUERIES, ANCHORS_ZERO_FEE_HTLC_TX (default), ROUTE_BLINDING, ONION_MESSAGES, QUIESCE, SCID_ALIAS, ZERO_CONF, KEYSEND, OPTION_TAPROOT, OPTION_WILL_FUND |
337
+ | 11 | Invoices | Encode, decode, sign, verify, amount formatting, hold invoices |
338
+ | 12 | Offers | Offer encode/decode, invoice_request/invoice exchange over onion messages, receive-side settlement, async payment offers |
339
+ | bLIP-51 | Liquidity Ads | lease_rates/request_funds/will_fund negotiation, lease fee accounting, CLTV-locked lessor to_local, advisor lease quoting |
340
+
341
+ ### Module Reference
342
+
343
+ The Lightning implementation is organized into 21 modules under `src/lightning/`:
344
+
345
+ | Module | Description |
346
+ |--------|-------------|
347
+ | `crypto/` | ChaCha20-Poly1305 AEAD, ECDH, HKDF key derivation, MuSig2 (BIP327) for taproot channels |
348
+ | `message/` | Wire protocol encode/decode for all channel, gossip, and control messages |
349
+ | `features/` | Feature flag bitmap management (BOLT 9) |
350
+ | `transport/` | Noise_XK handshake, encrypted transport cipher, TCP peer connections, PeerManager |
351
+ | `keys/` | HD key derivation, per-commitment secrets (shachain), transaction signing, wallet key derivation |
352
+ | `script/` | Funding (2-of-2 multisig), commitment tx outputs, HTLC scripts, revocation, anchor outputs, taproot commitment/HTLC scripts |
353
+ | `channel/` | Channel state machine, ChannelManager, commitment builder, channel actions, validation, liquidity ads |
354
+ | `chain/` | ChainMonitor, ChainWatcher, output resolver, closing tx, sweep tx, Electrum backend |
355
+ | `invoice/` | BOLT 11 invoice encoding/decoding, bech32 word conversion, signature verification |
356
+ | `gossip/` | NetworkGraph, Dijkstra pathfinding, gossip sync state machine, SCID encoding |
357
+ | `onion/` | Sphinx crypto, onion packet construction/processing, hop payloads, failure handling, blinded paths |
358
+ | `onion-message/` | BOLT 4 onion message construction/processing (carries BOLT 12 and async-payment messages) |
359
+ | `offer/` | BOLT 12 offers: encode/decode, OfferManager invoice_request/invoice flows |
360
+ | `async-payments/` | Hold invoices and AsyncPaymentManager (LSP held-forward, release_held_htlc, wake) |
361
+ | `interactive-tx/` | Interactive transaction construction for v2 dual-funded opens and splicing |
362
+ | `node/` | LightningNode orchestrator — the main entry point for the Lightning API |
363
+ | `wallet/` | WalletFundingProvider — adapts the on-chain Wallet for auto-funded channel opens |
364
+ | `bootstrap/` | DNS seed resolution for discovering initial Lightning peers |
365
+ | `advisor/` | Liquidity, fee, and channel suggestion advisors for AI agents |
366
+ | `storage/` | SQLite persistence backend, channel state serialization/deserialization |
367
+ | `validation/` | Input validation utilities shared across modules |
368
+
369
+ The `BeignetNode` wrapper (`src/cli/beignet-node.ts`) provides a simplified, JSON-friendly API on top of `LightningNode` for AI agents and programmatic use.
370
+
371
+ ### LightningNode API
372
+
373
+ `LightningNode` is an `EventEmitter` that provides the high-level API:
374
+
375
+ **Peer Management:**
376
+ - `connectPeer(pubkey, host, port)` — Establish encrypted connection
377
+ - `disconnectPeer(pubkey)` — Disconnect from peer
378
+ - `listPeers()` — List connected peers
379
+ - `getNodeId()` — Get this node's public key
380
+
381
+ **Channel Operations:**
382
+ - `openChannel(peerPubkey, fundingSatoshis, pushMsat?)` — Open a channel (auto-funds when `fundingProvider` is set)
383
+ - `createFunding(channel, txid, outputIndex, signature)` — Manual funding (when no `fundingProvider`)
384
+ - `handleFundingConfirmed(channelId)` — Notify funding tx confirmed
385
+ - `closeChannel(channelId, scriptPubkey)` — Cooperative close
386
+ - `forceCloseChannel(channelId, destinationScript)` — Force close (unilateral)
387
+ - `listChannels()` — List all channels
388
+ - `getChannel(channelId)` — Get channel details
389
+
390
+ **Payments:**
391
+ - `createInvoice(options)` — Generate a BOLT 11 invoice
392
+ - `sendPayment(invoiceString)` — Send a payment
393
+ - `sendPaymentToRoute(route, paymentHash, ...)` — Send via explicit route
394
+
395
+ **Chain Events:**
396
+ - `handleNewBlock(height)` — Process new block
397
+ - `handleOutputSpent(txid, index, spendingTx, height)` — Track spent outputs
398
+
399
+ **Events:**
400
+ - `payment:received` — Incoming payment fulfilled
401
+ - `payment:sent` — Outgoing payment succeeded
402
+ - `payment:failed` — Outgoing payment failed
403
+ - `channel:ready` — Channel entered NORMAL state
404
+ - `channel:closed` — Channel closed
405
+ - `peer:connect` / `peer:disconnect` — Peer connection changes
406
+ - `node:error` — Structured error (code, message, channelId, timestamp)
407
+
408
+ ## Running Tests
409
+
410
+ ```bash
411
+ # Run lightning unit tests (2740+ tests, no infrastructure needed)
412
+ npm run test:lightning
413
+
414
+ # Run CLI unit tests (720 CLI tests, no infrastructure needed)
415
+ npm run test:cli
416
+
417
+ # Run daemon/Electrum integration tests (requires Electrum server)
418
+ npm run test:integration
419
+
420
+ # Run interop tests against LND/CLN/Eclair (requires Docker)
421
+ npm run test:interop
422
+
423
+ # Run everything (requires Docker + Electrum)
424
+ npm run test:all
425
+ ```
426
+
427
+ ### Test Coverage
428
+
429
+ The Lightning implementation has **2740+ lightning unit tests + 129 interop tests + 720 CLI tests** across many phases:
430
+
431
+ | Phase | Tests | Coverage |
432
+ |-------|-------|---------|
433
+ | Crypto & Messages | 115 | ChaCha20-Poly1305, HKDF, ECDH, codec, TLV, init, error, feature flags |
434
+ | Transport (BOLT 8) | — | Noise_XK handshake, cipher, ping/pong, peer connections, PeerManager |
435
+ | Keys & Scripts (BOLT 3) | — | Key derivation, shachain, signer, funding, commitment, HTLC, revocation |
436
+ | Channel State Machine (BOLT 2) | 161 | Message encode/decode, channel types, validation, Channel, commitment builder, ChannelManager |
437
+ | Chain Monitor (BOLT 5) | 67 | Closing tx, sweep tx, output resolver, chain monitor, force close |
438
+ | Invoices (BOLT 11) | 98 | Types, words, amount, signing, decode, encode |
439
+ | Gossip & Routing (BOLT 7) | 104 | SCID, messages, validation, network graph, pathfinding |
440
+ | Onion & Payments (BOLT 4) | 83 | Sphinx crypto, hop payloads, onion construction/processing, failure handling |
441
+ | Node API | 50 | LightningNode orchestrator, invoice management, payment send/receive, HTLC forwarding |
442
+ | PeerManager Integration | 18 | PeerManager wiring, peer management, event forwarding |
443
+ | Production Hardening | — | Error visibility, input validation, resource management, BOLT 1 error propagation |
444
+ | **Interop (LND/CLN/Eclair)** | **129** | **Multi-implementation interop: TCP handshake, channel lifecycle, bidirectional payments, anchor channels, anchor force-close with wallet-funded CPFP + HTLC-timeout fee-attach, crash recovery against LND v0.20.0, CLN, and Eclair** |
445
+
446
+ ## Interop Testing
447
+
448
+ The interop test suite validates beignet against real Lightning implementations on Bitcoin regtest.
449
+
450
+ ### Prerequisites
451
+
452
+ - Docker and Docker Compose
453
+ - Node.js 18+
454
+
455
+ ### Setup
456
+
457
+ ```bash
458
+ # Start bitcoind + LND + CLN + Eclair containers
459
+ docker compose -f docker/docker-compose.yml up -d
460
+
461
+ # Wait for nodes to sync (~30 seconds)
462
+
463
+ # Run interop tests
464
+ npm run test:interop
465
+ ```
466
+
467
+ ### What's Tested
468
+
469
+ #### LND (43 tests)
470
+
471
+ | Tier | Tests | Validates |
472
+ |------|-------|-----------|
473
+ | **1: TCP & Init** | 5 | BOLT 8 Noise_XK handshake, BOLT 1 init exchange, feature negotiation, disconnect/reconnect, ping/pong survival |
474
+ | **2: Channel Open** | 3 | LND opens channel to beignet, balance verification, error-free lifecycle |
475
+ | **3: LND pays beignet** | 3 | Receive payment from LND, payment_secret validation, multiple sequential payments |
476
+ | **4: Beignet pays LND** | 3 | Pay LND invoice, outbound payment_secret, graceful failure handling |
477
+ | **5-9: Advanced** | 11 | Channel close, reestablish, gossip sync, MPP payments, SCID aliases |
478
+ | **10: Inbound connections** | 4 | LND connects to beignet listener, channel open from inbound peer |
479
+ | **11-13: Anchor & Recovery** | 14 | Anchor channels, beignet-funded opens, crash recovery |
480
+
481
+ #### CLN (42 tests)
482
+
483
+ | Tier | Tests | Validates |
484
+ |------|-------|-----------|
485
+ | **1: TCP & Init** | 5 | BOLT 8 handshake, init exchange, feature negotiation |
486
+ | **2-9: Channel & Payments** | 23 | Channel lifecycle, bidirectional payments, close, reestablish, gossip, MPP, SCID aliases |
487
+ | **10: Inbound** | 4 | Inbound connections from CLN |
488
+ | **12-14: Anchor & Recovery** | 10 | Anchor channels, beignet-funded opens, crash recovery |
489
+
490
+ #### Eclair (42 tests)
491
+
492
+ | Tier | Tests | Validates |
493
+ |------|-------|-----------|
494
+ | **1: TCP & Init** | 5 | BOLT 8 handshake, init exchange, feature negotiation |
495
+ | **2-9: Channel & Payments** | 23 | Channel lifecycle, bidirectional payments, close, reestablish, gossip, MPP |
496
+ | **10: Inbound** | 4 | Inbound connections from Eclair |
497
+ | **12-14: Anchor & Recovery** | 10 | Anchor channels, beignet-funded opens, crash recovery |
498
+
499
+ Interop tests are excluded from `npm run test:lightning` (which runs only unit tests). Use `npm run test:interop` to run them, or `npm run test:all` to run everything.
500
+
501
+ ### Docker Compose Services
502
+
503
+ The `docker/docker-compose.yml` includes:
504
+ - **bitcoind** — Bitcoin Core regtest node (RPC port 43782, ZMQ on 28334/28335)
505
+ - **LND** — Lightning Network Daemon v0.20.0-beta (P2P port 9735, REST port 8081)
506
+ - **CLN** — Core Lightning (CLNRest API on port 3010)
507
+ - **Eclair** — ACINQ Eclair (HTTP API on port 8082)
508
+
509
+ ## Known Limitations
510
+
511
+ Beignet is under active development. The following features are missing or carry caveats:
512
+
513
+ | Feature | Status | Impact |
514
+ |---------|--------|--------|
515
+ | **Watchtowers** | Not implemented | If your node goes offline, a counterparty could theoretically broadcast a revoked state. Mitigate with frequent backups and auto-reconnect. |
516
+ | **LSP / LSPS protocols** | Not implemented | No automated inbound liquidity acquisition via LSPS0/1/2. Liquidity ads (bLIP-51) are supported for negotiated leases; otherwise open channels manually. |
517
+ | **Trampoline routing** | Not implemented | All route computation is local. Cannot delegate pathfinding to a trampoline node. |
518
+ | **BOLT 12 offers** | Newer | Offer creation/decoding, invoice_request/invoice over onion messages, and receive-side settlement are implemented, but the surface is newer and less battle-tested than BOLT 11. Prefer BOLT 11 invoices for production. |
519
+ | **Async payments** | Implemented (LSP-dependent) | Hold invoices plus AsyncPaymentManager let an offline receiver be paid, but the receiver's LSP must run the held-forward/wake flow. |
520
+ | **Simple taproot channels** | Experimental | Opens, payments both directions, force-close, and reestablish validated against LND v0.20 on regtest; the feature bit is still in staging upstream. Not recommended for mainnet balances yet. |
521
+ | **Splicing / dual funding** | Partial | Splice-out and splice-in validated live against CLN on mainnet; v2 dual-funded opens implemented. CLN-initiated splices, repeat splices, and multi-UTXO splice-ins are untested. |
522
+ | **Mainnet battle-testing** | Limited | Interop-tested against LND/CLN/Eclair on regtest. Exercise caution with large mainnet balances. |
523
+ | **Mobile background** | Limited | Works on React Native but lacks mobile-specific optimizations (background sync, push notifications). |
524
+
525
+ **Recommended safeguards for production use:**
526
+ - Set `maxPaymentSats` and `dailySpendLimitSats` to cap exposure
527
+ - Use `validatePayment()` before every send to catch problems early
528
+ - Enable `backupPath` for automated database backups
529
+ - Use `electrumServers` (plural) for connection redundancy
530
+ - Monitor `node:error` events and `/health` endpoint
531
+ - Start with small channel sizes and increase gradually
532
+
203
533
  ## React Native
204
534
 
205
- You can use `react-native-tcp-socket` as a drop in replacement for `net` & `tls` in a react-native environment. In `package.json`:
535
+ You can use `react-native-tcp-socket` as a drop-in replacement for `net` & `tls`:
206
536
 
207
537
  ```json
208
- "react-native": {
209
- "net": "react-native-tcp-socket",
210
- "tls": "react-native-tcp-socket"
538
+ {
539
+ "react-native": {
540
+ "net": "react-native-tcp-socket",
541
+ "tls": "react-native-tcp-socket"
542
+ }
211
543
  }
212
544
  ```
213
545
 
214
546
  ## Documentation
547
+
215
548
  - [HTML](docs/html/classes/Wallet.html)
216
549
  - [Markdown](docs/markdown/classes/Wallet.md)
217
550
 
218
551
  ## Support
219
552
 
220
553
  If you are experiencing any problems, please open an issue or reach out to us on [Telegram](https://t.me/bitkitchat).
554
+
555
+ ## License
556
+
557
+ MIT