@teleportdao/bitcoin 1.8.5 → 1.8.7
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.
- package/dist/bitcoin-interface.d.ts +1 -1
- package/dist/bitcoin-interface.d.ts.map +1 -1
- package/dist/bitcoin-interface.js +2 -4
- package/dist/bitcoin-interface.js.map +1 -1
- package/dist/helper/brc20-helper.d.ts +1 -1
- package/dist/helper/brc20-helper.js +5 -5
- package/dist/helper/brc20-helper.js.map +1 -1
- package/dist/ordinal-wallet.d.ts +19 -17
- package/dist/ordinal-wallet.d.ts.map +1 -1
- package/dist/ordinal-wallet.js +38 -39
- package/dist/ordinal-wallet.js.map +1 -1
- package/package.json +4 -4
- package/src/bitcoin-interface.ts +2 -4
- package/src/helper/brc20-helper.ts +7 -7
- package/src/ordinal-wallet.ts +53 -43
- package/dist/bitcoin-base.d.ts +0 -93
- package/dist/bitcoin-base.d.ts.map +0 -1
- package/dist/bitcoin-base.js +0 -236
- package/dist/bitcoin-base.js.map +0 -1
- package/dist/helper/burn-request-helper.d.ts +0 -7
- package/dist/helper/burn-request-helper.d.ts.map +0 -1
- package/dist/helper/burn-request-helper.js +0 -26
- package/dist/helper/burn-request-helper.js.map +0 -1
- package/dist/helper/teleport-request-helper.d.ts +0 -47
- package/dist/helper/teleport-request-helper.d.ts.map +0 -1
- package/dist/helper/teleport-request-helper.js +0 -146
- package/dist/helper/teleport-request-helper.js.map +0 -1
- package/dist/teleport-dao-payments.d.ts +0 -76
- package/dist/teleport-dao-payments.d.ts.map +0 -1
- package/dist/teleport-dao-payments.js +0 -217
- package/dist/teleport-dao-payments.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teleportdao/bitcoin",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.7",
|
|
4
4
|
"description": "teleswap bitcoin package",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
"license": "ISC",
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@bitcoinerlab/secp256k1": "^1.0.5",
|
|
17
|
-
"@teleportdao/configs": "^1.8.
|
|
18
|
-
"@teleportdao/providers": "^1.8.
|
|
17
|
+
"@teleportdao/configs": "^1.8.7",
|
|
18
|
+
"@teleportdao/providers": "^1.8.7",
|
|
19
19
|
"axios": "^0.27.2",
|
|
20
20
|
"bignumber.js": "^9.1.1",
|
|
21
21
|
"bip32": "^4.0.0",
|
|
@@ -31,5 +31,5 @@
|
|
|
31
31
|
"publishConfig": {
|
|
32
32
|
"access": "public"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "a88e25610122c7d7caeed55ebcf17c848d428326"
|
|
35
35
|
}
|
package/src/bitcoin-interface.ts
CHANGED
|
@@ -177,10 +177,8 @@ export class BitcoinInterface extends BitcoinInterfaceUtils {
|
|
|
177
177
|
}
|
|
178
178
|
|
|
179
179
|
async getBalance(address: string) {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
}
|
|
183
|
-
return this.apiProvider.getBalance(address)
|
|
180
|
+
let utxos = await this.utxoProvider.getUtxos(address)
|
|
181
|
+
return utxos.reduce((a, tx) => a + Number(tx.value), 0)
|
|
184
182
|
}
|
|
185
183
|
|
|
186
184
|
// rpc
|
|
@@ -12,7 +12,7 @@ export type WrapOpReturn = {
|
|
|
12
12
|
thirdPartyId?: number
|
|
13
13
|
}
|
|
14
14
|
export type WrapOpReturnAndType = WrapOpReturn & {
|
|
15
|
-
requestType: "
|
|
15
|
+
requestType: "Wrap" | "WrapAndSwap"
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
const brc20WrapRequests = brc20.requestAppId
|
|
@@ -49,15 +49,15 @@ export function generateBrc2OpReturn({
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
export function parseBrc20OpReturn(data: string) {
|
|
52
|
-
let parsedData:
|
|
52
|
+
let parsedData: Partial<WrapOpReturnAndType> = {}
|
|
53
53
|
parsedData.chainId = Number(`0x${data.slice(0, 4)}`) // 2 bytes
|
|
54
54
|
parsedData.appId = Number(`0x${data.slice(4, 6)}`) // 1 bytes
|
|
55
55
|
parsedData.brc20TokenId = Number(`0x${data.slice(6, 10)}`) // 2 bytes
|
|
56
56
|
parsedData.inputAmount = new BigNumber(`0x${data.slice(10, 36)}`).toFixed(0) // 11 bytes
|
|
57
57
|
parsedData.recipientAddress = `0x${data.slice(36, 76)}` // 20 bytes
|
|
58
|
-
parsedData.thirdPartyId = `0x${data.slice(76, 78)}` // 20 bytes
|
|
58
|
+
parsedData.thirdPartyId = Number(`0x${data.slice(76, 78)}`) // 20 bytes
|
|
59
59
|
if (data.length === 78) {
|
|
60
|
-
parsedData.requestType = "
|
|
60
|
+
parsedData.requestType = "Wrap"
|
|
61
61
|
return {
|
|
62
62
|
status: true,
|
|
63
63
|
data: parsedData as WrapOpReturnAndType,
|
|
@@ -66,7 +66,7 @@ export function parseBrc20OpReturn(data: string) {
|
|
|
66
66
|
parsedData.outputToken = `0x${data.slice(78, 118)}` // 20 bytes
|
|
67
67
|
parsedData.outputAmount = new BigNumber(`0x${data.slice(118, 144)}`).toFixed(0) // 20 bytes
|
|
68
68
|
if (data.length === 144) {
|
|
69
|
-
parsedData.requestType = "
|
|
69
|
+
parsedData.requestType = "WrapAndSwap"
|
|
70
70
|
return {
|
|
71
71
|
status: true,
|
|
72
72
|
data: parsedData as WrapOpReturnAndType,
|
|
@@ -105,8 +105,8 @@ function parseBrc20RawRequest(opReturnData: string): {
|
|
|
105
105
|
)
|
|
106
106
|
|
|
107
107
|
switch (requestType) {
|
|
108
|
-
case "
|
|
109
|
-
case "
|
|
108
|
+
case "Wrap":
|
|
109
|
+
case "WrapAndSwap":
|
|
110
110
|
return parseBrc20OpReturn(data)
|
|
111
111
|
default:
|
|
112
112
|
return {
|
package/src/ordinal-wallet.ts
CHANGED
|
@@ -1,19 +1,16 @@
|
|
|
1
1
|
import BigNumber from "bignumber.js"
|
|
2
2
|
import { bitcoin as bitcoinProviders } from "@teleportdao/providers"
|
|
3
|
-
import {
|
|
4
|
-
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
5
|
-
import { BitcoinConnectionInfo } from "./type"
|
|
6
|
-
import type { SignerInfo, ChangeTarget, Target, ExtendedUtxo } from "./transaction-builder"
|
|
7
|
-
|
|
8
|
-
import { OrdinalTransactionBuilder } from "./transaction-builder"
|
|
3
|
+
import { OrdinalTransactionBuilder } from "./transaction-builder/ordinal-transaction-builder"
|
|
9
4
|
import BitcoinSign from "./sign/sign-transaction"
|
|
10
5
|
//
|
|
11
6
|
import { BitcoinInterfaceOrdinal } from "./bitcoin-interface-ordinal"
|
|
12
|
-
|
|
13
7
|
import { generateBrc2OpReturn } from "./helper/brc20-helper"
|
|
14
|
-
import { sleep } from "./utils/tools"
|
|
8
|
+
import { runWithRetries, sleep } from "./utils/tools"
|
|
9
|
+
import { BitcoinConnectionInfo } from "./type"
|
|
10
|
+
import { ChangeTarget, ExtendedUtxo, SignerInfo, Target } from "./transaction-builder"
|
|
11
|
+
import { BitcoinBaseWallet } from "./bitcoin-wallet-base"
|
|
15
12
|
|
|
16
|
-
|
|
13
|
+
class OrdinalWallet extends BitcoinBaseWallet {
|
|
17
14
|
unisat: bitcoinProviders.UniSat
|
|
18
15
|
transactionBuilder: OrdinalTransactionBuilder
|
|
19
16
|
btcInterface: BitcoinInterfaceOrdinal
|
|
@@ -37,19 +34,11 @@ export class OrdinalWallet extends BitcoinBaseWallet {
|
|
|
37
34
|
this.unisat = this.btcInterface.unisat
|
|
38
35
|
}
|
|
39
36
|
|
|
40
|
-
async sendSignedPsbtWithRetry(signedPsbt: string, {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
return txId
|
|
46
|
-
} catch (e: any) {
|
|
47
|
-
console.log(e.message)
|
|
48
|
-
await sleep(sleepTime + count * 5000)
|
|
49
|
-
count += 1
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
throw new Error("failed to send transaction")
|
|
37
|
+
async sendSignedPsbtWithRetry(signedPsbt: string, { maxTries = 5, retrySleep = 5000 } = {}) {
|
|
38
|
+
return runWithRetries(() => this.sendSignedPsbt(signedPsbt), {
|
|
39
|
+
retrySleep,
|
|
40
|
+
maxTries,
|
|
41
|
+
})
|
|
53
42
|
}
|
|
54
43
|
|
|
55
44
|
static deployBRC20Data(tickName: string, max: number | string, limit: number | string) {
|
|
@@ -68,6 +57,7 @@ export class OrdinalWallet extends BitcoinBaseWallet {
|
|
|
68
57
|
}
|
|
69
58
|
|
|
70
59
|
static mintBRC20Data(tickName: string, amount: string | number) {
|
|
60
|
+
if (BigNumber(amount).isLessThanOrEqualTo(0)) throw new Error("amount should be greater than 0")
|
|
71
61
|
let data = {
|
|
72
62
|
p: "brc-20",
|
|
73
63
|
op: "mint",
|
|
@@ -82,6 +72,7 @@ export class OrdinalWallet extends BitcoinBaseWallet {
|
|
|
82
72
|
}
|
|
83
73
|
|
|
84
74
|
static transferBRC20Data(tickName: string, amount: string | number) {
|
|
75
|
+
if (BigNumber(amount).isLessThanOrEqualTo(0)) throw new Error("amount should be greater than 0")
|
|
85
76
|
let data = {
|
|
86
77
|
p: "brc-20",
|
|
87
78
|
op: "transfer",
|
|
@@ -177,10 +168,12 @@ export class OrdinalWallet extends BitcoinBaseWallet {
|
|
|
177
168
|
type: string
|
|
178
169
|
},
|
|
179
170
|
signer: SignerInfo,
|
|
171
|
+
ordinalSigner?: SignerInfo,
|
|
180
172
|
extendedUtxo?: ExtendedUtxo[],
|
|
181
173
|
staticFeeRate?: number,
|
|
182
174
|
) {
|
|
183
|
-
const
|
|
175
|
+
const ordinalSignerPublicKey = ordinalSigner?.publicKey || signer.publicKey
|
|
176
|
+
const publicKey = Buffer.from(ordinalSignerPublicKey, "hex")
|
|
184
177
|
let transferOrdinal = this.transactionBuilder.createOrdinalAddress(file, publicKey)
|
|
185
178
|
const leafScript = transferOrdinal.redeem.output
|
|
186
179
|
const { ordinalAddress } = transferOrdinal
|
|
@@ -215,11 +208,19 @@ export class OrdinalWallet extends BitcoinBaseWallet {
|
|
|
215
208
|
type: string
|
|
216
209
|
},
|
|
217
210
|
signer: SignerInfo,
|
|
211
|
+
ordinalSigner?: SignerInfo,
|
|
218
212
|
extendedUtxo?: ExtendedUtxo[],
|
|
219
213
|
staticFeeRate?: number,
|
|
220
214
|
) {
|
|
215
|
+
const receiverAddress = ordinalSigner?.address || signer.address
|
|
221
216
|
const { inscribeDepositUnsignedInfo, transferOrdinal } =
|
|
222
|
-
await this.inscribeOrdinalDepositUnsigned(
|
|
217
|
+
await this.inscribeOrdinalDepositUnsigned(
|
|
218
|
+
file,
|
|
219
|
+
signer,
|
|
220
|
+
ordinalSigner,
|
|
221
|
+
extendedUtxo,
|
|
222
|
+
staticFeeRate,
|
|
223
|
+
)
|
|
223
224
|
const { ordinalAddress } = transferOrdinal
|
|
224
225
|
let ordinalAmount = 600
|
|
225
226
|
let inscribeDeposit: {
|
|
@@ -234,7 +235,7 @@ export class OrdinalWallet extends BitcoinBaseWallet {
|
|
|
234
235
|
let inscribeUnsignedInfo = this.transactionBuilder.createInscribeUnsignedTx(
|
|
235
236
|
transferOrdinal,
|
|
236
237
|
inscribeDeposit,
|
|
237
|
-
|
|
238
|
+
receiverAddress,
|
|
238
239
|
ordinalAmount,
|
|
239
240
|
)
|
|
240
241
|
return {
|
|
@@ -251,6 +252,7 @@ export class OrdinalWallet extends BitcoinBaseWallet {
|
|
|
251
252
|
),
|
|
252
253
|
},
|
|
253
254
|
inscribeAddress: ordinalAddress,
|
|
255
|
+
receiverAddress,
|
|
254
256
|
}
|
|
255
257
|
}
|
|
256
258
|
|
|
@@ -261,14 +263,21 @@ export class OrdinalWallet extends BitcoinBaseWallet {
|
|
|
261
263
|
},
|
|
262
264
|
extendedUtxo?: ExtendedUtxo[],
|
|
263
265
|
staticFeeRate?: number,
|
|
266
|
+
ordinalReceiverAddress?: string,
|
|
264
267
|
) {
|
|
265
268
|
if (!this.currentAccount || !this.currentAccountType || !this.publicKey || !this.privateKey) {
|
|
266
269
|
throw new Error("account not initialized")
|
|
267
270
|
}
|
|
271
|
+
const receiverAddress = ordinalReceiverAddress || this.bitcoinAddress!
|
|
268
272
|
|
|
269
273
|
const { inscribeDepositUnsignedInfo, transferOrdinal } =
|
|
270
|
-
await this.inscribeOrdinalDepositUnsigned(
|
|
271
|
-
|
|
274
|
+
await this.inscribeOrdinalDepositUnsigned(
|
|
275
|
+
file,
|
|
276
|
+
this.signerInfo!,
|
|
277
|
+
undefined,
|
|
278
|
+
extendedUtxo,
|
|
279
|
+
staticFeeRate,
|
|
280
|
+
)
|
|
272
281
|
let ordinalUtxo = await this.btcInterface.getBTCUtxo(
|
|
273
282
|
transferOrdinal.ordinalAddress,
|
|
274
283
|
this.signerInfo!,
|
|
@@ -327,7 +336,7 @@ export class OrdinalWallet extends BitcoinBaseWallet {
|
|
|
327
336
|
let inscribeUnsignedInfo = this.transactionBuilder.createInscribeUnsignedTx(
|
|
328
337
|
transferOrdinal,
|
|
329
338
|
inscribeDeposit,
|
|
330
|
-
|
|
339
|
+
receiverAddress,
|
|
331
340
|
ordinalAmount,
|
|
332
341
|
)
|
|
333
342
|
|
|
@@ -370,11 +379,12 @@ export class OrdinalWallet extends BitcoinBaseWallet {
|
|
|
370
379
|
async inscribeBrc20Unsigned(
|
|
371
380
|
brc: { tick: string; amount: number | string },
|
|
372
381
|
signer: SignerInfo,
|
|
382
|
+
ordinalSigner?: SignerInfo,
|
|
373
383
|
extendedUtxo?: ExtendedUtxo[],
|
|
374
384
|
staticFeeRate?: number,
|
|
375
385
|
) {
|
|
376
386
|
let file = OrdinalWallet.transferBRC20Data(brc.tick, brc.amount)
|
|
377
|
-
return this.inscribeOrdinalUnsigned(file, signer, extendedUtxo, staticFeeRate)
|
|
387
|
+
return this.inscribeOrdinalUnsigned(file, signer, ordinalSigner, extendedUtxo, staticFeeRate)
|
|
378
388
|
}
|
|
379
389
|
|
|
380
390
|
async inscribeBrc20(
|
|
@@ -394,10 +404,12 @@ export class OrdinalWallet extends BitcoinBaseWallet {
|
|
|
394
404
|
index: number
|
|
395
405
|
},
|
|
396
406
|
signer: SignerInfo,
|
|
407
|
+
ordinalSigner?: SignerInfo,
|
|
397
408
|
extendedUtxo?: ExtendedUtxo[],
|
|
398
409
|
staticFeeRate?: number,
|
|
399
410
|
otherTargets?: Target[],
|
|
400
411
|
) {
|
|
412
|
+
const ordinalSignerInfo = ordinalSigner || signer
|
|
401
413
|
let utxo = extendedUtxo || (await this.btcInterface.getBTCUtxo(signer.address, signer))
|
|
402
414
|
let feeRate = staticFeeRate || (await this.btcInterface.getFeeRate("normal"))
|
|
403
415
|
let unsignedTx = await this.transactionBuilder.createNftPsbt({
|
|
@@ -406,7 +418,7 @@ export class OrdinalWallet extends BitcoinBaseWallet {
|
|
|
406
418
|
hash: brcInscribeUtxo.hash,
|
|
407
419
|
index: 0,
|
|
408
420
|
value: brcInscribeUtxo.value,
|
|
409
|
-
signerInfo:
|
|
421
|
+
signerInfo: ordinalSignerInfo,
|
|
410
422
|
},
|
|
411
423
|
feeRate,
|
|
412
424
|
receiverAddress: receiver,
|
|
@@ -464,10 +476,12 @@ export class OrdinalWallet extends BitcoinBaseWallet {
|
|
|
464
476
|
receiver: string,
|
|
465
477
|
brc: { tick: string; amount: number | string },
|
|
466
478
|
signer: SignerInfo,
|
|
479
|
+
ordinalSigner?: SignerInfo,
|
|
467
480
|
otherTargets?: Target[],
|
|
468
481
|
extendedUtxo?: ExtendedUtxo[],
|
|
469
482
|
staticFeeRate?: number,
|
|
470
483
|
) {
|
|
484
|
+
const ordinalSignerInfo = ordinalSigner || signer
|
|
471
485
|
// check all fee before process transaction
|
|
472
486
|
let brc20Balance = await this.unisat.getBrc20AddressBalanceForTicker(signer.address, brc.tick)
|
|
473
487
|
|
|
@@ -489,7 +503,7 @@ export class OrdinalWallet extends BitcoinBaseWallet {
|
|
|
489
503
|
extendedUtxo || (await this.btcInterface.getBTCUtxo(signer.address, signer))
|
|
490
504
|
let utxo2: ExtendedUtxo[] = []
|
|
491
505
|
const { inscribeAddress, inscribeDepositUnsignedInfo, inscribeUnsignedInfo } =
|
|
492
|
-
await this.inscribeBrc20Unsigned(brc, signer, utxo1, feeRate)
|
|
506
|
+
await this.inscribeBrc20Unsigned(brc, signer, ordinalSignerInfo, utxo1, feeRate)
|
|
493
507
|
|
|
494
508
|
utxo2 = utxo1.filter(
|
|
495
509
|
(u) =>
|
|
@@ -514,6 +528,7 @@ export class OrdinalWallet extends BitcoinBaseWallet {
|
|
|
514
528
|
index: 0,
|
|
515
529
|
},
|
|
516
530
|
signer,
|
|
531
|
+
ordinalSignerInfo,
|
|
517
532
|
utxo2,
|
|
518
533
|
feeRate,
|
|
519
534
|
otherTargets,
|
|
@@ -618,12 +633,10 @@ export class OrdinalWallet extends BitcoinBaseWallet {
|
|
|
618
633
|
outputToken: string
|
|
619
634
|
outputAmount: string
|
|
620
635
|
},
|
|
636
|
+
ordinalSigner?: SignerInfo,
|
|
621
637
|
extendedUtxo?: ExtendedUtxo[],
|
|
622
638
|
staticFeeRate?: number,
|
|
623
|
-
{
|
|
624
|
-
chainId = 137, // 80001
|
|
625
|
-
appId = exchange ? 1 : 0,
|
|
626
|
-
} = {},
|
|
639
|
+
{ chainId = 137, appId = exchange ? 1 : 0 } = {},
|
|
627
640
|
) {
|
|
628
641
|
const isExchange = !!exchange
|
|
629
642
|
let dataHex = generateBrc2OpReturn({
|
|
@@ -641,6 +654,7 @@ export class OrdinalWallet extends BitcoinBaseWallet {
|
|
|
641
654
|
lockerAddress,
|
|
642
655
|
brc,
|
|
643
656
|
signer,
|
|
657
|
+
ordinalSigner,
|
|
644
658
|
[opTarget],
|
|
645
659
|
extendedUtxo,
|
|
646
660
|
staticFeeRate,
|
|
@@ -662,12 +676,10 @@ export class OrdinalWallet extends BitcoinBaseWallet {
|
|
|
662
676
|
outputToken: string
|
|
663
677
|
outputAmount: string
|
|
664
678
|
},
|
|
679
|
+
ordinalSigner?: SignerInfo,
|
|
665
680
|
extendedUtxo?: ExtendedUtxo[],
|
|
666
681
|
staticFeeRate?: number,
|
|
667
|
-
{
|
|
668
|
-
chainId = 137, // 80001
|
|
669
|
-
appId = exchange ? 1 : 0,
|
|
670
|
-
} = {},
|
|
682
|
+
{ chainId = 137, appId = exchange ? 1 : 0 } = {},
|
|
671
683
|
) {
|
|
672
684
|
let utxo: ExtendedUtxo[] =
|
|
673
685
|
extendedUtxo || (await this.btcInterface.getBTCUtxo(signer.address, signer))
|
|
@@ -689,6 +701,7 @@ export class OrdinalWallet extends BitcoinBaseWallet {
|
|
|
689
701
|
lockerAddress,
|
|
690
702
|
brcInscribeTx,
|
|
691
703
|
signer,
|
|
704
|
+
ordinalSigner,
|
|
692
705
|
utxo,
|
|
693
706
|
feeRate,
|
|
694
707
|
[opTarget],
|
|
@@ -707,10 +720,7 @@ export class OrdinalWallet extends BitcoinBaseWallet {
|
|
|
707
720
|
},
|
|
708
721
|
extendedUtxo?: ExtendedUtxo[],
|
|
709
722
|
staticFeeRate?: number,
|
|
710
|
-
{
|
|
711
|
-
chainId = 137, // 80001
|
|
712
|
-
appId = exchange ? 1 : 0,
|
|
713
|
-
} = {},
|
|
723
|
+
{ chainId = 137, appId = exchange ? 1 : 0 } = {},
|
|
714
724
|
) {
|
|
715
725
|
const isExchange = !!exchange
|
|
716
726
|
|
package/dist/bitcoin-base.d.ts
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import TransactionBuilder, { BitcoinConnectionInfo } from "./transaction-builder/bitcoin-transaction-builder";
|
|
3
|
-
import type { ExtendedUtxo, SignerInfo, Target } from "./transaction-builder/transaction-builder";
|
|
4
|
-
import BitcoinSign from "./sign/sign-transaction";
|
|
5
|
-
import { Network, Payment } from "bitcoinjs-lib";
|
|
6
|
-
import { BitcoinInterface } from "./bitcoin-interface";
|
|
7
|
-
declare class BitcoinBase {
|
|
8
|
-
network: Network;
|
|
9
|
-
hdWalletPath: {
|
|
10
|
-
p2pkh: string;
|
|
11
|
-
p2wpkh: string;
|
|
12
|
-
"p2sh-p2wpkh": string;
|
|
13
|
-
p2sh: string;
|
|
14
|
-
p2wsh: string;
|
|
15
|
-
"p2sh-p2wsh": string;
|
|
16
|
-
p2tr: string;
|
|
17
|
-
};
|
|
18
|
-
transactionBuilder: TransactionBuilder;
|
|
19
|
-
btcInterface: BitcoinInterface;
|
|
20
|
-
signer: BitcoinSign;
|
|
21
|
-
currentAccount?: string;
|
|
22
|
-
currentAccountType?: string;
|
|
23
|
-
privateKey?: Buffer;
|
|
24
|
-
publicKey?: Buffer;
|
|
25
|
-
publicKeys?: Buffer[];
|
|
26
|
-
addressObj?: Payment;
|
|
27
|
-
bitcoinAddress: string | undefined;
|
|
28
|
-
constructor(networkName: string, connectionInfo?: BitcoinConnectionInfo);
|
|
29
|
-
get signerInfo(): {
|
|
30
|
-
address: string;
|
|
31
|
-
publicKey: string;
|
|
32
|
-
addressType: string;
|
|
33
|
-
} | undefined;
|
|
34
|
-
createTransactionInputsAndOutputs({ targets, extendedUtxo, changeAddress, feeRate, }: {
|
|
35
|
-
targets: Target[];
|
|
36
|
-
extendedUtxo: ExtendedUtxo[];
|
|
37
|
-
changeAddress: string;
|
|
38
|
-
feeRate: number;
|
|
39
|
-
fullAmount?: boolean;
|
|
40
|
-
}): {
|
|
41
|
-
inputs: ExtendedUtxo[];
|
|
42
|
-
fee: number;
|
|
43
|
-
outputs: Target[];
|
|
44
|
-
change: import("./transaction-builder/transaction-builder").ChangeTarget | undefined;
|
|
45
|
-
};
|
|
46
|
-
checkBalanceIsSufficient({ targets, extendedUtxo, changeAddress, feeRate, fullAmount, }: {
|
|
47
|
-
targets: Target[];
|
|
48
|
-
extendedUtxo: ExtendedUtxo[];
|
|
49
|
-
changeAddress: string;
|
|
50
|
-
feeRate: number;
|
|
51
|
-
fullAmount?: boolean;
|
|
52
|
-
}): boolean;
|
|
53
|
-
setMultiSigAccount(accountType?: string): void;
|
|
54
|
-
setAccountPrivateKey(privateKeyHex: string): void;
|
|
55
|
-
setAccountPublicKey(publicKeyHex: string): void;
|
|
56
|
-
setAccountPrivateKeyByMnemonic({ mnemonic, mnemonicPassword, index, walletNumber, addressType, }: {
|
|
57
|
-
mnemonic: string;
|
|
58
|
-
mnemonicPassword?: string;
|
|
59
|
-
index?: number;
|
|
60
|
-
walletNumber?: number;
|
|
61
|
-
addressType?: string;
|
|
62
|
-
}): string | undefined;
|
|
63
|
-
setAccount(accountType?: string): string | undefined;
|
|
64
|
-
getExtendedUtxo(input: SignerInfo): Promise<{
|
|
65
|
-
signerInfo: SignerInfo;
|
|
66
|
-
hash: string;
|
|
67
|
-
value: number;
|
|
68
|
-
index: number;
|
|
69
|
-
}[]>;
|
|
70
|
-
send({ receiverAddress, amount, fullAmount, speed, }: {
|
|
71
|
-
receiverAddress: string;
|
|
72
|
-
amount: number;
|
|
73
|
-
fullAmount?: boolean;
|
|
74
|
-
speed?: "normal" | "fast" | "slow";
|
|
75
|
-
}): Promise<string>;
|
|
76
|
-
sendSignedPsbt(signedPsbt: string): Promise<string>;
|
|
77
|
-
sendSignedTx(signedTx: string): Promise<string>;
|
|
78
|
-
sendMultiSignedPsbt(signedPsbts?: string[]): Promise<string>;
|
|
79
|
-
increaseTransactionFeeUnsignedPsbt(txId: string, signerInfos: SignerInfo[], extraExtendedUtxo: ExtendedUtxo[], changeAddress: string, staticFeeRate?: number): Promise<{
|
|
80
|
-
unsignedTransaction: string;
|
|
81
|
-
outputs: Target[];
|
|
82
|
-
inputs: {
|
|
83
|
-
hash: string;
|
|
84
|
-
value: number;
|
|
85
|
-
index: number;
|
|
86
|
-
signerInfo: SignerInfo;
|
|
87
|
-
}[];
|
|
88
|
-
fee: number;
|
|
89
|
-
change: import("./transaction-builder/transaction-builder").ChangeTarget | undefined;
|
|
90
|
-
}>;
|
|
91
|
-
}
|
|
92
|
-
export { BitcoinBase };
|
|
93
|
-
//# sourceMappingURL=bitcoin-base.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bitcoin-base.d.ts","sourceRoot":"","sources":["../src/bitcoin-base.ts"],"names":[],"mappings":"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"}
|