@did-btcr2/method 0.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (310) hide show
  1. package/LICENSE +373 -0
  2. package/README.md +7 -0
  3. package/dist/browser.js +2364 -0
  4. package/dist/browser.js.map +7 -0
  5. package/dist/browser.mjs +2364 -0
  6. package/dist/browser.mjs.map +7 -0
  7. package/dist/cjs/bitcoin/constants.js +20 -0
  8. package/dist/cjs/bitcoin/constants.js.map +1 -0
  9. package/dist/cjs/bitcoin/errors.js +11 -0
  10. package/dist/cjs/bitcoin/errors.js.map +1 -0
  11. package/dist/cjs/bitcoin/index.js +95 -0
  12. package/dist/cjs/bitcoin/index.js.map +1 -0
  13. package/dist/cjs/bitcoin/interface.js +2 -0
  14. package/dist/cjs/bitcoin/interface.js.map +1 -0
  15. package/dist/cjs/bitcoin/network.js +17 -0
  16. package/dist/cjs/bitcoin/network.js.map +1 -0
  17. package/dist/cjs/bitcoin/rest-client.js +289 -0
  18. package/dist/cjs/bitcoin/rest-client.js.map +1 -0
  19. package/dist/cjs/bitcoin/rpc-client.js +722 -0
  20. package/dist/cjs/bitcoin/rpc-client.js.map +1 -0
  21. package/dist/cjs/bitcoin/taproot.js +219 -0
  22. package/dist/cjs/bitcoin/taproot.js.map +1 -0
  23. package/dist/cjs/btcr2/beacon/aggregation/coordinator.js +120 -0
  24. package/dist/cjs/btcr2/beacon/aggregation/coordinator.js.map +1 -0
  25. package/dist/cjs/btcr2/beacon/aggregation/messages/advert.js +24 -0
  26. package/dist/cjs/btcr2/beacon/aggregation/messages/advert.js.map +1 -0
  27. package/dist/cjs/btcr2/beacon/aggregation/messages/base.js +37 -0
  28. package/dist/cjs/btcr2/beacon/aggregation/messages/base.js.map +1 -0
  29. package/dist/cjs/btcr2/beacon/aggregation/messages/cohort-set.js +25 -0
  30. package/dist/cjs/btcr2/beacon/aggregation/messages/cohort-set.js.map +1 -0
  31. package/dist/cjs/btcr2/beacon/aggregation/messages/keygen.js +8 -0
  32. package/dist/cjs/btcr2/beacon/aggregation/messages/keygen.js.map +1 -0
  33. package/dist/cjs/btcr2/beacon/aggregation/messages/opt-in.js +23 -0
  34. package/dist/cjs/btcr2/beacon/aggregation/messages/opt-in.js.map +1 -0
  35. package/dist/cjs/btcr2/beacon/aggregation/messages/sign.js +7 -0
  36. package/dist/cjs/btcr2/beacon/aggregation/messages/sign.js.map +1 -0
  37. package/dist/cjs/btcr2/beacon/aggregation/models/cohort/index.js +92 -0
  38. package/dist/cjs/btcr2/beacon/aggregation/models/cohort/index.js.map +1 -0
  39. package/dist/cjs/btcr2/beacon/aggregation/models/cohort/status.js +8 -0
  40. package/dist/cjs/btcr2/beacon/aggregation/models/cohort/status.js.map +1 -0
  41. package/dist/cjs/btcr2/beacon/aggregation/participant.js +2 -0
  42. package/dist/cjs/btcr2/beacon/aggregation/participant.js.map +1 -0
  43. package/dist/cjs/btcr2/beacon/aggregation/protocol/nostr.js +57 -0
  44. package/dist/cjs/btcr2/beacon/aggregation/protocol/nostr.js.map +1 -0
  45. package/dist/cjs/btcr2/beacon/aggregation/protocol/service.js +2 -0
  46. package/dist/cjs/btcr2/beacon/aggregation/protocol/service.js.map +1 -0
  47. package/dist/cjs/btcr2/beacon/cid-aggregate.js +116 -0
  48. package/dist/cjs/btcr2/beacon/cid-aggregate.js.map +1 -0
  49. package/dist/cjs/btcr2/beacon/factory.js +30 -0
  50. package/dist/cjs/btcr2/beacon/factory.js.map +1 -0
  51. package/dist/cjs/btcr2/beacon/singleton.js +220 -0
  52. package/dist/cjs/btcr2/beacon/singleton.js.map +1 -0
  53. package/dist/cjs/btcr2/beacon/smt-aggregate.js +126 -0
  54. package/dist/cjs/btcr2/beacon/smt-aggregate.js.map +1 -0
  55. package/dist/cjs/btcr2/crud/create.js +102 -0
  56. package/dist/cjs/btcr2/crud/create.js.map +1 -0
  57. package/dist/cjs/btcr2/crud/deactivate.js +14 -0
  58. package/dist/cjs/btcr2/crud/deactivate.js.map +1 -0
  59. package/dist/cjs/btcr2/crud/read.js +686 -0
  60. package/dist/cjs/btcr2/crud/read.js.map +1 -0
  61. package/dist/cjs/btcr2/crud/update.js +195 -0
  62. package/dist/cjs/btcr2/crud/update.js.map +1 -0
  63. package/dist/cjs/btcr2/key-manager/index.js +290 -0
  64. package/dist/cjs/btcr2/key-manager/index.js.map +1 -0
  65. package/dist/cjs/btcr2/key-manager/interface.js +2 -0
  66. package/dist/cjs/btcr2/key-manager/interface.js.map +1 -0
  67. package/dist/cjs/did-btcr2.js +222 -0
  68. package/dist/cjs/did-btcr2.js.map +1 -0
  69. package/dist/cjs/index.js +27 -0
  70. package/dist/cjs/index.js.map +1 -0
  71. package/dist/cjs/interfaces/beacon.js +41 -0
  72. package/dist/cjs/interfaces/beacon.js.map +1 -0
  73. package/dist/cjs/interfaces/crud.js +2 -0
  74. package/dist/cjs/interfaces/crud.js.map +1 -0
  75. package/dist/cjs/interfaces/ibeacon.js +2 -0
  76. package/dist/cjs/interfaces/ibeacon.js.map +1 -0
  77. package/dist/cjs/package.json +1 -0
  78. package/dist/cjs/types/bitcoin.js +62 -0
  79. package/dist/cjs/types/bitcoin.js.map +1 -0
  80. package/dist/cjs/types/crud.js +2 -0
  81. package/dist/cjs/types/crud.js.map +1 -0
  82. package/dist/cjs/utils/appendix.js +221 -0
  83. package/dist/cjs/utils/appendix.js.map +1 -0
  84. package/dist/cjs/utils/beacons.js +206 -0
  85. package/dist/cjs/utils/beacons.js.map +1 -0
  86. package/dist/cjs/utils/did-document-builder.js +61 -0
  87. package/dist/cjs/utils/did-document-builder.js.map +1 -0
  88. package/dist/cjs/utils/did-document.js +380 -0
  89. package/dist/cjs/utils/did-document.js.map +1 -0
  90. package/dist/cjs/utils/general.js +195 -0
  91. package/dist/cjs/utils/general.js.map +1 -0
  92. package/dist/cjs/utils/identifier.js +238 -0
  93. package/dist/cjs/utils/identifier.js.map +1 -0
  94. package/dist/esm/bitcoin/constants.js +20 -0
  95. package/dist/esm/bitcoin/constants.js.map +1 -0
  96. package/dist/esm/bitcoin/errors.js +11 -0
  97. package/dist/esm/bitcoin/errors.js.map +1 -0
  98. package/dist/esm/bitcoin/index.js +95 -0
  99. package/dist/esm/bitcoin/index.js.map +1 -0
  100. package/dist/esm/bitcoin/interface.js +2 -0
  101. package/dist/esm/bitcoin/interface.js.map +1 -0
  102. package/dist/esm/bitcoin/network.js +17 -0
  103. package/dist/esm/bitcoin/network.js.map +1 -0
  104. package/dist/esm/bitcoin/rest-client.js +289 -0
  105. package/dist/esm/bitcoin/rest-client.js.map +1 -0
  106. package/dist/esm/bitcoin/rpc-client.js +722 -0
  107. package/dist/esm/bitcoin/rpc-client.js.map +1 -0
  108. package/dist/esm/bitcoin/taproot.js +219 -0
  109. package/dist/esm/bitcoin/taproot.js.map +1 -0
  110. package/dist/esm/btcr2/beacon/aggregation/coordinator.js +120 -0
  111. package/dist/esm/btcr2/beacon/aggregation/coordinator.js.map +1 -0
  112. package/dist/esm/btcr2/beacon/aggregation/messages/advert.js +24 -0
  113. package/dist/esm/btcr2/beacon/aggregation/messages/advert.js.map +1 -0
  114. package/dist/esm/btcr2/beacon/aggregation/messages/base.js +37 -0
  115. package/dist/esm/btcr2/beacon/aggregation/messages/base.js.map +1 -0
  116. package/dist/esm/btcr2/beacon/aggregation/messages/cohort-set.js +25 -0
  117. package/dist/esm/btcr2/beacon/aggregation/messages/cohort-set.js.map +1 -0
  118. package/dist/esm/btcr2/beacon/aggregation/messages/keygen.js +8 -0
  119. package/dist/esm/btcr2/beacon/aggregation/messages/keygen.js.map +1 -0
  120. package/dist/esm/btcr2/beacon/aggregation/messages/opt-in.js +23 -0
  121. package/dist/esm/btcr2/beacon/aggregation/messages/opt-in.js.map +1 -0
  122. package/dist/esm/btcr2/beacon/aggregation/messages/sign.js +7 -0
  123. package/dist/esm/btcr2/beacon/aggregation/messages/sign.js.map +1 -0
  124. package/dist/esm/btcr2/beacon/aggregation/models/cohort/index.js +92 -0
  125. package/dist/esm/btcr2/beacon/aggregation/models/cohort/index.js.map +1 -0
  126. package/dist/esm/btcr2/beacon/aggregation/models/cohort/status.js +8 -0
  127. package/dist/esm/btcr2/beacon/aggregation/models/cohort/status.js.map +1 -0
  128. package/dist/esm/btcr2/beacon/aggregation/participant.js +2 -0
  129. package/dist/esm/btcr2/beacon/aggregation/participant.js.map +1 -0
  130. package/dist/esm/btcr2/beacon/aggregation/protocol/nostr.js +57 -0
  131. package/dist/esm/btcr2/beacon/aggregation/protocol/nostr.js.map +1 -0
  132. package/dist/esm/btcr2/beacon/aggregation/protocol/service.js +2 -0
  133. package/dist/esm/btcr2/beacon/aggregation/protocol/service.js.map +1 -0
  134. package/dist/esm/btcr2/beacon/cid-aggregate.js +116 -0
  135. package/dist/esm/btcr2/beacon/cid-aggregate.js.map +1 -0
  136. package/dist/esm/btcr2/beacon/factory.js +30 -0
  137. package/dist/esm/btcr2/beacon/factory.js.map +1 -0
  138. package/dist/esm/btcr2/beacon/singleton.js +220 -0
  139. package/dist/esm/btcr2/beacon/singleton.js.map +1 -0
  140. package/dist/esm/btcr2/beacon/smt-aggregate.js +126 -0
  141. package/dist/esm/btcr2/beacon/smt-aggregate.js.map +1 -0
  142. package/dist/esm/btcr2/crud/create.js +102 -0
  143. package/dist/esm/btcr2/crud/create.js.map +1 -0
  144. package/dist/esm/btcr2/crud/deactivate.js +14 -0
  145. package/dist/esm/btcr2/crud/deactivate.js.map +1 -0
  146. package/dist/esm/btcr2/crud/read.js +686 -0
  147. package/dist/esm/btcr2/crud/read.js.map +1 -0
  148. package/dist/esm/btcr2/crud/update.js +195 -0
  149. package/dist/esm/btcr2/crud/update.js.map +1 -0
  150. package/dist/esm/btcr2/key-manager/index.js +290 -0
  151. package/dist/esm/btcr2/key-manager/index.js.map +1 -0
  152. package/dist/esm/btcr2/key-manager/interface.js +2 -0
  153. package/dist/esm/btcr2/key-manager/interface.js.map +1 -0
  154. package/dist/esm/did-btcr2.js +222 -0
  155. package/dist/esm/did-btcr2.js.map +1 -0
  156. package/dist/esm/index.js +27 -0
  157. package/dist/esm/index.js.map +1 -0
  158. package/dist/esm/interfaces/beacon.js +41 -0
  159. package/dist/esm/interfaces/beacon.js.map +1 -0
  160. package/dist/esm/interfaces/crud.js +2 -0
  161. package/dist/esm/interfaces/crud.js.map +1 -0
  162. package/dist/esm/interfaces/ibeacon.js +2 -0
  163. package/dist/esm/interfaces/ibeacon.js.map +1 -0
  164. package/dist/esm/types/bitcoin.js +62 -0
  165. package/dist/esm/types/bitcoin.js.map +1 -0
  166. package/dist/esm/types/crud.js +2 -0
  167. package/dist/esm/types/crud.js.map +1 -0
  168. package/dist/esm/utils/appendix.js +221 -0
  169. package/dist/esm/utils/appendix.js.map +1 -0
  170. package/dist/esm/utils/beacons.js +206 -0
  171. package/dist/esm/utils/beacons.js.map +1 -0
  172. package/dist/esm/utils/did-document-builder.js +61 -0
  173. package/dist/esm/utils/did-document-builder.js.map +1 -0
  174. package/dist/esm/utils/did-document.js +380 -0
  175. package/dist/esm/utils/did-document.js.map +1 -0
  176. package/dist/esm/utils/general.js +195 -0
  177. package/dist/esm/utils/general.js.map +1 -0
  178. package/dist/esm/utils/identifier.js +238 -0
  179. package/dist/esm/utils/identifier.js.map +1 -0
  180. package/dist/types/bitcoin/constants.d.ts +19 -0
  181. package/dist/types/bitcoin/constants.d.ts.map +1 -0
  182. package/dist/types/bitcoin/errors.d.ts +5 -0
  183. package/dist/types/bitcoin/errors.d.ts.map +1 -0
  184. package/dist/types/bitcoin/index.d.ts +75 -0
  185. package/dist/types/bitcoin/index.d.ts.map +1 -0
  186. package/dist/types/bitcoin/interface.d.ts +86 -0
  187. package/dist/types/bitcoin/interface.d.ts.map +1 -0
  188. package/dist/types/bitcoin/network.d.ts +2 -0
  189. package/dist/types/bitcoin/network.d.ts.map +1 -0
  190. package/dist/types/bitcoin/rest-client.d.ts +268 -0
  191. package/dist/types/bitcoin/rest-client.d.ts.map +1 -0
  192. package/dist/types/bitcoin/rpc-client.d.ts +506 -0
  193. package/dist/types/bitcoin/rpc-client.d.ts.map +1 -0
  194. package/dist/types/bitcoin/taproot.d.ts +34 -0
  195. package/dist/types/bitcoin/taproot.d.ts.map +1 -0
  196. package/dist/types/btcr2/beacon/aggregation/coordinator.d.ts +74 -0
  197. package/dist/types/btcr2/beacon/aggregation/coordinator.d.ts.map +1 -0
  198. package/dist/types/btcr2/beacon/aggregation/messages/advert.d.ts +22 -0
  199. package/dist/types/btcr2/beacon/aggregation/messages/advert.d.ts.map +1 -0
  200. package/dist/types/btcr2/beacon/aggregation/messages/base.d.ts +36 -0
  201. package/dist/types/btcr2/beacon/aggregation/messages/base.d.ts.map +1 -0
  202. package/dist/types/btcr2/beacon/aggregation/messages/cohort-set.d.ts +23 -0
  203. package/dist/types/btcr2/beacon/aggregation/messages/cohort-set.d.ts.map +1 -0
  204. package/dist/types/btcr2/beacon/aggregation/messages/keygen.d.ts +6 -0
  205. package/dist/types/btcr2/beacon/aggregation/messages/keygen.d.ts.map +1 -0
  206. package/dist/types/btcr2/beacon/aggregation/messages/opt-in.d.ts +22 -0
  207. package/dist/types/btcr2/beacon/aggregation/messages/opt-in.d.ts.map +1 -0
  208. package/dist/types/btcr2/beacon/aggregation/messages/sign.d.ts +5 -0
  209. package/dist/types/btcr2/beacon/aggregation/messages/sign.d.ts.map +1 -0
  210. package/dist/types/btcr2/beacon/aggregation/models/cohort/index.d.ts +77 -0
  211. package/dist/types/btcr2/beacon/aggregation/models/cohort/index.d.ts.map +1 -0
  212. package/dist/types/btcr2/beacon/aggregation/models/cohort/status.d.ts +7 -0
  213. package/dist/types/btcr2/beacon/aggregation/models/cohort/status.d.ts.map +1 -0
  214. package/dist/types/btcr2/beacon/aggregation/participant.d.ts +1 -0
  215. package/dist/types/btcr2/beacon/aggregation/participant.d.ts.map +1 -0
  216. package/dist/types/btcr2/beacon/aggregation/protocol/nostr.d.ts +36 -0
  217. package/dist/types/btcr2/beacon/aggregation/protocol/nostr.d.ts.map +1 -0
  218. package/dist/types/btcr2/beacon/aggregation/protocol/service.d.ts +6 -0
  219. package/dist/types/btcr2/beacon/aggregation/protocol/service.d.ts.map +1 -0
  220. package/dist/types/btcr2/beacon/cid-aggregate.d.ts +103 -0
  221. package/dist/types/btcr2/beacon/cid-aggregate.d.ts.map +1 -0
  222. package/dist/types/btcr2/beacon/factory.d.ts +17 -0
  223. package/dist/types/btcr2/beacon/factory.d.ts.map +1 -0
  224. package/dist/types/btcr2/beacon/singleton.d.ts +93 -0
  225. package/dist/types/btcr2/beacon/singleton.d.ts.map +1 -0
  226. package/dist/types/btcr2/beacon/smt-aggregate.d.ts +112 -0
  227. package/dist/types/btcr2/beacon/smt-aggregate.d.ts.map +1 -0
  228. package/dist/types/btcr2/crud/create.d.ts +92 -0
  229. package/dist/types/btcr2/crud/create.d.ts.map +1 -0
  230. package/dist/types/btcr2/crud/deactivate.d.ts +13 -0
  231. package/dist/types/btcr2/crud/deactivate.d.ts.map +1 -0
  232. package/dist/types/btcr2/crud/read.d.ts +341 -0
  233. package/dist/types/btcr2/crud/read.d.ts.map +1 -0
  234. package/dist/types/btcr2/crud/update.d.ts +83 -0
  235. package/dist/types/btcr2/crud/update.d.ts.map +1 -0
  236. package/dist/types/btcr2/key-manager/index.d.ts +145 -0
  237. package/dist/types/btcr2/key-manager/index.d.ts.map +1 -0
  238. package/dist/types/btcr2/key-manager/interface.d.ts +113 -0
  239. package/dist/types/btcr2/key-manager/interface.d.ts.map +1 -0
  240. package/dist/types/did-btcr2.d.ts +117 -0
  241. package/dist/types/did-btcr2.d.ts.map +1 -0
  242. package/dist/types/index.d.ts +26 -0
  243. package/dist/types/index.d.ts.map +1 -0
  244. package/dist/types/interfaces/beacon.d.ts +57 -0
  245. package/dist/types/interfaces/beacon.d.ts.map +1 -0
  246. package/dist/types/interfaces/crud.d.ts +35 -0
  247. package/dist/types/interfaces/crud.d.ts.map +1 -0
  248. package/dist/types/interfaces/ibeacon.d.ts +66 -0
  249. package/dist/types/interfaces/ibeacon.d.ts.map +1 -0
  250. package/dist/types/types/bitcoin.d.ts +827 -0
  251. package/dist/types/types/bitcoin.d.ts.map +1 -0
  252. package/dist/types/types/crud.d.ts +38 -0
  253. package/dist/types/types/crud.d.ts.map +1 -0
  254. package/dist/types/utils/appendix.d.ts +118 -0
  255. package/dist/types/utils/appendix.d.ts.map +1 -0
  256. package/dist/types/utils/beacons.d.ts +156 -0
  257. package/dist/types/utils/beacons.d.ts.map +1 -0
  258. package/dist/types/utils/did-document-builder.d.ts +13 -0
  259. package/dist/types/utils/did-document-builder.d.ts.map +1 -0
  260. package/dist/types/utils/did-document.d.ts +211 -0
  261. package/dist/types/utils/did-document.d.ts.map +1 -0
  262. package/dist/types/utils/general.d.ts +85 -0
  263. package/dist/types/utils/general.d.ts.map +1 -0
  264. package/dist/types/utils/identifier.d.ts +59 -0
  265. package/dist/types/utils/identifier.d.ts.map +1 -0
  266. package/package.json +137 -0
  267. package/src/bitcoin/constants.ts +19 -0
  268. package/src/bitcoin/errors.ts +10 -0
  269. package/src/bitcoin/index.ts +154 -0
  270. package/src/bitcoin/interface.ts +160 -0
  271. package/src/bitcoin/network.ts +17 -0
  272. package/src/bitcoin/rest-client.ts +415 -0
  273. package/src/bitcoin/rpc-client.ts +888 -0
  274. package/src/bitcoin/taproot.ts +237 -0
  275. package/src/btcr2/beacon/aggregation/coordinator.ts +135 -0
  276. package/src/btcr2/beacon/aggregation/messages/advert.ts +36 -0
  277. package/src/btcr2/beacon/aggregation/messages/base.ts +59 -0
  278. package/src/btcr2/beacon/aggregation/messages/cohort-set.ts +37 -0
  279. package/src/btcr2/beacon/aggregation/messages/keygen.ts +8 -0
  280. package/src/btcr2/beacon/aggregation/messages/opt-in.ts +35 -0
  281. package/src/btcr2/beacon/aggregation/messages/sign.ts +7 -0
  282. package/src/btcr2/beacon/aggregation/models/cohort/index.ts +112 -0
  283. package/src/btcr2/beacon/aggregation/models/cohort/status.ts +7 -0
  284. package/src/btcr2/beacon/aggregation/participant.ts +0 -0
  285. package/src/btcr2/beacon/aggregation/protocol/nostr.ts +81 -0
  286. package/src/btcr2/beacon/aggregation/protocol/service.ts +6 -0
  287. package/src/btcr2/beacon/cid-aggregate.ts +154 -0
  288. package/src/btcr2/beacon/factory.ts +36 -0
  289. package/src/btcr2/beacon/singleton.ts +257 -0
  290. package/src/btcr2/beacon/smt-aggregate.ts +136 -0
  291. package/src/btcr2/crud/create.ts +160 -0
  292. package/src/btcr2/crud/deactivate.ts +13 -0
  293. package/src/btcr2/crud/read.ts +946 -0
  294. package/src/btcr2/crud/update.ts +277 -0
  295. package/src/btcr2/key-manager/index.ts +364 -0
  296. package/src/btcr2/key-manager/interface.ts +129 -0
  297. package/src/canonicalize.d.ts +6 -0
  298. package/src/did-btcr2.ts +288 -0
  299. package/src/index.ts +34 -0
  300. package/src/interfaces/beacon.ts +68 -0
  301. package/src/interfaces/crud.ts +36 -0
  302. package/src/interfaces/ibeacon.ts +76 -0
  303. package/src/types/bitcoin.ts +1028 -0
  304. package/src/types/crud.ts +41 -0
  305. package/src/utils/appendix.ts +257 -0
  306. package/src/utils/beacons.ts +276 -0
  307. package/src/utils/did-document-builder.ts +73 -0
  308. package/src/utils/did-document.ts +474 -0
  309. package/src/utils/general.ts +204 -0
  310. package/src/utils/identifier.ts +276 -0
