@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
package/src/sign/index.ts CHANGED
@@ -1 +1 @@
1
- export { default as BaseBitcoinSigner } from "./sign-transaction"
1
+ export { default as BaseBitcoinSigner } from "./sign-transaction"
@@ -1,108 +1,108 @@
1
- import { Psbt, crypto, Network } from "bitcoinjs-lib"
2
- // import BIP32Factory from "bip32"
3
- import ecc from "@bitcoinerlab/secp256k1"
4
- import ECPairFactory from "ecpair"
5
-
6
- const ECPair = ECPairFactory(ecc)
7
-
8
- function tapTweakHash(pubKey: Buffer, h?: Buffer) {
9
- return crypto.taggedHash("TapTweak", Buffer.concat(h ? [pubKey, h] : [pubKey]))
10
- }
11
-
12
- function tweakSigner(
13
- privateKey: Buffer,
14
- network: Network,
15
- opts = {} as {
16
- [key: string]: Buffer
17
- },
18
- ) {
19
- let newPrv = privateKey
20
- let keyPair = ECPair.fromPrivateKey(privateKey, {
21
- network,
22
- compressed: true,
23
- })
24
-
25
- if (!keyPair.privateKey) throw new Error("private key not exist")
26
-
27
- if (keyPair.publicKey.toString("hex").startsWith("03")) {
28
- newPrv = ecc.privateNegate(keyPair.privateKey) as Buffer
29
- }
30
-
31
- const tweakedPrivateKey = ecc.privateAdd(
32
- newPrv,
33
- tapTweakHash(Buffer.from(keyPair.publicKey.toString("hex").slice(2), "hex"), opts?.tweakHash),
34
- )
35
- if (!tweakedPrivateKey) {
36
- throw new Error("Invalid tweaked private key!")
37
- }
38
-
39
- return ECPair.fromPrivateKey(Buffer.from(tweakedPrivateKey), {
40
- network,
41
- })
42
- }
43
-
44
- class BitcoinLikeSignTransaction {
45
- network: Network
46
-
47
- constructor(network: Network) {
48
- this.network = network
49
- }
50
-
51
- async signPsbt(
52
- unsignedPsbt: {
53
- unsignedTransaction: string
54
- inputsToSign?: number[]
55
- },
56
- privateKey: Buffer,
57
- sighashTypes?: any[],
58
- usingTweakSignerIfNeeded = true,
59
- ) {
60
- const { network } = this
61
- const keyPair = ECPair.fromPrivateKey(privateKey, {
62
- network,
63
- compressed: true,
64
- })
65
- const psbt = Psbt.fromBase64(unsignedPsbt.unsignedTransaction, {
66
- network,
67
- })
68
-
69
- let numberOfInputs = psbt.inputCount
70
-
71
- for (let i = 0; i < numberOfInputs; i += 1) {
72
- if (unsignedPsbt.inputsToSign && !unsignedPsbt.inputsToSign.includes(i)) {
73
- // eslint-disable-next-line no-continue
74
- continue
75
- }
76
- let type = psbt.getInputType(i)
77
-
78
- if (usingTweakSignerIfNeeded && type === "nonstandard") {
79
- console.log("using tweak signer")
80
- let a = tweakSigner(privateKey, this.network)
81
- await psbt.signInputAsync(i, a, sighashTypes)
82
- } else {
83
- await psbt.signInputAsync(i, keyPair, sighashTypes)
84
- }
85
- }
86
-
87
- // psbt.signAllInputs(keyPair)
88
- const partialSigendPsbt = psbt.toBase64()
89
- return partialSigendPsbt
90
- }
91
-
92
- finalizePsbts(psbtsBase64: string[] = []) {
93
- const finals = psbtsBase64.map((psbtBase64) =>
94
- Psbt.fromBase64(psbtBase64, { network: this.network }),
95
- )
96
- const psbt =
97
- finals.length === 1 ? finals[0] : new Psbt({ network: this.network }).combine(...finals)
98
-
99
- psbt.finalizeAllInputs()
100
-
101
- let finalizeTx = psbt.extractTransaction()
102
- // const rawTx = finalizeTx.toBuffer()
103
- // const hex = rawTx.toString("hex")
104
- return finalizeTx.toHex()
105
- }
106
- }
107
-
108
- export default BitcoinLikeSignTransaction
1
+ import { Psbt, crypto, Network } from "bitcoinjs-lib"
2
+ // import BIP32Factory from "bip32"
3
+ import ecc from "@bitcoinerlab/secp256k1"
4
+ import ECPairFactory from "ecpair"
5
+
6
+ const ECPair = ECPairFactory(ecc)
7
+
8
+ function tapTweakHash(pubKey: Buffer, h?: Buffer) {
9
+ return crypto.taggedHash("TapTweak", Buffer.concat(h ? [pubKey, h] : [pubKey]))
10
+ }
11
+
12
+ function tweakSigner(
13
+ privateKey: Buffer,
14
+ network: Network,
15
+ opts = {} as {
16
+ [key: string]: Buffer
17
+ },
18
+ ) {
19
+ let newPrv = privateKey
20
+ let keyPair = ECPair.fromPrivateKey(privateKey, {
21
+ network,
22
+ compressed: true,
23
+ })
24
+
25
+ if (!keyPair.privateKey) throw new Error("private key not exist")
26
+
27
+ if (keyPair.publicKey.toString("hex").startsWith("03")) {
28
+ newPrv = ecc.privateNegate(keyPair.privateKey) as Buffer
29
+ }
30
+
31
+ const tweakedPrivateKey = ecc.privateAdd(
32
+ newPrv,
33
+ tapTweakHash(Buffer.from(keyPair.publicKey.toString("hex").slice(2), "hex"), opts?.tweakHash),
34
+ )
35
+ if (!tweakedPrivateKey) {
36
+ throw new Error("Invalid tweaked private key!")
37
+ }
38
+
39
+ return ECPair.fromPrivateKey(Buffer.from(tweakedPrivateKey), {
40
+ network,
41
+ })
42
+ }
43
+
44
+ class BitcoinLikeSignTransaction {
45
+ network: Network
46
+
47
+ constructor(network: Network) {
48
+ this.network = network
49
+ }
50
+
51
+ async signPsbt(
52
+ unsignedPsbt: {
53
+ unsignedTransaction: string
54
+ inputsToSign?: number[]
55
+ },
56
+ privateKey: Buffer,
57
+ sighashTypes?: any[],
58
+ usingTweakSignerIfNeeded = true,
59
+ ) {
60
+ const { network } = this
61
+ const keyPair = ECPair.fromPrivateKey(privateKey, {
62
+ network,
63
+ compressed: true,
64
+ })
65
+ const psbt = Psbt.fromBase64(unsignedPsbt.unsignedTransaction, {
66
+ network,
67
+ })
68
+
69
+ let numberOfInputs = psbt.inputCount
70
+
71
+ for (let i = 0; i < numberOfInputs; i += 1) {
72
+ if (unsignedPsbt.inputsToSign && !unsignedPsbt.inputsToSign.includes(i)) {
73
+ // eslint-disable-next-line no-continue
74
+ continue
75
+ }
76
+ let type = psbt.getInputType(i)
77
+
78
+ if (usingTweakSignerIfNeeded && type === "nonstandard") {
79
+ console.log("using tweak signer")
80
+ let a = tweakSigner(privateKey, this.network)
81
+ await psbt.signInputAsync(i, a, sighashTypes)
82
+ } else {
83
+ await psbt.signInputAsync(i, keyPair, sighashTypes)
84
+ }
85
+ }
86
+
87
+ // psbt.signAllInputs(keyPair)
88
+ const partialSigendPsbt = psbt.toBase64()
89
+ return partialSigendPsbt
90
+ }
91
+
92
+ finalizePsbts(psbtsBase64: string[] = []) {
93
+ const finals = psbtsBase64.map((psbtBase64) =>
94
+ Psbt.fromBase64(psbtBase64, { network: this.network }),
95
+ )
96
+ const psbt =
97
+ finals.length === 1 ? finals[0] : new Psbt({ network: this.network }).combine(...finals)
98
+
99
+ psbt.finalizeAllInputs()
100
+
101
+ let finalizeTx = psbt.extractTransaction()
102
+ // const rawTx = finalizeTx.toBuffer()
103
+ // const hex = rawTx.toString("hex")
104
+ return finalizeTx.toHex()
105
+ }
106
+ }
107
+
108
+ export default BitcoinLikeSignTransaction
@@ -1,133 +1,133 @@
1
- import { teleswap, chainInfo } from "@teleportdao/configs"
2
- import type {
3
- ExtendedUtxo,
4
- SignerInfo,
5
- TargetAddress,
6
- } from "./transaction-builder/transaction-builder"
7
- import { BitcoinBaseWallet, FeeRateType } from "./bitcoin-wallet-base"
8
- import { generateWrapOpReturn } from "./helper/teleswap-helper"
9
-
10
- export type TransferRequest = {
11
- changeAddress?: string
12
- lockerAddress: string
13
- amount: number
14
- fullAmount?: boolean
15
- //-----------
16
- chainId: number
17
- appId: number
18
- recipientAddress: string // 20 bytes
19
- percentageFee: number // 2 bytes in satoshi
20
- speed?: number | boolean // 1 byte
21
- isExchange?: boolean
22
- exchangeTokenAddress?: string // 20 bytes
23
- outputAmount?: number // 28 bytes
24
- deadline?: number // 4 bytes
25
- isFixedToken?: boolean // 1 byte
26
- feeSpeed?: "normal" | "fast" | "slow"
27
- staticFeeRate?: number
28
- }
29
-
30
- export class TeleswapWallet extends BitcoinBaseWallet {
31
- // signed methods
32
- async wrap(
33
- recipientAddress: string,
34
- amount: string,
35
- networkFee: string,
36
- lockerAddress: string,
37
- chainId: number, // 80001
38
- exchange?: {
39
- outputToken: string
40
- outputAmount: string
41
- bridgePercentageFee?: number
42
- },
43
- appId = exchange
44
- ? teleswap.requestAppId.WrapAndSwap.default
45
- : teleswap.requestAppId.Wrap.default,
46
- fee: FeeRateType = "normal",
47
- thirdPartyId?: number,
48
- staticExtendedUtxo?: ExtendedUtxo[],
49
- changeAddress?: string,
50
- fullAmount = false,
51
- ) {
52
- if (!this.signerInfo || !this.privateKey) {
53
- throw new Error("account not initialized")
54
- }
55
- let unsignedTransaction = await this.wrapUnsigned(
56
- recipientAddress,
57
- amount,
58
- networkFee,
59
- lockerAddress,
60
- chainId,
61
- this.signerInfo,
62
- exchange,
63
- appId,
64
- fee,
65
- thirdPartyId,
66
- staticExtendedUtxo,
67
- changeAddress,
68
- fullAmount,
69
- )
70
- let signedPsbt = await this.signer.signPsbt(unsignedTransaction, this.privateKey)
71
- return this.sendSignedPsbt(signedPsbt)
72
- }
73
-
74
- // unsigned methods
75
-
76
- async wrapUnsigned(
77
- recipientAddress: string,
78
- amount: string,
79
- networkFee: string,
80
- lockerAddress: string,
81
- chainId: number, // 80001
82
- signer: SignerInfo,
83
- exchange?: {
84
- outputToken: string
85
- outputAmount: string
86
- bridgePercentageFee?: number
87
- },
88
- appId = exchange
89
- ? teleswap.requestAppId.WrapAndSwap.default
90
- : teleswap.requestAppId.Wrap.default,
91
- fee: FeeRateType = "normal",
92
- thirdPartyId?: number,
93
- staticExtendedUtxo?: ExtendedUtxo[],
94
- changeAddress?: string,
95
- fullAmount = false,
96
- ) {
97
- const dataHex = generateWrapOpReturn({
98
- chainId,
99
- appId,
100
- recipientAddress,
101
- networkFee,
102
- speed: false,
103
- isExchange: !!exchange,
104
- outputAmount: exchange?.outputAmount,
105
- outputToken: exchange?.outputToken,
106
- bridgePercentageFee: exchange?.bridgePercentageFee,
107
- thirdPartyId,
108
- })
109
- let extendedUtxo = staticExtendedUtxo || (await this.getExtendedUtxo(signer))
110
- let feeRate = await this.getFeeRate(fee)
111
-
112
- const targets = fullAmount
113
- ? [this.transactionBuilder.getOpReturnTarget(dataHex)]
114
- : [
115
- {
116
- address: lockerAddress,
117
- value: +amount,
118
- },
119
- this.transactionBuilder.getOpReturnTarget(dataHex),
120
- ]
121
-
122
- const unsignedTx = this.transactionBuilder.processUnsignedTransaction({
123
- extendedUtxo,
124
- feeRate,
125
- targets,
126
- changeAddress: changeAddress || signer.address,
127
- fullAmount,
128
- })
129
-
130
- return unsignedTx
131
- }
132
- }
133
- export default TeleswapWallet
1
+ import { teleswap, chainInfo } from "@teleportdao/configs"
2
+ import type {
3
+ ExtendedUtxo,
4
+ SignerInfo,
5
+ TargetAddress,
6
+ } from "./transaction-builder/transaction-builder"
7
+ import { BitcoinBaseWallet, FeeRateType } from "./bitcoin-wallet-base"
8
+ import { generateWrapOpReturn } from "./helper/teleswap-helper"
9
+
10
+ export type TransferRequest = {
11
+ changeAddress?: string
12
+ lockerAddress: string
13
+ amount: number
14
+ fullAmount?: boolean
15
+ //-----------
16
+ chainId: number
17
+ appId: number
18
+ recipientAddress: string // 20 bytes
19
+ percentageFee: number // 2 bytes in satoshi
20
+ speed?: number | boolean // 1 byte
21
+ isExchange?: boolean
22
+ exchangeTokenAddress?: string // 20 bytes
23
+ outputAmount?: number // 28 bytes
24
+ deadline?: number // 4 bytes
25
+ isFixedToken?: boolean // 1 byte
26
+ feeSpeed?: "normal" | "fast" | "slow"
27
+ staticFeeRate?: number
28
+ }
29
+
30
+ export class TeleswapWallet extends BitcoinBaseWallet {
31
+ // signed methods
32
+ async wrap(
33
+ recipientAddress: string,
34
+ amount: string,
35
+ networkFee: string,
36
+ lockerAddress: string,
37
+ chainId: number, // 80001
38
+ exchange?: {
39
+ outputToken: string
40
+ outputAmount: string
41
+ bridgePercentageFee?: number
42
+ },
43
+ appId = exchange
44
+ ? teleswap.requestAppId.WrapAndSwap.default
45
+ : teleswap.requestAppId.Wrap.default,
46
+ fee: FeeRateType = "normal",
47
+ thirdPartyId?: number,
48
+ staticExtendedUtxo?: ExtendedUtxo[],
49
+ changeAddress?: string,
50
+ fullAmount = false,
51
+ ) {
52
+ if (!this.signerInfo || !this.privateKey) {
53
+ throw new Error("account not initialized")
54
+ }
55
+ let unsignedTransaction = await this.wrapUnsigned(
56
+ recipientAddress,
57
+ amount,
58
+ networkFee,
59
+ lockerAddress,
60
+ chainId,
61
+ this.signerInfo,
62
+ exchange,
63
+ appId,
64
+ fee,
65
+ thirdPartyId,
66
+ staticExtendedUtxo,
67
+ changeAddress,
68
+ fullAmount,
69
+ )
70
+ let signedPsbt = await this.signer.signPsbt(unsignedTransaction, this.privateKey)
71
+ return this.sendSignedPsbt(signedPsbt)
72
+ }
73
+
74
+ // unsigned methods
75
+
76
+ async wrapUnsigned(
77
+ recipientAddress: string,
78
+ amount: string,
79
+ networkFee: string,
80
+ lockerAddress: string,
81
+ chainId: number, // 80001
82
+ signer: SignerInfo,
83
+ exchange?: {
84
+ outputToken: string
85
+ outputAmount: string
86
+ bridgePercentageFee?: number
87
+ },
88
+ appId = exchange
89
+ ? teleswap.requestAppId.WrapAndSwap.default
90
+ : teleswap.requestAppId.Wrap.default,
91
+ fee: FeeRateType = "normal",
92
+ thirdPartyId?: number,
93
+ staticExtendedUtxo?: ExtendedUtxo[],
94
+ changeAddress?: string,
95
+ fullAmount = false,
96
+ ) {
97
+ const dataHex = generateWrapOpReturn({
98
+ chainId,
99
+ appId,
100
+ recipientAddress,
101
+ networkFee,
102
+ speed: false,
103
+ isExchange: !!exchange,
104
+ outputAmount: exchange?.outputAmount,
105
+ outputToken: exchange?.outputToken,
106
+ bridgePercentageFee: exchange?.bridgePercentageFee,
107
+ thirdPartyId,
108
+ })
109
+ let extendedUtxo = staticExtendedUtxo || (await this.getExtendedUtxo(signer))
110
+ let feeRate = await this.getFeeRate(fee)
111
+
112
+ const targets = fullAmount
113
+ ? [this.transactionBuilder.getOpReturnTarget(dataHex)]
114
+ : [
115
+ {
116
+ address: lockerAddress,
117
+ value: +amount,
118
+ },
119
+ this.transactionBuilder.getOpReturnTarget(dataHex),
120
+ ]
121
+
122
+ const unsignedTx = this.transactionBuilder.processUnsignedTransaction({
123
+ extendedUtxo,
124
+ feeRate,
125
+ targets,
126
+ changeAddress: changeAddress || signer.address,
127
+ fullAmount,
128
+ })
129
+
130
+ return unsignedTx
131
+ }
132
+ }
133
+ export default TeleswapWallet
@@ -1,26 +1,26 @@
1
- import * as bitcoin from "bitcoinjs-lib"
2
- import { BaseTransactionBuilder } from "./transaction-builder"
3
- import { BitcoinInterfaceWallet } from "../bitcoin-interface-wallet"
4
- import { BitcoinInterface } from "../bitcoin-interface"
5
- import { BitcoinInterfaceConnectionInfo } from "../type"
6
-
7
- export class BitcoinTransactionBuilder extends BaseTransactionBuilder {
8
- btcInterface: BitcoinInterfaceWallet
9
- constructor(
10
- networkName: string,
11
- network = bitcoin.networks.bitcoin,
12
- connectionInfo?: BitcoinInterfaceConnectionInfo,
13
- ) {
14
- super({
15
- network,
16
- testnet: networkName?.includes("_testnet"),
17
- dustLimit: 1000,
18
- })
19
- this.btcInterface = new BitcoinInterface(networkName, connectionInfo)
20
- }
21
-
22
- // eslint-disable-next-line no-underscore-dangle
23
- async _getTransactionHex(transactionId: string): Promise<string> {
24
- return this.btcInterface.getRawTransaction(transactionId)
25
- }
26
- }
1
+ import * as bitcoin from "bitcoinjs-lib"
2
+ import { BaseTransactionBuilder } from "./transaction-builder"
3
+ import { BitcoinInterfaceWallet } from "../bitcoin-interface-wallet"
4
+ import { BitcoinInterface } from "../bitcoin-interface"
5
+ import { BitcoinConnectionInfo } from "../type"
6
+
7
+ export class BitcoinTransactionBuilder extends BaseTransactionBuilder {
8
+ btcInterface: BitcoinInterfaceWallet
9
+ constructor(
10
+ networkName: string,
11
+ network = bitcoin.networks.bitcoin,
12
+ connectionInfo?: BitcoinConnectionInfo,
13
+ ) {
14
+ super({
15
+ network,
16
+ testnet: networkName?.includes("_testnet"),
17
+ dustLimit: 1000,
18
+ })
19
+ this.btcInterface = new BitcoinInterface(networkName, connectionInfo)
20
+ }
21
+
22
+ // eslint-disable-next-line no-underscore-dangle
23
+ async _getTransactionHex(transactionId: string): Promise<string> {
24
+ return this.btcInterface.getRawTransaction(transactionId)
25
+ }
26
+ }
@@ -1,3 +1,3 @@
1
- export * from "./bitcoin-transaction-builder"
2
- export * from "./ordinal-transaction-builder"
3
- export * from "./transaction-builder"
1
+ export * from "./bitcoin-transaction-builder"
2
+ export * from "./ordinal-transaction-builder"
3
+ export * from "./transaction-builder"