@teleportdao/bitcoin 1.7.2 → 1.7.6

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 (52) hide show
  1. package/dist/bitcoin-base.d.ts +93 -0
  2. package/dist/bitcoin-base.d.ts.map +1 -0
  3. package/dist/bitcoin-base.js +236 -0
  4. package/dist/bitcoin-base.js.map +1 -0
  5. package/dist/bitcoin-interface-teleswap.d.ts +6 -1
  6. package/dist/bitcoin-interface-teleswap.d.ts.map +1 -1
  7. package/dist/bitcoin-interface-teleswap.js +2 -4
  8. package/dist/bitcoin-interface-teleswap.js.map +1 -1
  9. package/dist/helper/burn-request-helper.d.ts +7 -0
  10. package/dist/helper/burn-request-helper.d.ts.map +1 -0
  11. package/dist/helper/burn-request-helper.js +26 -0
  12. package/dist/helper/burn-request-helper.js.map +1 -0
  13. package/dist/helper/teleport-request-helper.d.ts +47 -0
  14. package/dist/helper/teleport-request-helper.d.ts.map +1 -0
  15. package/dist/helper/teleport-request-helper.js +146 -0
  16. package/dist/helper/teleport-request-helper.js.map +1 -0
  17. package/dist/helper/teleswap-helper.d.ts +20 -8
  18. package/dist/helper/teleswap-helper.d.ts.map +1 -1
  19. package/dist/helper/teleswap-helper.js +55 -50
  20. package/dist/helper/teleswap-helper.js.map +1 -1
  21. package/dist/teleport-dao-payments.d.ts +76 -0
  22. package/dist/teleport-dao-payments.d.ts.map +1 -0
  23. package/dist/teleport-dao-payments.js +217 -0
  24. package/dist/teleport-dao-payments.js.map +1 -0
  25. package/dist/teleswap-wallet.d.ts +4 -6
  26. package/dist/teleswap-wallet.d.ts.map +1 -1
  27. package/dist/teleswap-wallet.js +7 -8
  28. package/dist/teleswap-wallet.js.map +1 -1
  29. package/package.json +5 -5
  30. package/src/bitcoin-interface-ordinal.ts +181 -181
  31. package/src/bitcoin-interface-teleswap.ts +252 -255
  32. package/src/bitcoin-interface-utils.ts +59 -59
  33. package/src/bitcoin-interface.ts +247 -247
  34. package/src/bitcoin-utils.ts +591 -591
  35. package/src/bitcoin-wallet-base.ts +314 -314
  36. package/src/helper/brc20-helper.ts +181 -181
  37. package/src/helper/ordinal-helper.ts +118 -118
  38. package/src/helper/teleswap-helper.ts +77 -101
  39. package/src/index.ts +15 -15
  40. package/src/ordinal-wallet.ts +738 -738
  41. package/src/sign/index.ts +1 -1
  42. package/src/sign/sign-transaction.ts +108 -108
  43. package/src/teleswap-wallet.ts +152 -155
  44. package/src/transaction-builder/bitcoin-transaction-builder.ts +44 -44
  45. package/src/transaction-builder/index.ts +3 -3
  46. package/src/transaction-builder/ordinal-transaction-builder.ts +147 -147
  47. package/src/transaction-builder/transaction-builder.ts +705 -705
  48. package/src/type.ts +43 -43
  49. package/src/utils/networks.ts +33 -33
  50. package/src/utils/tools.ts +89 -89
  51. package/tsconfig.json +9 -9
  52. package/webpack.config.js +16 -16
