@teleportdao/bitcoin 1.4.3 → 1.4.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 (69) hide show
  1. package/dist/bitcoin-base.d.ts +66 -53
  2. package/dist/bitcoin-base.d.ts.map +1 -1
  3. package/dist/bitcoin-base.js +47 -38
  4. package/dist/bitcoin-base.js.map +1 -1
  5. package/dist/bitcoin-interface-utils.d.ts +12 -10
  6. package/dist/bitcoin-interface-utils.d.ts.map +1 -1
  7. package/dist/bitcoin-interface-utils.js +16 -10
  8. package/dist/bitcoin-interface-utils.js.map +1 -1
  9. package/dist/bitcoin-interface.d.ts +206 -50
  10. package/dist/bitcoin-interface.d.ts.map +1 -1
  11. package/dist/bitcoin-interface.js +42 -27
  12. package/dist/bitcoin-interface.js.map +1 -1
  13. package/dist/bitcoin-utils.d.ts +111 -41
  14. package/dist/bitcoin-utils.d.ts.map +1 -1
  15. package/dist/bitcoin-utils.js +215 -156
  16. package/dist/bitcoin-utils.js.map +1 -1
  17. package/dist/bundle.js +13 -0
  18. package/dist/index.d.ts +5 -6
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +32 -12
  21. package/dist/index.js.map +1 -1
  22. package/dist/sign/sign-transaction.d.ts +9 -5
  23. package/dist/sign/sign-transaction.d.ts.map +1 -1
  24. package/dist/sign/sign-transaction.js +14 -11
  25. package/dist/sign/sign-transaction.js.map +1 -1
  26. package/dist/teleport-dao-payments.d.ts +68 -89
  27. package/dist/teleport-dao-payments.d.ts.map +1 -1
  28. package/dist/teleport-dao-payments.js +16 -4
  29. package/dist/teleport-dao-payments.js.map +1 -1
  30. package/dist/transaction-builder/bitcoin-transaction-builder.d.ts +30 -11
  31. package/dist/transaction-builder/bitcoin-transaction-builder.d.ts.map +1 -1
  32. package/dist/transaction-builder/bitcoin-transaction-builder.js +37 -9
  33. package/dist/transaction-builder/bitcoin-transaction-builder.js.map +1 -1
  34. package/dist/transaction-builder/transaction-builder.d.ts +198 -9
  35. package/dist/transaction-builder/transaction-builder.d.ts.map +1 -1
  36. package/dist/transaction-builder/transaction-builder.js +291 -38
  37. package/dist/transaction-builder/transaction-builder.js.map +1 -1
  38. package/dist/utils/networks.d.ts +5 -35
  39. package/dist/utils/networks.d.ts.map +1 -1
  40. package/dist/utils/networks.js +26 -2
  41. package/dist/utils/networks.js.map +1 -1
  42. package/dist/utils/tools.d.ts +15 -9
  43. package/dist/utils/tools.d.ts.map +1 -1
  44. package/dist/utils/tools.js +14 -11
  45. package/dist/utils/tools.js.map +1 -1
  46. package/package.json +8 -6
  47. package/src/{bitcoin-base.js → bitcoin-base.ts} +248 -219
  48. package/src/{bitcoin-interface-utils.js → bitcoin-interface-utils.ts} +59 -53
  49. package/src/{bitcoin-interface.js → bitcoin-interface.ts} +420 -350
  50. package/src/{bitcoin-utils.js → bitcoin-utils.ts} +608 -483
  51. package/src/helper/teleport-request-helper.js +179 -179
  52. package/src/index.ts +5 -0
  53. package/src/sign/sign-transaction.ts +96 -0
  54. package/src/{teleport-dao-payments.js → teleport-dao-payments.ts} +341 -280
  55. package/src/transaction-builder/bitcoin-transaction-builder.ts +61 -0
  56. package/src/transaction-builder/transaction-builder.ts +567 -0
  57. package/src/utils/{networks.js → networks.ts} +33 -31
  58. package/src/utils/{tools.js → tools.ts} +80 -72
  59. package/tsconfig.json +10 -9
  60. package/webpack.config.js +16 -0
  61. package/dist/transaction-builder/transaction-builder-common.d.ts +0 -57
  62. package/dist/transaction-builder/transaction-builder-common.d.ts.map +0 -1
  63. package/dist/transaction-builder/transaction-builder-common.js +0 -183
  64. package/dist/transaction-builder/transaction-builder-common.js.map +0 -1
  65. package/src/index.js +0 -15
  66. package/src/sign/sign-transaction.js +0 -36
  67. package/src/transaction-builder/bitcoin-transaction-builder.js +0 -37
  68. package/src/transaction-builder/transaction-builder-common.js +0 -236
  69. package/src/transaction-builder/transaction-builder.js +0 -159
