@teleportdao/bitcoin 2.0.5 → 2.0.8

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 (90) hide show
  1. package/dist/bitcoin-interface-ordinal.d.ts +108 -108
  2. package/dist/bitcoin-interface-ordinal.js +140 -140
  3. package/dist/bitcoin-interface-teleswap.d.ts +83 -101
  4. package/dist/bitcoin-interface-teleswap.d.ts.map +1 -1
  5. package/dist/bitcoin-interface-teleswap.js +119 -176
  6. package/dist/bitcoin-interface-teleswap.js.map +1 -1
  7. package/dist/bitcoin-interface-utils.d.ts +20 -20
  8. package/dist/bitcoin-interface-utils.js +45 -45
  9. package/dist/bitcoin-interface-wallet.d.ts +29 -28
  10. package/dist/bitcoin-interface-wallet.d.ts.map +1 -1
  11. package/dist/bitcoin-interface-wallet.js +126 -125
  12. package/dist/bitcoin-interface-wallet.js.map +1 -1
  13. package/dist/bitcoin-interface.d.ts +63 -66
  14. package/dist/bitcoin-interface.d.ts.map +1 -1
  15. package/dist/bitcoin-interface.js +112 -119
  16. package/dist/bitcoin-interface.js.map +1 -1
  17. package/dist/bitcoin-utils.d.ts +96 -96
  18. package/dist/bitcoin-utils.js +514 -514
  19. package/dist/bitcoin-wallet-base.d.ts +111 -111
  20. package/dist/bitcoin-wallet-base.d.ts.map +1 -1
  21. package/dist/bitcoin-wallet-base.js +258 -258
  22. package/dist/helper/brc20-helper.d.ts +42 -42
  23. package/dist/helper/brc20-helper.js +127 -127
  24. package/dist/helper/index.d.ts +3 -3
  25. package/dist/helper/index.js +29 -29
  26. package/dist/helper/ordinal-helper.d.ts +12 -12
  27. package/dist/helper/ordinal-helper.js +129 -129
  28. package/dist/helper/teleswap-helper.d.ts +95 -95
  29. package/dist/helper/teleswap-helper.js +186 -186
  30. package/dist/index.d.ts +12 -12
  31. package/dist/index.js +41 -41
  32. package/dist/ordinal-wallet.d.ts +492 -495
  33. package/dist/ordinal-wallet.d.ts.map +1 -1
  34. package/dist/ordinal-wallet.js +386 -386
  35. package/dist/ordinal-wallet.js.map +1 -1
  36. package/dist/sign/index.d.ts +1 -1
  37. package/dist/sign/index.js +8 -8
  38. package/dist/sign/sign-transaction.d.ts +12 -12
  39. package/dist/sign/sign-transaction.js +82 -82
  40. package/dist/teleswap-wallet.d.ts +45 -45
  41. package/dist/teleswap-wallet.js +68 -68
  42. package/dist/transaction-builder/bitcoin-transaction-builder.d.ts +9 -9
  43. package/dist/transaction-builder/bitcoin-transaction-builder.d.ts.map +1 -1
  44. package/dist/transaction-builder/bitcoin-transaction-builder.js +54 -54
  45. package/dist/transaction-builder/bitcoin-transaction-builder.js.map +1 -1
  46. package/dist/transaction-builder/index.d.ts +3 -3
  47. package/dist/transaction-builder/index.js +19 -19
  48. package/dist/transaction-builder/ordinal-transaction-builder.d.ts +63 -63
  49. package/dist/transaction-builder/ordinal-transaction-builder.js +125 -125
  50. package/dist/transaction-builder/transaction-builder.d.ts +223 -223
  51. package/dist/transaction-builder/transaction-builder.d.ts.map +1 -1
  52. package/dist/transaction-builder/transaction-builder.js +442 -447
  53. package/dist/transaction-builder/transaction-builder.js.map +1 -1
  54. package/dist/type.d.ts +55 -61
  55. package/dist/type.d.ts.map +1 -1
  56. package/dist/type.js +2 -2
  57. package/dist/utils/networks.d.ts +5 -5
  58. package/dist/utils/networks.js +53 -53
  59. package/dist/utils/tools.d.ts +18 -18
  60. package/dist/utils/tools.js +74 -74
  61. package/package.json +4 -4
  62. package/src/bitcoin-interface-ordinal.ts +185 -185
  63. package/src/bitcoin-interface-teleswap.ts +246 -251
  64. package/src/bitcoin-interface-utils.ts +60 -60
  65. package/src/bitcoin-interface-wallet.ts +112 -114
  66. package/src/bitcoin-interface.ts +146 -156
  67. package/src/bitcoin-utils.ts +591 -591
  68. package/src/bitcoin-wallet-base.ts +344 -344
  69. package/src/helper/brc20-helper.ts +179 -179
  70. package/src/helper/ordinal-helper.ts +118 -118
  71. package/src/index.ts +15 -15
  72. package/src/ordinal-wallet.ts +654 -659
  73. package/src/sign/index.ts +1 -1
  74. package/src/sign/sign-transaction.ts +108 -108
  75. package/src/teleswap-wallet.ts +133 -133
  76. package/src/transaction-builder/bitcoin-transaction-builder.ts +26 -26
  77. package/src/transaction-builder/index.ts +3 -3
  78. package/src/transaction-builder/ordinal-transaction-builder.ts +139 -139
  79. package/src/transaction-builder/transaction-builder.ts +686 -690
  80. package/src/type.ts +64 -74
  81. package/src/utils/networks.ts +33 -33
  82. package/src/utils/tools.ts +92 -92
  83. package/tsconfig.json +9 -9
  84. package/webpack.config.js +16 -16
  85. package/.tmp/block-parser.ts +0 -58
  86. package/.tmp/check.ts +0 -101
  87. package/.tmp/ordinal-helper.ts +0 -133
  88. package/.tmp/ordinal.ts +0 -25
  89. package/.tmp/psbt/sign-transaction.ts +0 -121
  90. package/.tmp/rbf.ts +0 -45
