@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,314 +1,314 @@
1
- import * as bip39 from "bip39"
2
- import { hdWalletPath } from "@teleportdao/configs"
3
- import { Network, Payment } from "bitcoinjs-lib"
4
- import BIP32Factory from "bip32"
5
- import ecc from "@bitcoinerlab/secp256k1"
6
- import { BitcoinTransactionBuilder } from "./transaction-builder"
7
- import type { BitcoinConnectionInfo } from "./type"
8
-
9
- import type { ExtendedUtxo, SignerInfo, Target } from "./transaction-builder/transaction-builder"
10
- import BitcoinSign from "./sign/sign-transaction"
11
-
12
- import { getPubKeyFromPrivateKeyHex } from "./bitcoin-utils"
13
- import networks from "./utils/networks"
14
- import { BitcoinInterface } from "./bitcoin-interface"
15
-
16
- const bip32 = BIP32Factory(ecc)
17
-
18
- export class BitcoinBaseWallet {
19
- network: Network
20
- hdWalletPath: {
21
- p2pkh: string
22
- p2wpkh: string
23
- "p2sh-p2wpkh": string
24
- p2sh: string
25
- p2wsh: string
26
- "p2sh-p2wsh": string
27
- p2tr: string
28
- }
29
- transactionBuilder: BitcoinTransactionBuilder
30
- btcInterface: BitcoinInterface
31
- signer: BitcoinSign
32
- currentAccount?: string
33
- currentAccountType?: string
34
- privateKey?: Buffer
35
- publicKey?: Buffer
36
- publicKeys?: Buffer[]
37
- addressObj?: Payment
38
- bitcoinAddress: string | undefined
39
- constructor(
40
- networkName: string,
41
- connectionInfo: BitcoinConnectionInfo = {
42
- api: {
43
- provider: "BlockStream",
44
- },
45
- },
46
- ) {
47
- this.network = networks[networkName]
48
- this.hdWalletPath = hdWalletPath.bitcoin
49
-
50
- this.transactionBuilder = new BitcoinTransactionBuilder(
51
- connectionInfo,
52
- networkName,
53
- this.network,
54
- )
55
- this.btcInterface = this.transactionBuilder.btcInterface
56
-
57
- this.signer = new BitcoinSign(this.network)
58
-
59
- this.currentAccount = undefined
60
- this.currentAccountType = undefined
61
-
62
- this.privateKey = undefined
63
- this.publicKey = undefined
64
- // todo multisig
65
- this.publicKeys = []
66
- }
67
-
68
- get signerInfo() {
69
- return this.privateKey
70
- ? {
71
- address: this.bitcoinAddress!,
72
- publicKey: this.publicKey!.toString("hex"),
73
- addressType: this.currentAccountType!,
74
- }
75
- : undefined
76
- }
77
-
78
- createTransactionInputsAndOutputs({
79
- targets,
80
- extendedUtxo,
81
- changeAddress,
82
- feeRate,
83
- }: {
84
- targets: Target[]
85
- extendedUtxo: ExtendedUtxo[]
86
- changeAddress: string
87
- feeRate: number
88
- fullAmount?: boolean
89
- }) {
90
- return this.transactionBuilder.helperHandleInputsAndOutputs({
91
- targets,
92
- extendedUtxo,
93
- changeObject: {
94
- address: changeAddress,
95
- },
96
- feeRate,
97
- })
98
- }
99
-
100
- checkBalanceIsSufficient({
101
- targets,
102
- extendedUtxo,
103
- changeAddress,
104
- feeRate,
105
- fullAmount = false,
106
- }: {
107
- targets: Target[]
108
- extendedUtxo: ExtendedUtxo[]
109
- changeAddress: string
110
- feeRate: number
111
- fullAmount?: boolean
112
- }) {
113
- try {
114
- this.transactionBuilder.helperHandleInputsAndOutputs({
115
- targets,
116
- extendedUtxo,
117
- changeObject: {
118
- address: changeAddress,
119
- },
120
- feeRate,
121
- })
122
- return true
123
- } catch (err) {
124
- return false
125
- }
126
- }
127
-
128
- // todo : not completed
129
- setMultiSigAccount(accountType = "p2sh") {
130
- throw new Error("not supported yet")
131
-
132
- /* eslint-disable no-unreachable */
133
- // todo : not completed
134
- switch (accountType) {
135
- // case 'p2sh':
136
- // this.currentAccount = ''
137
- // break
138
- // case 'p2wsh':
139
- // this.currentAccount = ''
140
- // break
141
- // case 'p2sh-p2wsh':
142
- // this.currentAccount = ''
143
- // break
144
- default:
145
- throw new Error("accountType is incorrect")
146
- }
147
- this.currentAccountType = accountType
148
- }
149
-
150
- setAccountPrivateKey(privateKeyHex: string) {
151
- this.privateKey = Buffer.from(privateKeyHex, "hex")
152
- let publicKey = getPubKeyFromPrivateKeyHex(privateKeyHex, this.network)
153
- this.publicKey = publicKey
154
- }
155
-
156
- setAccountPrivateKeyByMnemonic({
157
- mnemonic,
158
- mnemonicPassword = "",
159
- index = 0,
160
- walletNumber = 0,
161
- addressType = "p2sh-p2wpkh",
162
- }: {
163
- mnemonic: string
164
- mnemonicPassword?: string
165
- index?: number
166
- walletNumber?: number
167
- addressType?: string
168
- }) {
169
- if (!bip39.validateMnemonic(mnemonic)) throw new Error("invalid mnemonic")
170
- const seed = bip39.mnemonicToSeedSync(mnemonic, mnemonicPassword)
171
- const node = bip32.fromSeed(seed)
172
-
173
- let basePath = this.hdWalletPath[addressType as keyof typeof this.hdWalletPath]
174
- if (!basePath) {
175
- throw new Error("incorrect path or addressType")
176
- }
177
- const path = `${basePath}/${walletNumber}`
178
- const account = node.derivePath(path)
179
- const userKeyPair = account.derive(index)
180
- this.setAccountPrivateKey(userKeyPair.privateKey!.toString("hex"))
181
- return this.setAccount(addressType)
182
- }
183
-
184
- setAccountPublicKey(publicKeyHex: string) {
185
- this.publicKey = Buffer.from(publicKeyHex, "hex")
186
- }
187
-
188
- setAccount(accountType = "p2pkh") {
189
- if (!this.publicKey) {
190
- throw new Error("account not initialized")
191
- }
192
- let addressObj = this.transactionBuilder.createAddressObject({
193
- addressType: accountType,
194
- publicKey: this.publicKey,
195
- })
196
- this.currentAccount = addressObj.address
197
- this.currentAccountType = accountType
198
- this.addressObj = addressObj
199
- this.bitcoinAddress = addressObj.address
200
- return addressObj.address
201
- }
202
-
203
- //
204
-
205
- async getExtendedUtxo(input: SignerInfo) {
206
- return this.transactionBuilder.getExtendedUtxo(input)
207
- }
208
-
209
- async send({
210
- receiverAddress,
211
- amount,
212
- fullAmount = false,
213
- speed = "normal",
214
- }: {
215
- receiverAddress: string
216
- amount: number
217
- fullAmount?: boolean
218
- speed?: "normal" | "fast" | "slow"
219
- }) {
220
- if (!this.currentAccount || !this.currentAccountType || !this.publicKey || !this.privateKey) {
221
- throw new Error("account not initialized")
222
- }
223
-
224
- let extendedUtxo = await this.getExtendedUtxo({
225
- address: this.currentAccount,
226
- addressType: this.currentAccountType,
227
- publicKey: this.publicKey.toString("hex"),
228
- })
229
- if (amount - +amount.toFixed() !== 0)
230
- throw new Error("incorrect amount. amount should be in satoshi")
231
- let feeRate = await this.transactionBuilder._getFeeRate(speed)
232
- let unsignedTx = await this.transactionBuilder.processUnsignedTransaction({
233
- extendedUtxo,
234
- targets: [
235
- {
236
- address: receiverAddress,
237
- value: amount,
238
- },
239
- ],
240
- changeAddress: this.currentAccount,
241
- feeRate,
242
- fullAmount,
243
- })
244
- let signedPsbt = await this.signer.signPsbt(unsignedTx, this.privateKey)
245
- let signedTx = this.signer.finalizePsbts([signedPsbt])
246
- let txId = await this.transactionBuilder.sendTx(signedTx)
247
- return txId
248
- }
249
-
250
- async sendSignedPsbt(signedPsbt: string) {
251
- let signedTx = this.signer.finalizePsbts([signedPsbt])
252
- let txId = await this.transactionBuilder.sendTx(signedTx)
253
- return txId
254
- }
255
-
256
- async sendSignedTx(signedTx: string) {
257
- let txId = await this.transactionBuilder.sendTx(signedTx)
258
- return txId
259
- }
260
-
261
- async sendMultiSignedPsbt(signedPsbts: string[] = []) {
262
- let signedTx = this.signer.finalizePsbts(signedPsbts)
263
- let txId = await this.transactionBuilder.sendTx(signedTx)
264
- return txId
265
- }
266
-
267
- async increaseTransactionFeeUnsignedPsbt(
268
- txId: string,
269
- signerInfos: SignerInfo[],
270
- extraExtendedUtxo: ExtendedUtxo[],
271
- changeAddress: string,
272
- staticFeeRate?: number,
273
- ) {
274
- let transaction = await this.btcInterface.apiProvider.getTransaction(txId)
275
-
276
- let extendedUtxo = transaction.vin.map((vi) => ({
277
- signerInfo: signerInfos.find((s) => s.address === vi.address)!,
278
- hash: vi.txId,
279
- value: +vi.value,
280
- index: vi.index,
281
- }))
282
-
283
- if (extendedUtxo.find((x) => !x.signerInfo?.address)) {
284
- throw new Error("signerInfo not match")
285
- }
286
-
287
- let changeIndex = transaction.vout.findIndex((vo) =>
288
- transaction.vin.find((vi) => vo.address === vi.address || vo.address === changeAddress),
289
- )
290
-
291
- const feeRate = staticFeeRate || (await this.transactionBuilder._getFeeRate("fast"))
292
-
293
- let targets = transaction.vout
294
- .filter((_, index) => index !== changeIndex)
295
- .map((vo) =>
296
- vo.address
297
- ? {
298
- address: vo.address,
299
- value: vo.value,
300
- }
301
- : {
302
- script: Buffer.from(vo.script, "hex"),
303
- value: vo.value,
304
- },
305
- )
306
- return this.transactionBuilder.processUnsignedTransaction({
307
- extendedUtxo: [...extendedUtxo, ...extraExtendedUtxo],
308
- targets,
309
- feeRate,
310
- changeAddress: changeIndex >= 0 ? transaction.vout[changeIndex].address : changeAddress,
311
- selectType: "inOrder",
312
- })
313
- }
314
- }
1
+ import * as bip39 from "bip39"
2
+ import { hdWalletPath } from "@teleportdao/configs"
3
+ import { Network, Payment } from "bitcoinjs-lib"
4
+ import BIP32Factory from "bip32"
5
+ import ecc from "@bitcoinerlab/secp256k1"
6
+ import { BitcoinTransactionBuilder } from "./transaction-builder"
7
+ import type { BitcoinConnectionInfo } from "./type"
8
+
9
+ import type { ExtendedUtxo, SignerInfo, Target } from "./transaction-builder/transaction-builder"
10
+ import BitcoinSign from "./sign/sign-transaction"
11
+
12
+ import { getPubKeyFromPrivateKeyHex } from "./bitcoin-utils"
13
+ import networks from "./utils/networks"
14
+ import { BitcoinInterface } from "./bitcoin-interface"
15
+
16
+ const bip32 = BIP32Factory(ecc)
17
+
18
+ export class BitcoinBaseWallet {
19
+ network: Network
20
+ hdWalletPath: {
21
+ p2pkh: string
22
+ p2wpkh: string
23
+ "p2sh-p2wpkh": string
24
+ p2sh: string
25
+ p2wsh: string
26
+ "p2sh-p2wsh": string
27
+ p2tr: string
28
+ }
29
+ transactionBuilder: BitcoinTransactionBuilder
30
+ btcInterface: BitcoinInterface
31
+ signer: BitcoinSign
32
+ currentAccount?: string
33
+ currentAccountType?: string
34
+ privateKey?: Buffer
35
+ publicKey?: Buffer
36
+ publicKeys?: Buffer[]
37
+ addressObj?: Payment
38
+ bitcoinAddress: string | undefined
39
+ constructor(
40
+ networkName: string,
41
+ connectionInfo: BitcoinConnectionInfo = {
42
+ api: {
43
+ provider: "BlockStream",
44
+ },
45
+ },
46
+ ) {
47
+ this.network = networks[networkName]
48
+ this.hdWalletPath = hdWalletPath.bitcoin
49
+
50
+ this.transactionBuilder = new BitcoinTransactionBuilder(
51
+ connectionInfo,
52
+ networkName,
53
+ this.network,
54
+ )
55
+ this.btcInterface = this.transactionBuilder.btcInterface
56
+
57
+ this.signer = new BitcoinSign(this.network)
58
+
59
+ this.currentAccount = undefined
60
+ this.currentAccountType = undefined
61
+
62
+ this.privateKey = undefined
63
+ this.publicKey = undefined
64
+ // todo multisig
65
+ this.publicKeys = []
66
+ }
67
+
68
+ get signerInfo() {
69
+ return this.privateKey
70
+ ? {
71
+ address: this.bitcoinAddress!,
72
+ publicKey: this.publicKey!.toString("hex"),
73
+ addressType: this.currentAccountType!,
74
+ }
75
+ : undefined
76
+ }
77
+
78
+ createTransactionInputsAndOutputs({
79
+ targets,
80
+ extendedUtxo,
81
+ changeAddress,
82
+ feeRate,
83
+ }: {
84
+ targets: Target[]
85
+ extendedUtxo: ExtendedUtxo[]
86
+ changeAddress: string
87
+ feeRate: number
88
+ fullAmount?: boolean
89
+ }) {
90
+ return this.transactionBuilder.helperHandleInputsAndOutputs({
91
+ targets,
92
+ extendedUtxo,
93
+ changeObject: {
94
+ address: changeAddress,
95
+ },
96
+ feeRate,
97
+ })
98
+ }
99
+
100
+ checkBalanceIsSufficient({
101
+ targets,
102
+ extendedUtxo,
103
+ changeAddress,
104
+ feeRate,
105
+ fullAmount = false,
106
+ }: {
107
+ targets: Target[]
108
+ extendedUtxo: ExtendedUtxo[]
109
+ changeAddress: string
110
+ feeRate: number
111
+ fullAmount?: boolean
112
+ }) {
113
+ try {
114
+ this.transactionBuilder.helperHandleInputsAndOutputs({
115
+ targets,
116
+ extendedUtxo,
117
+ changeObject: {
118
+ address: changeAddress,
119
+ },
120
+ feeRate,
121
+ })
122
+ return true
123
+ } catch (err) {
124
+ return false
125
+ }
126
+ }
127
+
128
+ // todo : not completed
129
+ setMultiSigAccount(accountType = "p2sh") {
130
+ throw new Error("not supported yet")
131
+
132
+ /* eslint-disable no-unreachable */
133
+ // todo : not completed
134
+ switch (accountType) {
135
+ // case 'p2sh':
136
+ // this.currentAccount = ''
137
+ // break
138
+ // case 'p2wsh':
139
+ // this.currentAccount = ''
140
+ // break
141
+ // case 'p2sh-p2wsh':
142
+ // this.currentAccount = ''
143
+ // break
144
+ default:
145
+ throw new Error("accountType is incorrect")
146
+ }
147
+ this.currentAccountType = accountType
148
+ }
149
+
150
+ setAccountPrivateKey(privateKeyHex: string) {
151
+ this.privateKey = Buffer.from(privateKeyHex, "hex")
152
+ let publicKey = getPubKeyFromPrivateKeyHex(privateKeyHex, this.network)
153
+ this.publicKey = publicKey
154
+ }
155
+
156
+ setAccountPrivateKeyByMnemonic({
157
+ mnemonic,
158
+ mnemonicPassword = "",
159
+ index = 0,
160
+ walletNumber = 0,
161
+ addressType = "p2sh-p2wpkh",
162
+ }: {
163
+ mnemonic: string
164
+ mnemonicPassword?: string
165
+ index?: number
166
+ walletNumber?: number
167
+ addressType?: string
168
+ }) {
169
+ if (!bip39.validateMnemonic(mnemonic)) throw new Error("invalid mnemonic")
170
+ const seed = bip39.mnemonicToSeedSync(mnemonic, mnemonicPassword)
171
+ const node = bip32.fromSeed(seed)
172
+
173
+ let basePath = this.hdWalletPath[addressType as keyof typeof this.hdWalletPath]
174
+ if (!basePath) {
175
+ throw new Error("incorrect path or addressType")
176
+ }
177
+ const path = `${basePath}/${walletNumber}`
178
+ const account = node.derivePath(path)
179
+ const userKeyPair = account.derive(index)
180
+ this.setAccountPrivateKey(userKeyPair.privateKey!.toString("hex"))
181
+ return this.setAccount(addressType)
182
+ }
183
+
184
+ setAccountPublicKey(publicKeyHex: string) {
185
+ this.publicKey = Buffer.from(publicKeyHex, "hex")
186
+ }
187
+
188
+ setAccount(accountType = "p2pkh") {
189
+ if (!this.publicKey) {
190
+ throw new Error("account not initialized")
191
+ }
192
+ let addressObj = this.transactionBuilder.createAddressObject({
193
+ addressType: accountType,
194
+ publicKey: this.publicKey,
195
+ })
196
+ this.currentAccount = addressObj.address
197
+ this.currentAccountType = accountType
198
+ this.addressObj = addressObj
199
+ this.bitcoinAddress = addressObj.address
200
+ return addressObj.address
201
+ }
202
+
203
+ //
204
+
205
+ async getExtendedUtxo(input: SignerInfo) {
206
+ return this.transactionBuilder.getExtendedUtxo(input)
207
+ }
208
+
209
+ async send({
210
+ receiverAddress,
211
+ amount,
212
+ fullAmount = false,
213
+ speed = "normal",
214
+ }: {
215
+ receiverAddress: string
216
+ amount: number
217
+ fullAmount?: boolean
218
+ speed?: "normal" | "fast" | "slow"
219
+ }) {
220
+ if (!this.currentAccount || !this.currentAccountType || !this.publicKey || !this.privateKey) {
221
+ throw new Error("account not initialized")
222
+ }
223
+
224
+ let extendedUtxo = await this.getExtendedUtxo({
225
+ address: this.currentAccount,
226
+ addressType: this.currentAccountType,
227
+ publicKey: this.publicKey.toString("hex"),
228
+ })
229
+ if (amount - +amount.toFixed() !== 0)
230
+ throw new Error("incorrect amount. amount should be in satoshi")
231
+ let feeRate = await this.transactionBuilder._getFeeRate(speed)
232
+ let unsignedTx = await this.transactionBuilder.processUnsignedTransaction({
233
+ extendedUtxo,
234
+ targets: [
235
+ {
236
+ address: receiverAddress,
237
+ value: amount,
238
+ },
239
+ ],
240
+ changeAddress: this.currentAccount,
241
+ feeRate,
242
+ fullAmount,
243
+ })
244
+ let signedPsbt = await this.signer.signPsbt(unsignedTx, this.privateKey)
245
+ let signedTx = this.signer.finalizePsbts([signedPsbt])
246
+ let txId = await this.transactionBuilder.sendTx(signedTx)
247
+ return txId
248
+ }
249
+
250
+ async sendSignedPsbt(signedPsbt: string) {
251
+ let signedTx = this.signer.finalizePsbts([signedPsbt])
252
+ let txId = await this.transactionBuilder.sendTx(signedTx)
253
+ return txId
254
+ }
255
+
256
+ async sendSignedTx(signedTx: string) {
257
+ let txId = await this.transactionBuilder.sendTx(signedTx)
258
+ return txId
259
+ }
260
+
261
+ async sendMultiSignedPsbt(signedPsbts: string[] = []) {
262
+ let signedTx = this.signer.finalizePsbts(signedPsbts)
263
+ let txId = await this.transactionBuilder.sendTx(signedTx)
264
+ return txId
265
+ }
266
+
267
+ async increaseTransactionFeeUnsignedPsbt(
268
+ txId: string,
269
+ signerInfos: SignerInfo[],
270
+ extraExtendedUtxo: ExtendedUtxo[],
271
+ changeAddress: string,
272
+ staticFeeRate?: number,
273
+ ) {
274
+ let transaction = await this.btcInterface.apiProvider.getTransaction(txId)
275
+
276
+ let extendedUtxo = transaction.vin.map((vi) => ({
277
+ signerInfo: signerInfos.find((s) => s.address === vi.address)!,
278
+ hash: vi.txId,
279
+ value: +vi.value,
280
+ index: vi.index,
281
+ }))
282
+
283
+ if (extendedUtxo.find((x) => !x.signerInfo?.address)) {
284
+ throw new Error("signerInfo not match")
285
+ }
286
+
287
+ let changeIndex = transaction.vout.findIndex((vo) =>
288
+ transaction.vin.find((vi) => vo.address === vi.address || vo.address === changeAddress),
289
+ )
290
+
291
+ const feeRate = staticFeeRate || (await this.transactionBuilder._getFeeRate("fast"))
292
+
293
+ let targets = transaction.vout
294
+ .filter((_, index) => index !== changeIndex)
295
+ .map((vo) =>
296
+ vo.address
297
+ ? {
298
+ address: vo.address,
299
+ value: vo.value,
300
+ }
301
+ : {
302
+ script: Buffer.from(vo.script, "hex"),
303
+ value: vo.value,
304
+ },
305
+ )
306
+ return this.transactionBuilder.processUnsignedTransaction({
307
+ extendedUtxo: [...extendedUtxo, ...extraExtendedUtxo],
308
+ targets,
309
+ feeRate,
310
+ changeAddress: changeIndex >= 0 ? transaction.vout[changeIndex].address : changeAddress,
311
+ selectType: "inOrder",
312
+ })
313
+ }
314
+ }