@@ -1,219 +1,248 @@
1
- const bip39 = require("bip39")
2
- const bip32 = require("bip32")
3
- const hdWalletNetworksPath = require("@teleportdao/configs").hdWalletPath
4
- const { getPubKeyFromPrivateKeyHex } = require("./bitcoin-utils")
5
- const networks = require("./utils/networks")
6
-
7
- const TransactionBuilder = require("./transaction-builder/bitcoin-transaction-builder")
8
- const BitcoinSign = require("./sign/sign-transaction")
9
-
10
- class BitcoinBase {
11
- constructor(
12
- networkName,
13
- connectionInfo = {
14
- api: {
15
- enabled: true,
16
- provider: "BlockStream",
17
- },
18
- },
19
- ) {
20
- this.network = networks[networkName]
21
- this.hdWalletPath = hdWalletNetworksPath[networkName.replace("_testnet", "")]
22
-
23
- this.transactionBuilder = new TransactionBuilder(connectionInfo, networkName, this.network)
24
- this.btcInterface = this.transactionBuilder.btcInterface
25
-
26
- this.signer = new BitcoinSign(this.network)
27
-
28
- this.currentAccount = null
29
- this.currentAccountType = null
30
-
31
- this.privateKey = null
32
- this.publicKey = null
33
- // todo multisig
34
- this.publicKeys = []
35
- }
36
-
37
- static createTransactionInputsAndOutputs({
38
- targets,
39
- extendedUtxo,
40
- changeAddress,
41
- feeRate,
42
- fullAmount = false,
43
- }) {
44
- return TransactionBuilder.helperHandleInputsAndOutputs({
45
- targets,
46
- extendedUtxo,
47
- changeAddress,
48
- feeRate,
49
- fullAmount,
50
- })
51
- }
52
-
53
- static checkBalanceIsSufficient({
54
- targets,
55
- extendedUtxo,
56
- changeAddress,
57
- feeRate,
58
- fullAmount = false,
59
- }) {
60
- try {
61
- TransactionBuilder.helperHandleInputsAndOutputs({
62
- targets,
63
- extendedUtxo,
64
- changeAddress,
65
- feeRate,
66
- fullAmount,
67
- })
68
- return true
69
- } catch (err) {
70
- return false
71
- }
72
- }
73
-
74
- setMultiSigAccount(accountType = "p2sh") {
75
- /* eslint-disable no-unreachable */
76
- // todo : not completed
77
- switch (accountType) {
78
- // case 'p2sh':
79
- // this.currentAccount = ''
80
- // break
81
- // case 'p2wsh':
82
- // this.currentAccount = ''
83
- // break
84
- // case 'p2sh-p2wsh':
85
- // this.currentAccount = ''
86
- // break
87
- default:
88
- throw new Error("accountType is incorrect")
89
- }
90
- this.currentAccountType = accountType
91
- }
92
-
93
- setAccountPrivateKey(privateKeyHex) {
94
- this.privateKey = Buffer.from(privateKeyHex, "hex")
95
- let publicKey = getPubKeyFromPrivateKeyHex(privateKeyHex, this.network)
96
- this.publicKey = publicKey
97
- }
98
-
99
- setAccountPublicKey(publicKeyHex) {
100
- this.publicKey = Buffer.from(publicKeyHex, "hex")
101
- }
102
-
103
- /**
104
- *
105
- * @param {*} input
106
- * @param {*} input.mnemonic
107
- * @param {*} input.mnemonicPassword
108
- * @param {*} input.index
109
- * @param {*} input.walletNumber
110
- * @param {*} input.addressType
111
- * @returns
112
- */
113
- setAccountPrivateKeyByMnemonic({
114
- mnemonic,
115
- mnemonicPassword = "",
116
- index = 0,
117
- walletNumber = 0,
118
- addressType = "p2sh-p2wpkh",
119
- }) {
120
- if (!bip39.validateMnemonic(mnemonic)) throw new Error("invalid mnemonic")
121
- const seed = bip39.mnemonicToSeedSync(mnemonic, mnemonicPassword)
122
- const node = bip32.fromSeed(seed)
123
-
124
- if (!this.hdWalletPath[addressType]) throw new Error("incorrect path or addressType")
125
-
126
- const path = `${this.hdWalletPath[addressType]}/${walletNumber}`
127
- const account = node.derivePath(path)
128
- const userKeyPair = account.derive(index)
129
- this.setAccountPrivateKey(userKeyPair.privateKey.toString("hex"))
130
- return this.setAccount(addressType)
131
- }
132
-
133
- setAccount(accountType = "p2pkh") {
134
- let addressObj = this.transactionBuilder.createAddressObject({
135
- addressType: accountType,
136
- publicKey: this.publicKey,
137
- })
138
- this.currentAccount = addressObj.address
139
- this.currentAccountType = accountType
140
- this.addressObj = addressObj
141
- this.bitcoinAddress = addressObj.address
142
- return addressObj.address
143
- }
144
-
145
- /**
146
- *
147
- * @param {Object} signerInfo
148
- * @param {*} signerInfo.address
149
- * @param {*} signerInfo.addressType
150
- * @param {*} signerInfo.publicKey
151
- * @param {*} signerInfo.derivationPath
152
- * @param {*} signerInfo.masterFingerprint
153
- * @returns
154
- */
155
- async getExtendedUtxo({ address, addressType, publicKey, derivationPath, masterFingerprint }) {
156
- return this.transactionBuilder.getExtendedUtxo({
157
- address,
158
- addressType,
159
- publicKey,
160
- derivationPath,
161
- masterFingerprint,
162
- })
163
- }
164
-
165
- /**
166
- *
167
- * @param {*} input
168
- * @param {*} input.receiverAddress
169
- * @param {*} input.amount
170
- * @param {*} input.fullAmount
171
- * @param {*} input.speed
172
- * @returns
173
- */
174
- async send({ receiverAddress, amount, fullAmount = false, speed = "normal" }) {
175
- let extendedUtxo = await this.getExtendedUtxo({
176
- address: this.currentAccount,
177
- addressType: this.currentAccountType,
178
- publicKey: this.publicKey.toString("hex"),
179
- })
180
- if (amount - +amount.toFixed() !== 0)
181
- throw new Error("incorrect amount. amount should be in satoshi")
182
- let feeRate = await this.transactionBuilder._getFeeRate(speed)
183
- let unsignedTx = await this.transactionBuilder.processUnsignedTransaction({
184
- extendedUtxo,
185
- targets: [
186
- {
187
- address: receiverAddress,
188
- value: amount,
189
- },
190
- ],
191
- changeAddress: this.currentAccount,
192
- feeRate,
193
- fullAmount,
194
- })
195
- let signedPsbt = await this.signer.signPsbt(unsignedTx, this.privateKey)
196
- let signedTx = this.signer.finalizePsbts([signedPsbt])
197
- let txId = await this.transactionBuilder.sendTx(signedTx)
198
- return txId
199
- }
200
-
201
- async sendSignedPsbt(signedPsbt) {
202
- let signedTx = this.signer.finalizePsbts([signedPsbt])
203
- let txId = await this.transactionBuilder.sendTx(signedTx)
204
- return txId
205
- }
206
-
207
- async sendSignedTx(signedTx) {
208
- let txId = await this.transactionBuilder.sendTx(signedTx)
209
- return txId
210
- }
211
-
212
- async sendMultiSignedPsbt(signedPsbts = []) {
213
- let signedTx = this.signer.finalizePsbts(signedPsbts)
214
- let txId = await this.transactionBuilder.sendTx(signedTx)
215
- return txId
216
- }
217
- }
218
-
219
- module.exports = BitcoinBase
1
+ import TransactionBuilder, {
2
+ BitcoinConnectionInfo,
3
+ } from "./transaction-builder/bitcoin-transaction-builder"
4
+
5
+ import type { ExtendedUtxo, SignerInfo, Target } from "./transaction-builder/transaction-builder"
6
+ import BitcoinSign from "./sign/sign-transaction"
7
+
8
+ import bip39 from "bip39"
9
+ import bip32 from "bip32"
10
+ import { hdWalletPath } from "@teleportdao/configs"
11
+ import { getPubKeyFromPrivateKeyHex } from "./bitcoin-utils"
12
+ import networks from "./utils/networks"
13
+ import { Network, Payment } from "bitcoinjs-lib"
14
+ import { BitcoinInterface } from "./bitcoin-interface"
15
+
16
+ class BitcoinBase {
17
+ network: Network
18
+ hdWalletPath: {
19
+ p2pkh: string
20
+ p2wpkh: string
21
+ "p2sh-p2wpkh": string
22
+ p2sh: string
23
+ p2wsh: string
24
+ "p2sh-p2wsh": string
25
+ }
26
+ transactionBuilder: TransactionBuilder
27
+ btcInterface: BitcoinInterface
28
+ signer: BitcoinSign
29
+ currentAccount?: string
30
+ currentAccountType?: string
31
+ privateKey?: Buffer
32
+ publicKey?: Buffer
33
+ publicKeys?: Buffer[]
34
+ addressObj?: Payment
35
+ bitcoinAddress: string | undefined
36
+ constructor(
37
+ networkName: string,
38
+ connectionInfo: BitcoinConnectionInfo = {
39
+ api: {
40
+ enabled: true,
41
+ provider: "BlockStream",
42
+ },
43
+ },
44
+ ) {
45
+ this.network = networks[networkName]
46
+ this.hdWalletPath = hdWalletPath.bitcoin
47
+
48
+ this.transactionBuilder = new TransactionBuilder(connectionInfo, networkName, this.network)
49
+ this.btcInterface = this.transactionBuilder.btcInterface
50
+
51
+ this.signer = new BitcoinSign(this.network)
52
+
53
+ this.currentAccount = undefined
54
+ this.currentAccountType = undefined
55
+
56
+ this.privateKey = undefined
57
+ this.publicKey = undefined
58
+ // todo multisig
59
+ this.publicKeys = []
60
+ }
61
+
62
+ static createTransactionInputsAndOutputs({
63
+ targets,
64
+ extendedUtxo,
65
+ changeAddress,
66
+ feeRate,
67
+ }: {
68
+ targets: Target[]
69
+ extendedUtxo: ExtendedUtxo[]
70
+ changeAddress: string
71
+ feeRate: number
72
+ fullAmount?: boolean
73
+ }) {
74
+ return TransactionBuilder.helperHandleInputsAndOutputs({
75
+ targets,
76
+ extendedUtxo,
77
+ changeObject: {
78
+ address: changeAddress,
79
+ },
80
+ feeRate,
81
+ })
82
+ }
83
+
84
+ static checkBalanceIsSufficient({
85
+ targets,
86
+ extendedUtxo,
87
+ changeAddress,
88
+ feeRate,
89
+ fullAmount = false,
90
+ }: {
91
+ targets: Target[]
92
+ extendedUtxo: ExtendedUtxo[]
93
+ changeAddress: string
94
+ feeRate: number
95
+ fullAmount?: boolean
96
+ }) {
97
+ try {
98
+ TransactionBuilder.helperHandleInputsAndOutputs({
99
+ targets,
100
+ extendedUtxo,
101
+ changeObject: {
102
+ address: changeAddress,
103
+ },
104
+ feeRate,
105
+ })
106
+ return true
107
+ } catch (err) {
108
+ return false
109
+ }
110
+ }
111
+
112
+ // todo : not completed
113
+ setMultiSigAccount(accountType = "p2sh") {
114
+ /* eslint-disable no-unreachable */
115
+ // todo : not completed
116
+ switch (accountType) {
117
+ // case 'p2sh':
118
+ // this.currentAccount = ''
119
+ // break
120
+ // case 'p2wsh':
121
+ // this.currentAccount = ''
122
+ // break
123
+ // case 'p2sh-p2wsh':
124
+ // this.currentAccount = ''
125
+ // break
126
+ default:
127
+ throw new Error("accountType is incorrect")
128
+ }
129
+ this.currentAccountType = accountType
130
+ }
131
+
132
+ setAccountPrivateKey(privateKeyHex: string) {
133
+ this.privateKey = Buffer.from(privateKeyHex, "hex")
134
+ let publicKey = getPubKeyFromPrivateKeyHex(privateKeyHex, this.network)
135
+ this.publicKey = publicKey
136
+ }
137
+
138
+ setAccountPublicKey(publicKeyHex: string) {
139
+ this.publicKey = Buffer.from(publicKeyHex, "hex")
140
+ }
141
+
142
+ setAccountPrivateKeyByMnemonic({
143
+ mnemonic,
144
+ mnemonicPassword = "",
145
+ index = 0,
146
+ walletNumber = 0,
147
+ addressType = "p2sh-p2wpkh",
148
+ }: {
149
+ mnemonic: string
150
+ mnemonicPassword?: string
151
+ index?: number
152
+ walletNumber?: number
153
+ addressType?: string
154
+ }) {
155
+ if (!bip39.validateMnemonic(mnemonic)) throw new Error("invalid mnemonic")
156
+ const seed = bip39.mnemonicToSeedSync(mnemonic, mnemonicPassword)
157
+ const node = bip32.fromSeed(seed)
158
+
159
+ let basePath = this.hdWalletPath[addressType as keyof typeof this.hdWalletPath]
160
+ if (!basePath) {
161
+ throw new Error("incorrect path or addressType")
162
+ }
163
+ const path = `${basePath}/${walletNumber}`
164
+ const account = node.derivePath(path)
165
+ const userKeyPair = account.derive(index)
166
+ this.setAccountPrivateKey(userKeyPair.privateKey!.toString("hex"))
167
+ return this.setAccount(addressType)
168
+ }
169
+
170
+ setAccount(accountType = "p2pkh") {
171
+ if (!this.publicKey) {
172
+ throw new Error("account not initialized")
173
+ }
174
+ let addressObj = this.transactionBuilder.createAddressObject({
175
+ addressType: accountType,
176
+ publicKey: this.publicKey,
177
+ })
178
+ this.currentAccount = addressObj.address
179
+ this.currentAccountType = accountType
180
+ this.addressObj = addressObj
181
+ this.bitcoinAddress = addressObj.address
182
+ return addressObj.address
183
+ }
184
+
185
+ async getExtendedUtxo(input: SignerInfo) {
186
+ return this.transactionBuilder.getExtendedUtxo(input)
187
+ }
188
+
189
+ async send({
190
+ receiverAddress,
191
+ amount,
192
+ fullAmount = false,
193
+ speed = "normal",
194
+ }: {
195
+ receiverAddress: string
196
+ amount: number
197
+ fullAmount?: boolean
198
+ speed?: "normal" | "fast" | "slow"
199
+ }) {
200
+ if (!this.currentAccount || !this.currentAccountType || !this.publicKey || !this.privateKey) {
201
+ throw new Error("account not initialized")
202
+ }
203
+
204
+ let extendedUtxo = await this.getExtendedUtxo({
205
+ address: this.currentAccount,
206
+ addressType: this.currentAccountType,
207
+ publicKey: this.publicKey.toString("hex"),
208
+ })
209
+ if (amount - +amount.toFixed() !== 0)
210
+ throw new Error("incorrect amount. amount should be in satoshi")
211
+ let feeRate = await this.transactionBuilder._getFeeRate(speed)
212
+ let unsignedTx = await this.transactionBuilder.processUnsignedTransaction({
213
+ extendedUtxo,
214
+ targets: [
215
+ {
216
+ address: receiverAddress,
217
+ value: amount,
218
+ },
219
+ ],
220
+ changeAddress: this.currentAccount,
221
+ feeRate,
222
+ fullAmount,
223
+ })
224
+ let signedPsbt = await this.signer.signPsbt(unsignedTx, this.privateKey)
225
+ let signedTx = this.signer.finalizePsbts([signedPsbt])
226
+ let txId = await this.transactionBuilder.sendTx(signedTx)
227
+ return txId
228
+ }
229
+
230
+ async sendSignedPsbt(signedPsbt: string) {
231
+ let signedTx = this.signer.finalizePsbts([signedPsbt])
232
+ let txId = await this.transactionBuilder.sendTx(signedTx)
233
+ return txId
234
+ }
235
+
236
+ async sendSignedTx(signedTx: string) {
237
+ let txId = await this.transactionBuilder.sendTx(signedTx)
238
+ return txId
239
+ }
240
+
241
+ async sendMultiSignedPsbt(signedPsbts: string[] = []) {
242
+ let signedTx = this.signer.finalizePsbts(signedPsbts)
243
+ let txId = await this.transactionBuilder.sendTx(signedTx)
244
+ return txId
245
+ }
246
+ }
247
+
248
+ export { BitcoinBase }
@@ -1,53 +1,59 @@
1
- const networks = require("./utils/networks")
2
- const {
3
- createAddressObjectByHash,
4
- createAddressObjectByAddress,
5
- createAddressObjectByPublicKey,
6
- createAddressObjectByScript,
7
- } = require("./bitcoin-utils")
8
-
9
- class BitcoinInterfaceUtils {
10
- constructor(networkName) {
11
- this.testnet = networkName.includes("_testnet")
12
- this.network = networks[networkName]
13
- }
14
-
15
- convertHashToAddress(hashHex, addressType) {
16
- let addressObj = createAddressObjectByHash(
17
- { addressType, hash: Buffer.from(hashHex, "hex") },
18
- this.network,
19
- )
20
- if (!addressObj.address) throw new Error("incorrect input")
21
- return addressObj.address
22
- }
23
-
24
- convertScriptToAddress(scriptHex, addressType) {
25
- let addressObj = createAddressObjectByScript(
26
- { addressType, script: Buffer.from(scriptHex, "hex") },
27
- this.network,
28
- )
29
- if (!addressObj.address) throw new Error("incorrect input")
30
- return addressObj.address
31
- }
32
-
33
- convertAddressToScript(address) {
34
- let { addressObject, addressType } = createAddressObjectByAddress(address, this.network)
35
- return {
36
- script: addressObject.output,
37
- hash: addressObject.hash,
38
- addressType,
39
- }
40
- }
41
-
42
- convertAddressToObject(address) {
43
- let addObj = createAddressObjectByAddress(address, this.network)
44
- return addObj
45
- }
46
-
47
- createAddressObjectByPublicKey(address, addressType) {
48
- let addObj = createAddressObjectByPublicKey({ address, addressType }, this.network)
49
- return addObj
50
- }
51
- }
52
-
53
- module.exports = BitcoinInterfaceUtils
1
+ import networks from "./utils/networks"
2
+ import {
3
+ createAddressObjectByHash,
4
+ createAddressObjectByAddress,
5
+ createAddressObjectByPublicKey,
6
+ createAddressObjectByScript,
7
+ } from "./bitcoin-utils"
8
+ import type { Network } from "bitcoinjs-lib"
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