@@ -1,114 +1,112 @@
1
- import { bitcoin as bitcoinProvider } from "@teleportdao/providers"
2
- import { BitcoinInterfaceUtils } from "./bitcoin-interface-utils"
3
- import type { BitcoinWalletInterfaceConnectionInfo } from "./type"
4
- import type { SignerInfo } from "./transaction-builder/transaction-builder"
5
-
6
- export class BitcoinInterfaceWallet extends BitcoinInterfaceUtils {
7
- utxoProvider: bitcoinProvider.Types.UtxoProvider
8
- apiProvider: bitcoinProvider.MempoolSpace
9
-
10
- constructor(networkName: string, connectionInfo?: BitcoinWalletInterfaceConnectionInfo) {
11
- super(networkName)
12
- if (connectionInfo?.api?.provider === "BlockStream") {
13
- this.apiProvider = new bitcoinProvider.BlockStream(this.testnet)
14
- } else {
15
- this.apiProvider = new bitcoinProvider.MempoolSpace(this.testnet)
16
- }
17
-
18
- this.utxoProvider = connectionInfo?.utxo
19
- ? bitcoinProvider.getUtxoProvider(connectionInfo.utxo, networkName)!
20
- : this.apiProvider
21
- }
22
-
23
- async getFeeRate(speed?: "normal" | "slow" | "fast") {
24
- return new bitcoinProvider.MempoolSpace(this.testnet).getRecommendedFeeRate(speed)
25
- }
26
-
27
- async getUtxo(address: string) {
28
- if (!this.utxoProvider) {
29
- throw new Error("utxo provider not set")
30
- }
31
- return this.utxoProvider.getUtxos(address)
32
- }
33
-
34
- async getRawTransaction(txId: string) {
35
- if (this.utxoProvider.getRawTransaction) {
36
- return this.utxoProvider.getRawTransaction(txId)
37
- }
38
- return this.apiProvider.getRawTransaction(txId)
39
- }
40
-
41
- async sendRawTransaction(txHex: string) {
42
- if (this.utxoProvider.sendRawTransaction) {
43
- return this.utxoProvider.sendRawTransaction(txHex)
44
- }
45
- return this.apiProvider.sendRawTransaction(txHex)
46
- }
47
-
48
- async getExtendedUtxo(signerInfo: SignerInfo) {
49
- let utxos = await this.getUtxo(signerInfo.address)
50
- return utxos.map((tx) => ({
51
- hash: tx.txId,
52
- value: tx.value,
53
- index: tx.index,
54
- signerInfo,
55
- }))
56
- }
57
-
58
- async getAddressesUtxo(allAddresses: string[]) {
59
- const chunkOfAddresses = []
60
- const chunkLength = 20
61
- for (let i = 0; i < allAddresses.length; i += chunkLength) {
62
- const tmp = allAddresses.slice(i, i + chunkLength)
63
- chunkOfAddresses.push(tmp)
64
- }
65
-
66
- let results = []
67
-
68
- for (let addresses of chunkOfAddresses) {
69
- const allPromises = []
70
- for (let address of addresses) {
71
- let promise = await this.getUtxo(address)
72
- allPromises.push(promise)
73
- }
74
- let result = await Promise.all(allPromises)
75
- if (result.flat(1).length === 0) {
76
- break
77
- }
78
- results.push(result.flat(1))
79
- }
80
- return results.flat(1)
81
- }
82
-
83
- async getAddressesExtendedUtxo(signerInfos: SignerInfo[]) {
84
- const chunkOfAddresses = []
85
- const chunkLength = 20
86
- for (let i = 0; i < signerInfos.length; i += chunkLength) {
87
- const tmp = signerInfos.slice(i, i + chunkLength)
88
- chunkOfAddresses.push(tmp)
89
- }
90
-
91
- let results = []
92
-
93
- for (let addresses of chunkOfAddresses) {
94
- const allPromises = []
95
- for (let signerInfo of addresses) {
96
- let promise = await this.getExtendedUtxo(signerInfo)
97
- allPromises.push(promise)
98
- }
99
- let result = await Promise.all(allPromises)
100
- if (result.flat(1).length === 0) {
101
- break
102
- }
103
- results.push(result.flat(1))
104
- }
105
- return results.flat(1)
106
- }
107
-
108
- async getBalance(address: string) {
109
- let utxos = await this.utxoProvider.getUtxos(address)
110
- return utxos.reduce((a, tx) => a + Number(tx.value), 0)
111
- }
112
- }
113
-
114
- export default BitcoinInterfaceWallet
1
+ import { bitcoin as bitcoinProvider } from "@teleportdao/providers"
2
+ import { BitcoinInterfaceUtils } from "./bitcoin-interface-utils"
3
+ import type { BitcoinConnectionInfo } from "./type"
4
+ import type { SignerInfo } from "./transaction-builder/transaction-builder"
5
+
6
+ export class BitcoinInterfaceWallet extends BitcoinInterfaceUtils {
7
+ utxoProvider: bitcoinProvider.Types.UtxoProvider
8
+ apiProvider: bitcoinProvider.MempoolSpace
9
+ rpcProvider?: bitcoinProvider.BitcoinRPC
10
+ constructor(networkName: string, connectionInfo?: BitcoinConnectionInfo) {
11
+ super(networkName)
12
+ if (connectionInfo?.api?.provider === "BlockStream") {
13
+ this.apiProvider = new bitcoinProvider.BlockStream(this.testnet)
14
+ } else {
15
+ this.apiProvider = new bitcoinProvider.MempoolSpace(this.testnet)
16
+ }
17
+
18
+ this.utxoProvider = connectionInfo?.utxo
19
+ ? bitcoinProvider.getUtxoProvider(connectionInfo.utxo, networkName)!
20
+ : this.apiProvider
21
+
22
+ // only for send tx
23
+ if (connectionInfo?.rpc) this.rpcProvider = bitcoinProvider.getRpcProvider(connectionInfo?.rpc)
24
+ }
25
+
26
+ async getFeeRate(speed?: "normal" | "slow" | "fast") {
27
+ return this.apiProvider.getFeeRate(speed)
28
+ }
29
+
30
+ async getUtxo(address: string) {
31
+ return this.utxoProvider.getUtxos(address)
32
+ }
33
+
34
+ async getExtendedUtxo(signerInfo: SignerInfo) {
35
+ let utxos = await this.getUtxo(signerInfo.address)
36
+ return utxos.map((tx) => ({
37
+ hash: tx.txId,
38
+ value: tx.value,
39
+ index: tx.index,
40
+ signerInfo,
41
+ }))
42
+ }
43
+
44
+ async getAddressesUtxo(allAddresses: string[]) {
45
+ const chunkOfAddresses = []
46
+ const chunkLength = 20
47
+ for (let i = 0; i < allAddresses.length; i += chunkLength) {
48
+ const tmp = allAddresses.slice(i, i + chunkLength)
49
+ chunkOfAddresses.push(tmp)
50
+ }
51
+
52
+ let results = []
53
+
54
+ for (let addresses of chunkOfAddresses) {
55
+ const allPromises = []
56
+ for (let address of addresses) {
57
+ let promise = await this.getUtxo(address)
58
+ allPromises.push(promise)
59
+ }
60
+ let result = await Promise.all(allPromises)
61
+ if (result.flat(1).length === 0) {
62
+ break
63
+ }
64
+ results.push(result.flat(1))
65
+ }
66
+ return results.flat(1)
67
+ }
68
+
69
+ async getAddressesExtendedUtxo(signerInfos: SignerInfo[]) {
70
+ const chunkOfAddresses = []
71
+ const chunkLength = 20
72
+ for (let i = 0; i < signerInfos.length; i += chunkLength) {
73
+ const tmp = signerInfos.slice(i, i + chunkLength)
74
+ chunkOfAddresses.push(tmp)
75
+ }
76
+
77
+ let results = []
78
+
79
+ for (let addresses of chunkOfAddresses) {
80
+ const allPromises = []
81
+ for (let signerInfo of addresses) {
82
+ let promise = await this.getExtendedUtxo(signerInfo)
83
+ allPromises.push(promise)
84
+ }
85
+ let result = await Promise.all(allPromises)
86
+ if (result.flat(1).length === 0) {
87
+ break
88
+ }
89
+ results.push(result.flat(1))
90
+ }
91
+ return results.flat(1)
92
+ }
93
+
94
+ async getBalance(address: string) {
95
+ let utxos = await this.utxoProvider.getUtxos(address)
96
+ return utxos.reduce((a, tx) => a + Number(tx.value), 0)
97
+ }
98
+
99
+ async getRawTransaction(txId: string) {
100
+ if (this.rpcProvider) return this.rpcProvider.getRawTransaction(txId)
101
+ if (this.utxoProvider.getRawTransaction) return this.utxoProvider.getRawTransaction(txId)
102
+ return this.apiProvider.getRawTransaction(txId)
103
+ }
104
+
105
+ async sendRawTransaction(txHex: string) {
106
+ if (this.rpcProvider) return this.rpcProvider.sendRawTransaction(txHex)
107
+ if (this.utxoProvider.sendRawTransaction) return this.utxoProvider.sendRawTransaction(txHex)
108
+ return this.apiProvider.sendRawTransaction(txHex)
109
+ }
110
+ }
111
+
112
+ export default BitcoinInterfaceWallet
@@ -1,156 +1,146 @@
1
- import { bitcoin as bitcoinProvider } from "@teleportdao/providers"
2
- import { runWithRetries } from "./utils/tools"
3
- import {
4
- parseRawTransaction,
5
- calculateMerkleProof,
6
- extractTransactionsAndBlockInfoFromRawBlock,
7
- } from "./bitcoin-utils"
8
- import BitcoinInterfaceWallet from "./bitcoin-interface-wallet"
9
- import type { BitcoinInterfaceConnectionInfo } from "./type"
10
-
11
- export class BitcoinInterface extends BitcoinInterfaceWallet {
12
- rpcProvider?: bitcoinProvider.BitcoinRPC
13
-
14
- constructor(networkName: string, connectionInfo?: BitcoinInterfaceConnectionInfo) {
15
- super(networkName, connectionInfo)
16
- if (connectionInfo?.rpc) {
17
- this.rpcProvider = bitcoinProvider.getRpcProvider(connectionInfo.rpc)
18
- }
19
- }
20
-
21
- async getLatestBlockNumber(): Promise<number> {
22
- let latestHeight = await (this.rpcProvider || this.apiProvider).getLatestBlockNumber()
23
- return latestHeight
24
- }
25
-
26
- async getBlockHash(blockNumber: number): Promise<string> {
27
- let headerHash = await runWithRetries(() =>
28
- (this.rpcProvider || this.apiProvider).getBlockHash(blockNumber),
29
- )
30
- return headerHash
31
- }
32
-
33
- async getBlockHeaderHex(blockNumber: number): Promise<string> {
34
- let headerHex = await runWithRetries(() =>
35
- (this.rpcProvider || this.apiProvider).getBlockHeaderHex(blockNumber),
36
- )
37
- return headerHex
38
- }
39
-
40
- async getTransaction(txId: string) {
41
- return (this.rpcProvider || this.apiProvider).getTransaction(txId)
42
- }
43
-
44
- async getRawTransaction(txId: string) {
45
- return (this.rpcProvider || this.apiProvider).getRawTransaction(txId)
46
- }
47
-
48
- async sendRawTransaction(txId: string) {
49
- return (this.rpcProvider || this.apiProvider).sendRawTransaction(txId)
50
- }
51
-
52
- async getMerkleProof(
53
- txId: string,
54
- blockHash: string,
55
- ): Promise<{
56
- intermediateNodes: string
57
- transactionIndex: number
58
- }> {
59
- if (!this.rpcProvider) {
60
- return this.apiProvider.getMerkleProof(txId)
61
- }
62
- let txIds = await runWithRetries(() => this.rpcProvider!.getBlockTransactionIds(blockHash), {
63
- maxTries: 10,
64
- retrySleep: 2000,
65
- })
66
- let proof = calculateMerkleProof(txIds, txId)
67
- return proof
68
- }
69
-
70
- async getRequestProof(transaction: {
71
- txId: string
72
- hex?: string
73
- blockHash?: string
74
- blockNumber?: number
75
- merkleProof?: {
76
- intermediateNodes: string
77
- transactionIndex: number
78
- }
79
- }) {
80
- let transactionHex = transaction.hex || (await this.getRawTransaction(transaction.txId))
81
-
82
- let blockHash = transaction.blockHash
83
- let blockNumber = transaction.blockNumber
84
- if (!(transaction.blockHash && transaction.blockNumber)) {
85
- let txInfo = await this.getTransaction(transaction.txId)
86
- blockHash = txInfo.blockHash
87
- blockNumber = txInfo.blockNumber
88
- }
89
- let parsedTx = parseRawTransaction(transactionHex)
90
- let merkleProof =
91
- transaction.merkleProof || (await this.getMerkleProof(transaction.txId, blockHash!))
92
-
93
- return {
94
- parsedTx,
95
- merkleProof,
96
- blockNumber: blockNumber!,
97
- blockHash: blockHash!,
98
- }
99
- }
100
-
101
- // rpc
102
- async getBlockTransactions(
103
- addresses: string[],
104
- blockNumber: number,
105
- inputTxIds: {
106
- txId: string
107
- index: number
108
- address: string
109
- script?: string | undefined
110
- value?: number | undefined
111
- }[] = [],
112
- ) {
113
- if (!this.rpcProvider) {
114
- throw new Error("RPC provider not set")
115
- }
116
- let rawBlockHex = await runWithRetries(
117
- () => this.rpcProvider!.getBlockByBlockNumber(blockNumber, 0),
118
- {
119
- maxTries: 10,
120
- retrySleep: 2000,
121
- },
122
- )
123
- return extractTransactionsAndBlockInfoFromRawBlock(
124
- rawBlockHex,
125
- blockNumber,
126
- addresses,
127
- inputTxIds,
128
- this.network,
129
- )
130
- }
131
-
132
- // from start+1 to end
133
- async getMultipleBlocksTransactions(
134
- addresses: string[],
135
- startBlockNumber: number,
136
- endBlockNumber: number,
137
- inputTxIds: {
138
- txId: string
139
- index: number
140
- address: string
141
- script?: string | undefined
142
- value?: number | undefined
143
- }[] = [],
144
- ) {
145
- let blockTxs = []
146
- for (let blockNumber = +startBlockNumber + 1; blockNumber <= endBlockNumber; blockNumber += 1) {
147
- console.log(blockNumber)
148
- const response = await this.getBlockTransactions(addresses, blockNumber, inputTxIds)
149
- blockTxs.push(response.withdrawTxs, response.depositTxs)
150
- }
151
- blockTxs = await Promise.all(blockTxs)
152
- return blockTxs.flat(1)
153
- }
154
- }
155
-
156
- export default BitcoinInterface
1
+ import { bitcoin as bitcoinProvider } from "@teleportdao/providers"
2
+ import { runWithRetries } from "./utils/tools"
3
+ import {
4
+ parseRawTransaction,
5
+ calculateMerkleProof,
6
+ extractTransactionsAndBlockInfoFromRawBlock,
7
+ } from "./bitcoin-utils"
8
+ import BitcoinInterfaceWallet from "./bitcoin-interface-wallet"
9
+
10
+ export class BitcoinInterface extends BitcoinInterfaceWallet {
11
+ async getLatestBlockNumber(): Promise<number> {
12
+ let latestHeight = await (this.rpcProvider || this.apiProvider).getLatestBlockNumber()
13
+ return latestHeight
14
+ }
15
+
16
+ async getBlockHash(blockNumber: number): Promise<string> {
17
+ let headerHash = await runWithRetries(() =>
18
+ (this.rpcProvider || this.apiProvider).getBlockHash(blockNumber),
19
+ )
20
+ return headerHash
21
+ }
22
+
23
+ async getBlockHeaderHex(blockNumber: number): Promise<string> {
24
+ let headerHex = await runWithRetries(() =>
25
+ (this.rpcProvider || this.apiProvider).getBlockHeaderHex(blockNumber),
26
+ )
27
+ return headerHex
28
+ }
29
+
30
+ async getTransaction(txId: string) {
31
+ return (this.rpcProvider || this.apiProvider).getTransaction(txId)
32
+ }
33
+
34
+ async getRawTransaction(txId: string) {
35
+ return (this.rpcProvider || this.apiProvider).getRawTransaction(txId)
36
+ }
37
+
38
+ async sendRawTransaction(txId: string) {
39
+ return (this.rpcProvider || this.apiProvider).sendRawTransaction(txId)
40
+ }
41
+
42
+ async getMerkleProof(
43
+ txId: string,
44
+ blockHash: string,
45
+ ): Promise<{
46
+ intermediateNodes: string
47
+ transactionIndex: number
48
+ }> {
49
+ if (!this.rpcProvider) {
50
+ return this.apiProvider.getMerkleProof(txId)
51
+ }
52
+ let txIds = await runWithRetries(() => this.rpcProvider!.getBlockTransactionIds(blockHash), {
53
+ maxTries: 5,
54
+ retrySleep: 2000,
55
+ })
56
+ let proof = calculateMerkleProof(txIds, txId)
57
+ return proof
58
+ }
59
+
60
+ async getRequestProof(transaction: {
61
+ txId: string
62
+ hex?: string
63
+ blockHash?: string
64
+ blockNumber?: number
65
+ merkleProof?: {
66
+ intermediateNodes: string
67
+ transactionIndex: number
68
+ }
69
+ }) {
70
+ let transactionHex = transaction.hex || (await this.getRawTransaction(transaction.txId))
71
+
72
+ let blockHash = transaction.blockHash
73
+ let blockNumber = transaction.blockNumber
74
+ if (!(transaction.blockHash && transaction.blockNumber)) {
75
+ let txInfo = await this.getTransaction(transaction.txId)
76
+ blockHash = txInfo.blockHash
77
+ blockNumber = txInfo.blockNumber
78
+ }
79
+ let parsedTx = parseRawTransaction(transactionHex)
80
+ let merkleProof =
81
+ transaction.merkleProof || (await this.getMerkleProof(transaction.txId, blockHash!))
82
+
83
+ return {
84
+ parsedTx,
85
+ merkleProof,
86
+ blockNumber: blockNumber!,
87
+ blockHash: blockHash!,
88
+ }
89
+ }
90
+
91
+ // rpc
92
+ async getBlockTransactions(
93
+ addresses: string[],
94
+ blockNumber: number,
95
+ inputTxIds: {
96
+ txId: string
97
+ index: number
98
+ address: string
99
+ script?: string | undefined
100
+ value?: number | undefined
101
+ }[] = [],
102
+ ) {
103
+ if (!this.rpcProvider) {
104
+ throw new Error("RPC provider not set")
105
+ }
106
+ let rawBlockHex = await runWithRetries(
107
+ () => this.rpcProvider!.getBlockByBlockNumber(blockNumber, 0),
108
+ {
109
+ maxTries: 10,
110
+ retrySleep: 2000,
111
+ },
112
+ )
113
+ return extractTransactionsAndBlockInfoFromRawBlock(
114
+ rawBlockHex,
115
+ blockNumber,
116
+ addresses,
117
+ inputTxIds,
118
+ this.network,
119
+ )
120
+ }
121
+
122
+ // from start+1 to end
123
+ async getMultipleBlocksTransactions(
124
+ addresses: string[],
125
+ startBlockNumber: number,
126
+ endBlockNumber: number,
127
+ inputTxIds: {
128
+ txId: string
129
+ index: number
130
+ address: string
131
+ script?: string | undefined
132
+ value?: number | undefined
133
+ }[] = [],
134
+ ) {
135
+ let blockTxs = []
136
+ for (let blockNumber = +startBlockNumber + 1; blockNumber <= endBlockNumber; blockNumber += 1) {
137
+ console.log(blockNumber)
138
+ const response = await this.getBlockTransactions(addresses, blockNumber, inputTxIds)
139
+ blockTxs.push(response.withdrawTxs, response.depositTxs)
140
+ }
141
+ blockTxs = await Promise.all(blockTxs)
142
+ return blockTxs.flat(1)
143
+ }
144
+ }
145
+
146
+ export default BitcoinInterface