@@ -0,0 +1,722 @@
1
+ import { default as RpcClient } from 'bitcoin-core';
2
+ import { RpcClientConfig } from '../types/bitcoin.js';
3
+ import { DEFAULT_RPC_CLIENT_CONFIG } from './constants.js';
4
+ import { BitcoinRpcError } from './errors.js';
5
+ /**
6
+ * Encapsulates a {@link RpcClient | Client} object from {@link https://www.npmjs.com/package/bitcoin-core | `bitcoin-core`}.
7
+ * Implements a strongly-typed {@link IBitcoinRpc | IBitcoinRpc interface} for added expresivity and developer support.
8
+ * @class BitcoinRpc
9
+ * @type {BitcoinRpc}
10
+ */
11
+ export default class BitcoinRpc {
12
+ /**
13
+ * The encapsulated {@link RpcClientConfig} object.
14
+ * @private
15
+ * @type {RpcClient} An instance of the Client class from {@link https://www.npmjs.com/package/bitcoin-core | `bitcoin-core`}.
16
+ * See {@link https://github.com/ruimarinho/bitcoin-core/blob/master/src/index.d.ts#L64 | `Client`} for more information.
17
+ */
18
+ _client;
19
+ /**
20
+ * The encapsulated {@link RpcClientConfig} object.
21
+ * @private
22
+ * @type {RpcClientConfig} ClientConfig from {@link https://www.npmjs.com/package/bitcoin-core | `bitcoin-core`}.
23
+ * See {@link https://github.com/ruimarinho/bitcoin-core/blob/master/src/index.d.ts#L39 | `ClientConfig`} for more information.
24
+ */
25
+ _config;
26
+ /**
27
+ * Constructs a new {@link BitcoinRpc} instance from a new {@link RpcClient | RpcClient}.
28
+ * @param {RpcClientConfig} config The bitcoin-core client instance.
29
+ * @example
30
+ * ```
31
+ * import BitcoinRpc from '@did-btcr2/method';
32
+ * const bob = BitcoinRpc.connect(); // To use default polar config, pass no args. Polar must run locally.
33
+ * ```
34
+ */
35
+ constructor(config) {
36
+ this._config = new RpcClientConfig(config);
37
+ this._client = new RpcClient(this._config);
38
+ }
39
+ /**
40
+ * Get the config for the current BitcoinRpc object.
41
+ * @returns {RpcClientConfig} The encapsulated {@link RpcClientConfig} object.
42
+ * @example
43
+ * ```
44
+ * import BitcoinRpc from '@did-btcr2/method';
45
+ * const alice = BitcoinRpc.connect();
46
+ * const config = alice.config;
47
+ * ```
48
+ */
49
+ get config() {
50
+ const config = this._config;
51
+ return config;
52
+ }
53
+ /**
54
+ * Get the client for the current BitcoinRpc object.
55
+ * @returns {RpcClient} The encapsulated {@link RpcClient} object.
56
+ * @example
57
+ * ```
58
+ * const alice = BitcoinRpc.connect();
59
+ * const config = alice.client;
60
+ * ```
61
+ */
62
+ get client() {
63
+ const client = this._client;
64
+ return client;
65
+ }
66
+ /**
67
+ * Static method initializes a new BitcoinRpc client with the given configuration.
68
+ * The RpcClient returned by this method does not have any named methods.
69
+ * Use this method to create and pass a new RpcClient instance to a BitcoinRpc constructor.
70
+ *
71
+ * @param {IClientConfig} config The configuration object for the client (optional).
72
+ * @returns {RpcClient} A new RpcClient instance.
73
+ * @example
74
+ * ```
75
+ * const options: IClientConfig = {
76
+ * host: 'http://localhost:18443',
77
+ * username: 'alice',
78
+ * password: 'alicepass',
79
+ * version: '28.1.0',
80
+ * }
81
+ * const aliceClient = BitcoinRpc.initialize(options); // Client config required
82
+ * const alice = new BitcoinRpc(aliceClient);
83
+ * ```
84
+ */
85
+ static initialize(config) {
86
+ const rpcConfig = RpcClientConfig.initialize(config);
87
+ return new RpcClient(rpcConfig);
88
+ }
89
+ /**
90
+ * Static method connects to a bitcoin node running the bitcoin core daemon (bitcoind).
91
+ * To use default polar config, do not pass a config. See {@link DEFAULT_RPC_CLIENT_CONFIG} for default config.
92
+ * @required A locally running {@link https://github.com/jamaljsr/polar | Polar Lightning} regtest node.
93
+ *
94
+ * @param {?RpcClientConfig} config The configuration object for the client (optional).
95
+ * @returns A new {@link BitcoinRpc} instance.
96
+ * @example
97
+ * ```
98
+ * const alice = BitcoinRpc.connect();
99
+ * ```
100
+ */
101
+ static connect(config) {
102
+ const client = this.initialize(config ?? DEFAULT_RPC_CLIENT_CONFIG);
103
+ return new BitcoinRpc(client);
104
+ }
105
+ /**
106
+ * Check if the given error is a JSON-RPC error.
107
+ * @param {unknown} e The error to check.
108
+ * @returns {boolean} True if the error is a JSON-RPC error, false otherwise.
109
+ */
110
+ isJsonRpcError(e) {
111
+ return (e instanceof Error &&
112
+ e.name === 'RpcError' &&
113
+ typeof e.code === 'number');
114
+ }
115
+ /**
116
+ * Executes a JSON-RPC command on the bitcoind node.
117
+ * @param {MethodNameInLowerCase} method The name of the method to call.
118
+ * @param {Array<any>} parameters The parameters to pass to the method.
119
+ * @returns {Promise<T>} A promise resolving to the result of the command.
120
+ */
121
+ async executeRpc(method, parameters = []) {
122
+ try {
123
+ // raw call
124
+ const raw = await this.client.command([{ method, parameters }]);
125
+ // normalization/unwrapping, if needed
126
+ const normalized = JSON.unprototyped(raw) ? JSON.normalize(raw) : raw;
127
+ const result = Array.isArray(normalized)
128
+ ? normalized[normalized.length - 1]
129
+ : normalized;
130
+ return result;
131
+ }
132
+ catch (err) {
133
+ this.handleError(err, method, parameters);
134
+ }
135
+ }
136
+ /**
137
+ * Handle errors that occur while executing commands.
138
+ * @param methods An array of {@link BatchOption} objects.
139
+ * @param error The error that was thrown.
140
+ * @throws Throws a {@link BitcoinRpcError} with the error message.
141
+ */
142
+ handleError(err, method, params) {
143
+ if (this.isJsonRpcError(err)) {
144
+ // a bitcoind JSON‑RPC error
145
+ throw new BitcoinRpcError(err.code, `RPC ${method} failed: ${err.message}`, { method, params });
146
+ }
147
+ if (err instanceof Error) {
148
+ // network, HTTP, or unexpected client error
149
+ throw new BitcoinRpcError('NETWORK_ERROR', `Network error in ${method}: ${err.message}`, { method, params, original: err });
150
+ }
151
+ // absolutely unknown
152
+ throw new BitcoinRpcError('UNKNOWN_ERROR', `Unknown failure in ${method}`, { method, params, err });
153
+ }
154
+ /**
155
+ * TODO: Comments
156
+ */
157
+ async getUnspentTransactionOutputs(outpoints) {
158
+ return this.client.getUnspentTransactionOutputs(outpoints);
159
+ }
160
+ /**
161
+ * TODO: Comments
162
+ */
163
+ async getTransactionByHash(hash, options) {
164
+ return this.client.getTransactionByHash(hash, options);
165
+ }
166
+ /**
167
+ * TODO: Comments
168
+ */
169
+ async getBlockHeadersByHash(hash, count, options) {
170
+ return this.client.getBlockHeadersByHash(hash, count, options);
171
+ }
172
+ /**
173
+ * TODO: Comments
174
+ */
175
+ async getMemoryPoolContent() {
176
+ return this.client.getMemoryPoolContent();
177
+ }
178
+ /**
179
+ * TODO: Comments
180
+ */
181
+ async getMemoryPoolInformation() {
182
+ return this.client.getMemoryPoolInformation();
183
+ }
184
+ /**
185
+ * Alias for `getblock <hash> 2`
186
+ */
187
+ async getBlockByHash(hash, options) {
188
+ return this.client.getBlockByHash(hash, options);
189
+ }
190
+ /**
191
+ * TODO: Comments
192
+ */
193
+ async abandonTransaction(txid) {
194
+ return await this.executeRpc('abandontransaction', [txid]);
195
+ }
196
+ /**
197
+ * TODO: Comments
198
+ */
199
+ async abortRescan() {
200
+ return await this.executeRpc('abortrescan');
201
+ }
202
+ /**
203
+ * TODO: Comments
204
+ */
205
+ async addMultiSigAddress(params) {
206
+ return await this.executeRpc('addmultisigaddress', [params]);
207
+ }
208
+ /**
209
+ * TODO: Comments
210
+ */
211
+ async addWitnessAddress(address) {
212
+ return await this.executeRpc('addwitnessaddress', [address]);
213
+ }
214
+ /**
215
+ * TODO: Comments
216
+ */
217
+ async backupWallet(destination) {
218
+ return await this.executeRpc('backupwallet', [destination]);
219
+ }
220
+ /**
221
+ * TODO: Comments
222
+ */
223
+ async bumpFee(txid, options) {
224
+ return await this.executeRpc('bumpfee', [txid, options]);
225
+ }
226
+ /**
227
+ * TODO: Comments
228
+ */
229
+ async createMultiSig(nrequired, keys) {
230
+ return await this.executeRpc('createmultisig', [nrequired, keys]);
231
+ }
232
+ /**
233
+ * TODO: Comments
234
+ */
235
+ async createWallet(params) {
236
+ return await this.executeRpc('createwallet', [params]);
237
+ }
238
+ /**
239
+ * TODO: Comments
240
+ */
241
+ async decodeScript(hexstring) {
242
+ return await this.executeRpc('decodescript', [hexstring]);
243
+ }
244
+ /**
245
+ * TODO: Comments
246
+ */
247
+ async getBestBlockHash() {
248
+ return await this.executeRpc('getbestblockhash', []);
249
+ }
250
+ /**
251
+ * Returns the block data associated with a `blockhash` of a valid block.
252
+ * @param {GetBlockParams} params See {@link GetBlockParams} for details.
253
+ * @param {?string} params.blockhash The blockhash of the block to query.
254
+ * @param {?number} params.height The block height of the block to query.
255
+ * @param {?VerbosityLevel} params.verbosity The verbosity level. See {@link VerbosityLevel}.
256
+ * @returns {BlockResponse} A promise resolving to a {@link BlockResponse} formatted depending on `verbosity` level.
257
+ * @throws {BitcoinRpcError} If neither `blockhash` nor `height` is provided.
258
+ */
259
+ async getBlock({ blockhash, height, verbosity }) {
260
+ // Check if blockhash or height is provided, if neither throw an error
261
+ if (!blockhash && height === undefined) {
262
+ throw new BitcoinRpcError('blockhash or height required', 'INVALID_PARAMS_GET_BLOCK', { blockhash, height });
263
+ }
264
+ // If height is provided, get the blockhash
265
+ blockhash ??= await this.getBlockHash(height);
266
+ if (!blockhash || typeof blockhash !== 'string') {
267
+ return undefined;
268
+ }
269
+ // Get the block data
270
+ const block = await this.executeRpc('getblock', [blockhash, verbosity ?? 3]);
271
+ // Return the block data depending on verbosity level
272
+ switch (verbosity) {
273
+ case 0:
274
+ return block;
275
+ case 1:
276
+ return block;
277
+ case 2:
278
+ return block;
279
+ case 3:
280
+ return block;
281
+ default:
282
+ return block;
283
+ }
284
+ }
285
+ /**
286
+ * Returns the blockheight of the most-work fully-validated chain. The genesis block has height 0.
287
+ * @returns {Blockheight} The number of the blockheight with the most-work of the fully-validated chain.
288
+ */
289
+ async getBlockCount() {
290
+ return await this.executeRpc('getblockcount');
291
+ }
292
+ /**
293
+ * Returns the blockhash of the block at the given height in the active chain.
294
+ */
295
+ async getBlockHash(height) {
296
+ return await this.executeRpc('getblockhash', [height]);
297
+ }
298
+ /**
299
+ * TODO: Comments
300
+ */
301
+ async getBlockHeader(hash, verbose) {
302
+ return await this.executeRpc('getblockheader', [hash, verbose]);
303
+ }
304
+ /**
305
+ * TODO: Comments
306
+ */
307
+ async getBlockchainInfo() {
308
+ return this.client.getBlockchainInformation();
309
+ }
310
+ /**
311
+ * TODO: Comments
312
+ */
313
+ async getInfo(...args) {
314
+ return await this.executeRpc('getinfo', [...args]);
315
+ }
316
+ /**
317
+ * TODO: Comments
318
+ */
319
+ async getMemoryInfo(mode) {
320
+ return await this.executeRpc('getmemoryinfo', [mode]);
321
+ }
322
+ /**
323
+ * TODO: Comments
324
+ */
325
+ async scanBlocks(params) {
326
+ return await this.executeRpc('scanblocks', [params]);
327
+ }
328
+ /**
329
+ * TODO: Comments
330
+ */
331
+ async fundRawTransaction(hexstring, options) {
332
+ return await this.executeRpc('fundrawtransaction', [hexstring, options]);
333
+ }
334
+ /**
335
+ * Sign inputs for raw transaction (serialized, hex-encoded).
336
+ * The second optional argument (may be null) is an array of previous transaction outputs that
337
+ * this transaction depends on but may not yet be in the block chain.
338
+ * Requires wallet passphrase to be set with walletpassphrase call if wallet is encrypted.
339
+ * @param {string} hexstring The hex-encoded transaction to send.
340
+ */
341
+ async signRawTransaction(hexstring) {
342
+ return await this.executeRpc('signrawtransactionwithwallet', [hexstring]);
343
+ }
344
+ /**
345
+ * Submit a raw transaction (serialized, hex-encoded) to local node and network.
346
+ *
347
+ * The transaction will be sent unconditionally to all peers, so using sendrawtransaction
348
+ * for manual rebroadcast may degrade privacy by leaking the transaction's origin, as
349
+ * nodes will normally not rebroadcast non-wallet transactions already in their mempool.
350
+ *
351
+ * @param {string} hexstring The hex-encoded transaction to send.
352
+ * @param {numbner} [maxfeerate] If not passed, default is 0.10.
353
+ * @returns {Promise<string>} A promise resolving to the transaction hash in hex.
354
+ */
355
+ async sendRawTransaction(hexstring, maxfeerate, maxBurnAmount) {
356
+ console.log('sendRawTransaction', { hexstring, maxfeerate, maxBurnAmount });
357
+ return await this.executeRpc('sendrawtransaction', [hexstring, maxfeerate ?? 0.10, maxBurnAmount ?? 0.00]);
358
+ }
359
+ /**
360
+ * Combines calls to `signRawTransaction` and `sendRawTransaction`.
361
+ * @param {string} params.hexstring The hex-encoded transaction to send.
362
+ * @returns {Promise<string>} A promise resolving to the transaction hash in hex.
363
+ */
364
+ async signAndSendRawTransaction(hexstring) {
365
+ const signedRawTx = await this.signRawTransaction(hexstring);
366
+ return await this.sendRawTransaction(signedRawTx.hex);
367
+ }
368
+ /**
369
+ * Combines calls to `createRawTransaction`, `signRawTransaction` and `sendRawTransaction`.
370
+ * @param {CreateRawTxInputs[]} inputs The inputs to the transaction (required).
371
+ * @param {CreateRawTxOutputs[]} outputs The outputs of the transaction (required).
372
+ * @returns {Promise<string>} A promise resolving to the transaction hash in hex.
373
+ */
374
+ async createSignSendRawTransaction(inputs, outputs) {
375
+ const rawTx = await this.createRawTransaction(inputs, outputs);
376
+ const signedRawTx = await this.signRawTransaction(rawTx);
377
+ const sentRawTx = await this.sendRawTransaction(signedRawTx.hex);
378
+ return sentRawTx;
379
+ }
380
+ /**
381
+ * TODO: Comments
382
+ */
383
+ async listTransactions(params) {
384
+ return await this.executeRpc('listtransactions', [params]);
385
+ }
386
+ /**
387
+ * TODO: Comments
388
+ */
389
+ async decodeRawTransaction(hexstring) {
390
+ return await this.executeRpc('decoderawtransaction', [hexstring]);
391
+ }
392
+ /**
393
+ * TODO: Comments
394
+ */
395
+ async combineRawTransaction(txs) {
396
+ return await this.executeRpc('combinerawtransaction', [txs]);
397
+ }
398
+ /**
399
+ * Create a transaction spending the given inputs and creating new outputs.
400
+ * Outputs can be addresses or data.
401
+ * Returns hex-encoded raw transaction.
402
+ * Note that the transaction's inputs are not signed, and
403
+ * it is not stored in the wallet or transmitted to the network.
404
+ * @param {TxInForCreateRaw[]} inputs The inputs to the transaction (required).
405
+ * @param {CreateRawTxOutputs[]} outputs The outputs of the transaction (required).
406
+ * @param {number} [locktime] The locktime of the transaction (optional).
407
+ * @param {boolean} [replacable] Whether the transaction is replaceable (optional).
408
+ * @returns {string} The hex-encoded raw transaction.
409
+ */
410
+ async createRawTransaction(inputs, outputs, locktime, replacable) {
411
+ return await this.executeRpc('createrawtransaction', [inputs, outputs, locktime, replacable]);
412
+ }
413
+ /**
414
+ * Creates a multi-signature address with n signature of m keys required.
415
+ *
416
+ * @param {CreateMultisigParams} params The parameters for the createMultisig command.
417
+ * @param {number} params.nrequired The number of required signatures out of the n keys (required).
418
+ * @param {string[]} params.keys The hex-encoded public keys (required).
419
+ * @param {?string} params.address_type The address type to use (optional, options=["legacy", "p2sh-segwit", "bech32"], default="legacy").
420
+ * @returns {CreateMultiSigResult} json object with the address and redeemScript.
421
+ *
422
+ * @example Create a multisig address from 2 public keys
423
+ * ```
424
+ * const bob = BitcoinRpc.connect();
425
+ * const keys = [
426
+ * '03789ed0bb717d88f7d321a368d905e7430207ebbd82bd342cf11ae157a7ace5fd',
427
+ * '03dbc6764b8884a92e871274b87583e6d5c2a58819473e17e107ef3f6aa5a61626'
428
+ * ];
429
+ * const multisig = await bob.createMultisig({ nrequired: 2, keys });
430
+ * ```
431
+ */
432
+ async createMultisig({ nrequired, keys, address_type }) {
433
+ return await this.executeRpc('createmultisig', [nrequired, keys, address_type]);
434
+ }
435
+ /**
436
+ * TODO: Comments
437
+ */
438
+ async getDescriptorInfo(descriptor) {
439
+ return await this.executeRpc('getdescriptorinfo', [descriptor]);
440
+ }
441
+ /**
442
+ * TODO: Comments
443
+ */
444
+ async signMessageWithPrivkey(privkey, message) {
445
+ return await this.executeRpc('signmessagewithprivkey', [privkey, message]);
446
+ }
447
+ /**
448
+ * TODO: Comments
449
+ */
450
+ async validateAddress(address) {
451
+ return await this.executeRpc('validateaddress', [address]);
452
+ }
453
+ /**
454
+ * TODO: Comments
455
+ */
456
+ async verifyMessage(address, signature, message) {
457
+ return await this.executeRpc('verifymessage', [address, signature, message]);
458
+ }
459
+ /**
460
+ * Derives one or more addresses corresponding to an output descriptor.
461
+ * Examples of output descriptors are:
462
+ * pkh(<pubkey>) P2PKH outputs for the given pubkey
463
+ * wpkh(<pubkey>) Native segwit P2PKH outputs for the given pubkey
464
+ * sh(multi(<n>,<pubkey>,<pubkey>,...)) P2SH-multisig outputs for the given threshold and pubkeys
465
+ * raw(<hex script>) Outputs whose output script equals the specified hex-encoded bytes
466
+ * tr(<pubkey>,multi_a(<n>,<pubkey>,<pubkey>,...)) P2TR-multisig outputs for the given threshold and pubkeys
467
+ *
468
+ * In the above, <pubkey> either refers to a fixed public key in hexadecimal notation, or to an xpub/xprv optionally followed by one
469
+ * or more path elements separated by "/", where "h" represents a hardened child key.
470
+ *
471
+ * See {@link https://github.com/bitcoin/bitcoin/blob/master/doc/descriptors.md | github.com/bitcoin/bitcoin/descriptors.md}
472
+ * for more information.
473
+ * @async
474
+ * @param {string} descriptor The descriptor.
475
+ * @param {Array<number>} range If descriptor is ranged, must specify end or [begin,end] to derive.
476
+ * @returns {Array<DerivedAddresses>} a list of derived addresses
477
+ * @example First three native segwit receive addresses
478
+ * ```
479
+ * const bitcoind = BitcoinRpc.connect()
480
+ * const addresses = bitcoind.deriveAddresses("wpkh([d34db33f/84h/0h/0h]xpub6DJ2dN.../0/*)#cjjspncu", [0,2])
481
+ * ```
482
+ */
483
+ async deriveAddresses(descriptor, range) {
484
+ return await this.executeRpc('deriveaddresses', [descriptor, range]);
485
+ }
486
+ /**
487
+ * TODO: Comments
488
+ */
489
+ async addMultisigAddress() {
490
+ return await this.executeRpc('addmultisigaddress');
491
+ }
492
+ /**
493
+ * Creates the wallet's descriptor for the given address type. The address type must be one that the
494
+ * wallet does not already have a descriptor for. Requires wallet passphrase to be set with walletpassphrase call
495
+ * if wallet is encrypted.
496
+ * @param type The address type the descriptor will produce. Options are "legacy", "p2sh-segwit", "bech32", and "bech32m". (string, required)
497
+ * @param options Options object that can be used to pass named arguments, listed below. (json object, optional)
498
+ * @param options.internal Whether to only make one descriptor that is internal (if parameter is true) or external (if parameter is false)
499
+ * (boolean, optional, default=Both external and internal will be generated unless this parameter is specified)
500
+ * @param options.hdkey The HD key that the wallet knows the private key of, listed using 'gethdkeys', to use for this descriptor's key.
501
+ * (string, optional, default=The HD key used by all other active descriptors)
502
+ * @returns A {@link CreateWalletDescriptorsResult} response object
503
+ */
504
+ async createWalletDescriptor(type, options) {
505
+ return await this.executeRpc('createwalletdescriptor', [type, options]);
506
+ }
507
+ /**
508
+ * TODO: Comments
509
+ */
510
+ async getBalance() {
511
+ return await this.executeRpc('getbalance');
512
+ }
513
+ /**
514
+ * TODO: Comments
515
+ */
516
+ async getNewAddress(account) {
517
+ return await this.executeRpc('getnewaddress', [account]);
518
+ }
519
+ /**
520
+ * TODO: Comments
521
+ */
522
+ async importAddress(script, label, rescan, p2sh) {
523
+ return await this.executeRpc('importaddress', [script, label, rescan, p2sh]);
524
+ }
525
+ /**
526
+ * Import descriptors.
527
+ *
528
+ * This will trigger a rescan of the blockchain based on the earliest timestamp of all descriptors being imported.
529
+ * Requires a new wallet backup. Note: This call can take over an hour to complete if using an early timestamp;
530
+ * during that time, other rpc calls may report that the imported keys, addresses or scripts exist but related
531
+ * transactions are still missing. The rescan is significantly faster if block filters are available
532
+ * (using startup option "-blockfilterindex=1").
533
+ *
534
+ * @param requests Array of {@link ImportDescriptorRequest} objects to be imported
535
+ * @returns Array of {@link ImportDescriptorResult} objects
536
+ * @returns
537
+ */
538
+ async importDescriptors(requests) {
539
+ return await this.executeRpc('importdescriptors', [requests]);
540
+ }
541
+ /**
542
+ * TODO: Comments
543
+ */
544
+ async importMulti(requests, options) {
545
+ return await this.executeRpc('importmulti', [requests, options]);
546
+ }
547
+ /**
548
+ * TODO: Comments
549
+ */
550
+ async listUnspent(params) {
551
+ return await this.executeRpc('listunspent', [params]);
552
+ }
553
+ /**
554
+ * TODO: Comments
555
+ */
556
+ async rescanBlockchain() {
557
+ return await this.executeRpc('addmultisigaddress');
558
+ }
559
+ /**
560
+ * Send an amount to a given address.
561
+ * @async
562
+ * @param {string} address The address to send to.
563
+ * @param {number} amount The amount to send in BTC.
564
+ * @returns {Promise<SendToAddressResult>} A promise resolving to the transaction id.
565
+ */
566
+ async sendToAddress(address, amount) {
567
+ const txid = await this.executeRpc('sendtoaddress', [address, amount]);
568
+ return await this.getRawTransaction(txid);
569
+ }
570
+ /**
571
+ * TODO: Comments
572
+ */
573
+ async signMessage() {
574
+ return await this.executeRpc('signmessage');
575
+ }
576
+ /**
577
+ * TODO: Comments
578
+ */
579
+ async signRawTransactionWithWallet() {
580
+ return await this.executeRpc('signrawtransactionwithwallet');
581
+ }
582
+ /**
583
+ * TODO: Comments
584
+ */
585
+ async send() {
586
+ return await this.executeRpc('send');
587
+ }
588
+ /**
589
+ * @warning EXPERIMENTAL this call may be changed in future releases.
590
+ *
591
+ * Spend the value of all (or specific) confirmed UTXOs & unconfirmed change in the wallet to one or
592
+ * more recipients. Unconfirmed inbound UTXOs and locked UTXOs will not be spent. Sendall will respect the
593
+ * avoid_reuse wallet flag. If your wallet contains many small inputs, either because it received tiny payments or as
594
+ * a result of accumulating change, consider using `send_max` to exclude inputs that are worth less than the fees
595
+ * needed to spend them.
596
+ *
597
+ * @param {SendAllParams} params The parameters for the sendAll command.
598
+ * @param {Recipients} params.recipients The recipient destination addresses.
599
+ * Each address may only appear once. Optionally some recipients can be specified with an
600
+ * amount to perform payments, but at least one address must appear without a specified amount.
601
+ * @param {SendAllOptions} params.options Options object that can be used to pass named arguments.
602
+ * @param {} params.options.conf_target Confirmation target in blocks. numeric, optional, default=wallet -txconfirmtarget.
603
+ * @param estimate_mode The fee estimate mode, must be one of (case insensitive). string, optional, default="unset".
604
+ * See {@link FeeEstimateMode} for possible values.
605
+ * @param fee_rate Specify a fee rate in sat/vB. numeric or string, optional, default=not set,
606
+ * falls back to wallet fee estimation
607
+ * @param options: Options object that can be used to pass named arguments. json object, optional
608
+ *
609
+ * @returns A promise resolving to a {@link SendAllResult} object
610
+ *
611
+ * @example
612
+ * Spend all UTXOs from the wallet with a fee rate of 1 sat/vB using named arguments
613
+ * const bob = BitcoinRpc.connect({
614
+ * username: 'bob',
615
+ * password: 'bobpass',
616
+ * host: 'http://127.0.0.1:18443',
617
+ * allowDefaultWallet: true,
618
+ * version: '28.1.0'
619
+ * });
620
+ * const sendall = await bob.sendAll({
621
+ * recipients: [
622
+ * 'bc1q09vm5lfy0j5reeulh4x5752q25uqqvz34hufdl',
623
+ * 'bc1q02ad21edsxd23d32dfgqqsz4vv4nmtfzuklhy3'
624
+ * ],
625
+ * options: { fee_rate: 1.1 }
626
+ * });
627
+ */
628
+ async sendAll(params) {
629
+ return await this.executeRpc('sendall', [params]);
630
+ }
631
+ /**
632
+ * TODO: Comments
633
+ */
634
+ async sendMany(params) {
635
+ return await this.executeRpc('sendmany', [params]);
636
+ }
637
+ /**
638
+ * Get detailed information about in-wallet transaction <txid>.
639
+ * @param txid: The transaction id. (string, required)
640
+ * @param {boolean} include_watchonly Whether to include watch-only addresses in balance calculation and details.
641
+ * @returns {WalletTransaction} A promise resolving to a {@link WalletTransaction} object.
642
+ */
643
+ async getTransaction(txid, include_watchonly) {
644
+ return await this.executeRpc('gettransaction', [txid, include_watchonly]);
645
+ }
646
+ /**
647
+ * Get detailed information about a transaction.
648
+ *
649
+ * By default, this call only returns a transaction if it is in the mempool. If -txindex is enabled
650
+ * and no blockhash argument is passed, it will return the transaction if it is in the mempool or any block.
651
+ * If a blockhash argument is passed, it will return the transaction if the specified block is available and
652
+ * the transaction is in that block.
653
+ * @async
654
+ * @param {string} txid The transaction id (required).
655
+ * @param {?VerbosityLevel} verbosity Response format: 0 (hex), 1 (json) or 2 (jsonext).
656
+ * @param {?string} blockhash The block in which to look for the transaction (optional).
657
+ * @returns {GetRawTransaction} A promise resolving to data about a transaction in the form specified by verbosity.
658
+ */
659
+ async getRawTransaction(txid, verbosity, blockhash) {
660
+ // Get the raw transaction
661
+ const rawTransaction = await this.executeRpc('getrawtransaction', [txid, verbosity ?? 2, blockhash]);
662
+ // Return the raw transaction based on verbosity
663
+ switch (verbosity) {
664
+ case 0:
665
+ return rawTransaction;
666
+ case 1:
667
+ return rawTransaction;
668
+ case 2:
669
+ return rawTransaction;
670
+ default:
671
+ return rawTransaction;
672
+ }
673
+ }
674
+ /**
675
+ * Get detailed information about multiple transactions. An extension of {@link getRawTransaction}.
676
+ *
677
+ * @async
678
+ * @param {Array<string>} txids An array of transaction ids.
679
+ * @param {?VerbosityLevel} verbosity Response format: 0 (hex), 1 (json) or 2 (jsonext).
680
+ * @returns {Promise<Array<RawTransactionResponse>>}
681
+ */
682
+ async getRawTransactions(txids, verbosity) {
683
+ return await Promise.all(txids.map(async (txid) => await this.getRawTransaction(txid, verbosity ?? 2)));
684
+ }
685
+ clearBanned() {
686
+ throw new Error('Method not implemented.');
687
+ }
688
+ disconnectNode(address, nodeid) {
689
+ throw new Error('Method not implemented.' + address + nodeid);
690
+ }
691
+ dumpPrivKey(address) {
692
+ throw new Error('Method not implemented.' + address);
693
+ }
694
+ dumpWallet(filename) {
695
+ throw new Error('Method not implemented.' + filename);
696
+ }
697
+ encryptWallet(passphrase) {
698
+ throw new Error('Method not implemented.' + passphrase);
699
+ }
700
+ estimateSmartFee(conf_target, estimate_mode) {
701
+ throw new Error('Method not implemented.' + conf_target + estimate_mode);
702
+ }
703
+ getConnectionCount() {
704
+ throw new Error('Method not implemented.');
705
+ }
706
+ getDifficulty() {
707
+ throw new Error('Method not implemented.');
708
+ }
709
+ getMempoolInfo() {
710
+ throw new Error('Method not implemented.');
711
+ }
712
+ getMiningInfo() {
713
+ throw new Error('Method not implemented.');
714
+ }
715
+ getPeerInfo() {
716
+ throw new Error('Method not implemented.');
717
+ }
718
+ walletLock(passphrase, timeout) {
719
+ throw new Error('Method not implemented.' + passphrase + timeout);
720
+ }
721
+ }
722
+ //# sourceMappingURL=rpc-client.js.map