@@ -1,255 +1,252 @@
1
- import { bitcoin } from "@teleportdao/providers"
2
- import { parseBlockHeader } from "./bitcoin-utils"
3
- import {
4
- checkAndParseWrapRequest,
5
- getBurnTransactionInfo,
6
- UnwrapInfo,
7
- WrapOpReturnWithType,
8
- } from "./helper/teleswap-helper"
9
- import BitcoinInterface from "./bitcoin-interface"
10
- import { Transaction } from "./type"
11
-
12
- export type ValidWrapRequest = {
13
- transaction: bitcoin.Types.ConfirmedTransaction & {
14
- address?: string
15
- addressScript?: string
16
- merkleProof?: Transaction["merkleProof"]
17
- }
18
- request: {
19
- status: boolean
20
- data: WrapOpReturnWithType
21
- value: number
22
- valueOutputIndex: number
23
- }
24
- lockerAddress: string
25
- lockerLockingScript: string
26
- }
27
-
28
- export type InValidWrapRequest = {
29
- transaction: bitcoin.Types.ConfirmedTransaction & {
30
- address?: string
31
- addressScript?: string
32
- merkleProof?: Transaction["merkleProof"]
33
- }
34
- request: {
35
- status: boolean
36
- message: string
37
- code: string
38
- }
39
- lockerAddress: string
40
- lockerLockingScript: string
41
- }
42
-
43
- export type UnwrapRequest = {
44
- burnInfo: UnwrapInfo | undefined
45
- lockerAddress: string
46
- lockerLockingScript: string
47
- }
48
-
49
- export class BitcoinInterfaceTeleswap extends BitcoinInterface {
50
- // relayer
51
- async getHexBlockHeaders(startBlockNumber: number, endBlockNumber: number) {
52
- const blockHeaders = []
53
- let difficulty = null
54
- let hexBlockHeaders = ""
55
-
56
- let fromBlockNumber = startBlockNumber
57
- for (let blockNumber = startBlockNumber; blockNumber <= endBlockNumber; blockNumber += 1) {
58
- let blockHeader = await this.getBlockHeaderHex(blockNumber)
59
- console.log("block", blockNumber)
60
- let parsedBlockHeader = parseBlockHeader(blockHeader)
61
- if (difficulty && parsedBlockHeader.difficulty !== difficulty) {
62
- blockHeaders.push({
63
- hexBlockHeaders,
64
- fromBlockNumber,
65
- toBlockNumber: blockNumber - 1,
66
- difficulty,
67
- })
68
- hexBlockHeaders = blockHeader
69
- fromBlockNumber = blockNumber
70
- } else {
71
- hexBlockHeaders += blockHeader
72
- }
73
- difficulty = parsedBlockHeader.difficulty
74
- }
75
- if (hexBlockHeaders) {
76
- blockHeaders.push({
77
- hexBlockHeaders,
78
- fromBlockNumber,
79
- toBlockNumber: endBlockNumber,
80
- difficulty,
81
- })
82
- }
83
-
84
- return blockHeaders
85
- }
86
-
87
- async getWrapRequests(addresses: string[], startblockNumber: number, endBlockNumber: number) {
88
- // transaction in StartBlock is not returned --> (startblockNumber,endBlockNumber]
89
- let transactions = await this.getMultipleBlocksTransactions(
90
- addresses,
91
- startblockNumber,
92
- endBlockNumber,
93
- )
94
-
95
- let requests: ValidWrapRequest[] = []
96
- let invalidRequests: InValidWrapRequest[] = []
97
-
98
- for (let inputTx of transactions) {
99
- let { transaction, request, lockerAddress, lockerLockingScript } =
100
- await this.getWrapRequestByTx(inputTx, inputTx.address)
101
- if (request.status && "data" in request && request.data) {
102
- requests.push({
103
- transaction,
104
- request,
105
- lockerAddress,
106
- lockerLockingScript,
107
- })
108
- } else if (request.code !== "NO_OP_RETURN") {
109
- invalidRequests.push({ transaction, request, lockerAddress, lockerLockingScript })
110
- }
111
- }
112
- return { requests, invalidRequests }
113
- }
114
-
115
- async getMempoolWrapRequests(addresses: string[]) {
116
- // transaction in StartBlock is not returned --> (startblockNumber,endBlockNumber]
117
- let transactions = await this.apiProvider.getMempoolTransactionHistoryForMultipleAddresses(
118
- addresses,
119
- )
120
-
121
- let requests = []
122
- let invalidRequests = []
123
-
124
- for (let inputTx of transactions) {
125
- let { transaction, request, lockerAddress, lockerLockingScript } =
126
- await this.getWrapRequestByTx(inputTx, inputTx.address)
127
- if (request.status) {
128
- requests.push({ transaction, request, lockerAddress, lockerLockingScript })
129
- } else if (request.code !== "NO_OP_RETURN") {
130
- invalidRequests.push({ transaction, request, lockerAddress, lockerLockingScript })
131
- }
132
- }
133
- return { requests, invalidRequests }
134
- }
135
-
136
- async getWrapRequestByTx(
137
- inputTransaction:
138
- | { txId: string }
139
- | (bitcoin.Types.ConfirmedTransaction & {
140
- address?: string
141
- addressScript?: string
142
- merkleProof?: Transaction["merkleProof"]
143
- }),
144
- lockerAddress: string,
145
- minTeleporterFeeAmount = 0,
146
- ) {
147
- let transaction: bitcoin.Types.ConfirmedTransaction & {
148
- address?: string
149
- addressScript?: string
150
- merkleProof?: Transaction["merkleProof"]
151
- }
152
- if ("vout" in inputTransaction && "blockNumber" in inputTransaction) {
153
- transaction = inputTransaction
154
- } else {
155
- if (!inputTransaction.txId) throw new Error("txId not exist")
156
- transaction = await this.getTransaction(inputTransaction.txId)
157
- }
158
-
159
- let vout = transaction.vout
160
- let request = checkAndParseWrapRequest(vout!, lockerAddress, {
161
- minTeleporterFeeAmount,
162
- })
163
- let lockerLockingScript: string =
164
- transaction.addressScript ||
165
- this.convertAddressToScript(lockerAddress).script!.toString("hex")
166
-
167
- return {
168
- transaction,
169
- request,
170
- lockerAddress,
171
- lockerLockingScript,
172
- }
173
- }
174
-
175
- async getLockersUnWrapTransactions(
176
- addresses: string[],
177
- startBlockNumber: number,
178
- endBlockNumber: number,
179
- ) {
180
- let transactions = await this.getMultipleBlocksTransactions(
181
- addresses,
182
- startBlockNumber,
183
- endBlockNumber,
184
- )
185
-
186
- let validTxs = []
187
- for (let transaction of transactions) {
188
- let address = transaction.address
189
- // check if its a transaction to spend btc
190
- let txBurnInfo = await this.getTransactionUnwrapInfoByTx(transaction, address)
191
- if (txBurnInfo) {
192
- const { burnInfo, lockerAddress, lockerLockingScript } = txBurnInfo
193
- validTxs.push({
194
- transaction,
195
- burnInfo,
196
- lockerAddress,
197
- lockerLockingScript,
198
- })
199
- }
200
- }
201
- return validTxs
202
- }
203
-
204
- async getLockersUnwrapMEmpoolTransactions(
205
- addresses: string[],
206
- startBlockNumber: number,
207
- endBlockNumber: number,
208
- ) {
209
- let transactions = await this.getMultipleBlocksTransactions(
210
- addresses,
211
- startBlockNumber,
212
- endBlockNumber,
213
- )
214
-
215
- let validTxs = []
216
- for (let transaction of transactions) {
217
- let address = transaction.address
218
- // check if its a transaction to spend btc
219
- let txBurnInfo = await this.getTransactionUnwrapInfoByTx(transaction, address)
220
- if (txBurnInfo) {
221
- const { burnInfo, lockerAddress, lockerLockingScript } = txBurnInfo
222
- validTxs.push({
223
- transaction,
224
- burnInfo,
225
- lockerAddress,
226
- lockerLockingScript,
227
- })
228
- }
229
- }
230
- return validTxs
231
- }
232
-
233
- async getTransactionUnwrapInfoByTx(
234
- transaction: {
235
- txId: any
236
- vout?: any
237
- vin?: any
238
- addressScript?: any
239
- },
240
- lockerAddress: string,
241
- ) {
242
- if (!transaction.txId) throw new Error("txId not exist")
243
- let vin = transaction.vin || (await this.getTransaction(transaction.txId)).vin
244
- let burnInfo = getBurnTransactionInfo(lockerAddress, vin, transaction.vout)
245
- if (!burnInfo) return
246
- let lockerLockingScript: string =
247
- transaction.addressScript ||
248
- this.convertAddressToScript(lockerAddress).script!.toString("hex")
249
- return {
250
- burnInfo,
251
- lockerAddress,
252
- lockerLockingScript,
253
- } as UnwrapRequest
254
- }
255
- }
1
+ import { bitcoin } from "@teleportdao/providers"
2
+ import { parseBlockHeader } from "./bitcoin-utils"
3
+ import {
4
+ checkAndParseWrapRequest,
5
+ getBurnTransactionInfo,
6
+ UnwrapInfo,
7
+ WrapOpReturnWithType,
8
+ } from "./helper/teleswap-helper"
9
+ import BitcoinInterface from "./bitcoin-interface"
10
+ import { Transaction } from "./type"
11
+
12
+ export type ValidWrapRequest = {
13
+ transaction: bitcoin.Types.ConfirmedTransaction & {
14
+ address?: string
15
+ addressScript?: string
16
+ merkleProof?: Transaction["merkleProof"]
17
+ }
18
+ request: {
19
+ status: boolean
20
+ data: WrapOpReturnWithType
21
+ value: number
22
+ valueOutputIndex: number
23
+ }
24
+ lockerAddress: string
25
+ lockerLockingScript: string
26
+ }
27
+
28
+ export type InValidWrapRequest = {
29
+ transaction: bitcoin.Types.ConfirmedTransaction & {
30
+ address?: string
31
+ addressScript?: string
32
+ merkleProof?: Transaction["merkleProof"]
33
+ }
34
+ request: {
35
+ status: boolean
36
+ message: string
37
+ code: string
38
+ }
39
+ lockerAddress: string
40
+ lockerLockingScript: string
41
+ }
42
+
43
+ export type UnwrapRequest = {
44
+ burnInfo: UnwrapInfo | undefined
45
+ lockerAddress: string
46
+ lockerLockingScript: string
47
+ }
48
+
49
+ export class BitcoinInterfaceTeleswap extends BitcoinInterface {
50
+ // relayer
51
+ async getHexBlockHeaders(startBlockNumber: number, endBlockNumber: number) {
52
+ const blockHeaders = []
53
+ let difficulty = null
54
+ let hexBlockHeaders = ""
55
+
56
+ let fromBlockNumber = startBlockNumber
57
+ for (let blockNumber = startBlockNumber; blockNumber <= endBlockNumber; blockNumber += 1) {
58
+ let blockHeader = await this.getBlockHeaderHex(blockNumber)
59
+ console.log("block", blockNumber)
60
+ let parsedBlockHeader = parseBlockHeader(blockHeader)
61
+ if (difficulty && parsedBlockHeader.difficulty !== difficulty) {
62
+ blockHeaders.push({
63
+ hexBlockHeaders,
64
+ fromBlockNumber,
65
+ toBlockNumber: blockNumber - 1,
66
+ difficulty,
67
+ })
68
+ hexBlockHeaders = blockHeader
69
+ fromBlockNumber = blockNumber
70
+ } else {
71
+ hexBlockHeaders += blockHeader
72
+ }
73
+ difficulty = parsedBlockHeader.difficulty
74
+ }
75
+ if (hexBlockHeaders) {
76
+ blockHeaders.push({
77
+ hexBlockHeaders,
78
+ fromBlockNumber,
79
+ toBlockNumber: endBlockNumber,
80
+ difficulty,
81
+ })
82
+ }
83
+
84
+ return blockHeaders
85
+ }
86
+
87
+ async getWrapRequests(addresses: string[], startblockNumber: number, endBlockNumber: number) {
88
+ // transaction in StartBlock is not returned --> (startblockNumber,endBlockNumber]
89
+ let transactions = await this.getMultipleBlocksTransactions(
90
+ addresses,
91
+ startblockNumber,
92
+ endBlockNumber,
93
+ )
94
+
95
+ let requests: ValidWrapRequest[] = []
96
+ let invalidRequests: InValidWrapRequest[] = []
97
+
98
+ for (let inputTx of transactions) {
99
+ let { transaction, request, lockerAddress, lockerLockingScript } =
100
+ await this.getWrapRequestByTx(inputTx, inputTx.address)
101
+ if (request.status && "data" in request && request.data) {
102
+ requests.push({
103
+ transaction,
104
+ request,
105
+ lockerAddress,
106
+ lockerLockingScript,
107
+ })
108
+ } else if (request.code !== "NO_OP_RETURN") {
109
+ invalidRequests.push({ transaction, request, lockerAddress, lockerLockingScript })
110
+ }
111
+ }
112
+ return { requests, invalidRequests }
113
+ }
114
+
115
+ async getMempoolWrapRequests(addresses: string[]) {
116
+ // transaction in StartBlock is not returned --> (startblockNumber,endBlockNumber]
117
+ let transactions = await this.apiProvider.getMempoolTransactionHistoryForMultipleAddresses(
118
+ addresses,
119
+ )
120
+
121
+ let requests = []
122
+ let invalidRequests = []
123
+
124
+ for (let inputTx of transactions) {
125
+ let { transaction, request, lockerAddress, lockerLockingScript } =
126
+ await this.getWrapRequestByTx(inputTx, inputTx.address)
127
+ if (request.status) {
128
+ requests.push({ transaction, request, lockerAddress, lockerLockingScript })
129
+ } else if (request.code !== "NO_OP_RETURN") {
130
+ invalidRequests.push({ transaction, request, lockerAddress, lockerLockingScript })
131
+ }
132
+ }
133
+ return { requests, invalidRequests }
134
+ }
135
+
136
+ async getWrapRequestByTx(
137
+ inputTransaction:
138
+ | { txId: string }
139
+ | (bitcoin.Types.ConfirmedTransaction & {
140
+ address?: string
141
+ addressScript?: string
142
+ merkleProof?: Transaction["merkleProof"]
143
+ }),
144
+ lockerAddress: string,
145
+ ) {
146
+ let transaction: bitcoin.Types.ConfirmedTransaction & {
147
+ address?: string
148
+ addressScript?: string
149
+ merkleProof?: Transaction["merkleProof"]
150
+ }
151
+ if ("vout" in inputTransaction && "blockNumber" in inputTransaction) {
152
+ transaction = inputTransaction
153
+ } else {
154
+ if (!inputTransaction.txId) throw new Error("txId not exist")
155
+ transaction = await this.getTransaction(inputTransaction.txId)
156
+ }
157
+
158
+ let vout = transaction.vout
159
+ let request = checkAndParseWrapRequest(vout!, lockerAddress)
160
+ let lockerLockingScript: string =
161
+ transaction.addressScript ||
162
+ this.convertAddressToScript(lockerAddress).script!.toString("hex")
163
+
164
+ return {
165
+ transaction,
166
+ request,
167
+ lockerAddress,
168
+ lockerLockingScript,
169
+ }
170
+ }
171
+
172
+ async getLockersUnWrapTransactions(
173
+ addresses: string[],
174
+ startBlockNumber: number,
175
+ endBlockNumber: number,
176
+ ) {
177
+ let transactions = await this.getMultipleBlocksTransactions(
178
+ addresses,
179
+ startBlockNumber,
180
+ endBlockNumber,
181
+ )
182
+
183
+ let validTxs = []
184
+ for (let transaction of transactions) {
185
+ let address = transaction.address
186
+ // check if its a transaction to spend btc
187
+ let txBurnInfo = await this.getTransactionUnwrapInfoByTx(transaction, address)
188
+ if (txBurnInfo) {
189
+ const { burnInfo, lockerAddress, lockerLockingScript } = txBurnInfo
190
+ validTxs.push({
191
+ transaction,
192
+ burnInfo,
193
+ lockerAddress,
194
+ lockerLockingScript,
195
+ })
196
+ }
197
+ }
198
+ return validTxs
199
+ }
200
+
201
+ async getLockersUnwrapMEmpoolTransactions(
202
+ addresses: string[],
203
+ startBlockNumber: number,
204
+ endBlockNumber: number,
205
+ ) {
206
+ let transactions = await this.getMultipleBlocksTransactions(
207
+ addresses,
208
+ startBlockNumber,
209
+ endBlockNumber,
210
+ )
211
+
212
+ let validTxs = []
213
+ for (let transaction of transactions) {
214
+ let address = transaction.address
215
+ // check if its a transaction to spend btc
216
+ let txBurnInfo = await this.getTransactionUnwrapInfoByTx(transaction, address)
217
+ if (txBurnInfo) {
218
+ const { burnInfo, lockerAddress, lockerLockingScript } = txBurnInfo
219
+ validTxs.push({
220
+ transaction,
221
+ burnInfo,
222
+ lockerAddress,
223
+ lockerLockingScript,
224
+ })
225
+ }
226
+ }
227
+ return validTxs
228
+ }
229
+
230
+ async getTransactionUnwrapInfoByTx(
231
+ transaction: {
232
+ txId: any
233
+ vout?: any
234
+ vin?: any
235
+ addressScript?: any
236
+ },
237
+ lockerAddress: string,
238
+ ) {
239
+ if (!transaction.txId) throw new Error("txId not exist")
240
+ let vin = transaction.vin || (await this.getTransaction(transaction.txId)).vin
241
+ let burnInfo = getBurnTransactionInfo(lockerAddress, vin, transaction.vout)
242
+ if (!burnInfo) return
243
+ let lockerLockingScript: string =
244
+ transaction.addressScript ||
245
+ this.convertAddressToScript(lockerAddress).script!.toString("hex")
246
+ return {
247
+ burnInfo,
248
+ lockerAddress,
249
+ lockerLockingScript,
250
+ } as UnwrapRequest
251
+ }
252
+ }
@@ -1,59 +1,59 @@
1
- import type { Network } from "bitcoinjs-lib"
2
- import networks from "./utils/networks"
3
- import {
4
- createAddressObjectByHash,
5
- createAddressObjectByAddress,
6
- createAddressObjectByPublicKey,
7
- createAddressObjectByScript,
8
- } from "./bitcoin-utils"
9
-
10
- export class BitcoinInterfaceUtils {
11
- testnet: boolean
12
- network: Network
13
- constructor(networkName: string) {
14
- this.testnet = networkName.includes("_testnet")
15
- this.network = networks[networkName]
16
- }
17
-
18
- convertHashToAddress(hashHex: string, addressType: string) {
19
- let addressObj = createAddressObjectByHash(
20
- { addressType, hash: Buffer.from(hashHex, "hex") },
21
- this.network,
22
- )
23
- if (!addressObj.address) throw new Error("incorrect input")
24
- return addressObj.address
25
- }
26
-
27
- convertScriptToAddress(scriptHex: string, addressType: string) {
28
- let addressObj = createAddressObjectByScript(
29
- { addressType, script: Buffer.from(scriptHex, "hex") },
30
- this.network,
31
- )
32
- if (!addressObj.address) throw new Error("incorrect input")
33
- return addressObj.address
34
- }
35
-
36
- convertAddressToScript(address: string) {
37
- let { addressObject, addressType } = createAddressObjectByAddress(address, this.network)
38
- return {
39
- script: addressObject.output,
40
- hash: addressObject.hash,
41
- addressType,
42
- }
43
- }
44
-
45
- convertAddressToObject(address: string) {
46
- let addObj = createAddressObjectByAddress(address, this.network)
47
- return addObj
48
- }
49
-
50
- createAddressObjectByPublicKey(publicKey: string, addressType: string) {
51
- let addObj = createAddressObjectByPublicKey(
52
- { publicKey: Buffer.from(publicKey, "hex"), addressType },
53
- this.network,
54
- )
55
- return addObj
56
- }
57
- }
58
-
59
- export default BitcoinInterfaceUtils
1
+ import type { Network } from "bitcoinjs-lib"
2
+ import networks from "./utils/networks"
3
+ import {
4
+ createAddressObjectByHash,
5
+ createAddressObjectByAddress,
6
+ createAddressObjectByPublicKey,
7
+ createAddressObjectByScript,
8
+ } from "./bitcoin-utils"
9
+
10
+ export class BitcoinInterfaceUtils {
11
+ testnet: boolean
12
+ network: Network
13
+ constructor(networkName: string) {
14
+ this.testnet = networkName.includes("_testnet")
15
+ this.network = networks[networkName]
16
+ }
17
+
18
+ convertHashToAddress(hashHex: string, addressType: string) {
19
+ let addressObj = createAddressObjectByHash(
20
+ { addressType, hash: Buffer.from(hashHex, "hex") },
21
+ this.network,
22
+ )
23
+ if (!addressObj.address) throw new Error("incorrect input")
24
+ return addressObj.address
25
+ }
26
+
27
+ convertScriptToAddress(scriptHex: string, addressType: string) {
28
+ let addressObj = createAddressObjectByScript(
29
+ { addressType, script: Buffer.from(scriptHex, "hex") },
30
+ this.network,
31
+ )
32
+ if (!addressObj.address) throw new Error("incorrect input")
33
+ return addressObj.address
34
+ }
35
+
36
+ convertAddressToScript(address: string) {
37
+ let { addressObject, addressType } = createAddressObjectByAddress(address, this.network)
38
+ return {
39
+ script: addressObject.output,
40
+ hash: addressObject.hash,
41
+ addressType,
42
+ }
43
+ }
44
+
45
+ convertAddressToObject(address: string) {
46
+ let addObj = createAddressObjectByAddress(address, this.network)
47
+ return addObj
48
+ }
49
+
50
+ createAddressObjectByPublicKey(publicKey: string, addressType: string) {
51
+ let addObj = createAddressObjectByPublicKey(
52
+ { publicKey: Buffer.from(publicKey, "hex"), addressType },
53
+ this.network,
54
+ )
55
+ return addObj
56
+ }
57
+ }
58
+
59
+ export default BitcoinInterfaceUtils