@teleportdao/bitcoin 1.7.6 → 1.7.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 (46) hide show
  1. package/dist/bitcoin-wallet-base.d.ts +1 -6
  2. package/dist/bitcoin-wallet-base.d.ts.map +1 -1
  3. package/dist/bitcoin-wallet-base.js +4 -3
  4. package/dist/bitcoin-wallet-base.js.map +1 -1
  5. package/dist/transaction-builder/transaction-builder.d.ts.map +1 -1
  6. package/dist/transaction-builder/transaction-builder.js +1 -1
  7. package/dist/transaction-builder/transaction-builder.js.map +1 -1
  8. package/package.json +4 -4
  9. package/src/bitcoin-interface-ordinal.ts +181 -181
  10. package/src/bitcoin-interface-teleswap.ts +252 -252
  11. package/src/bitcoin-interface-utils.ts +59 -59
  12. package/src/bitcoin-interface.ts +247 -247
  13. package/src/bitcoin-utils.ts +591 -591
  14. package/src/bitcoin-wallet-base.ts +310 -314
  15. package/src/helper/brc20-helper.ts +181 -181
  16. package/src/helper/ordinal-helper.ts +118 -118
  17. package/src/index.ts +15 -15
  18. package/src/ordinal-wallet.ts +738 -738
  19. package/src/sign/index.ts +1 -1
  20. package/src/sign/sign-transaction.ts +108 -108
  21. package/src/teleswap-wallet.ts +152 -152
  22. package/src/transaction-builder/bitcoin-transaction-builder.ts +44 -44
  23. package/src/transaction-builder/index.ts +3 -3
  24. package/src/transaction-builder/ordinal-transaction-builder.ts +147 -147
  25. package/src/transaction-builder/transaction-builder.ts +706 -705
  26. package/src/type.ts +43 -43
  27. package/src/utils/networks.ts +33 -33
  28. package/src/utils/tools.ts +89 -89
  29. package/tsconfig.json +9 -9
  30. package/webpack.config.js +16 -16
  31. package/dist/bitcoin-base.d.ts +0 -93
  32. package/dist/bitcoin-base.d.ts.map +0 -1
  33. package/dist/bitcoin-base.js +0 -236
  34. package/dist/bitcoin-base.js.map +0 -1
  35. package/dist/helper/burn-request-helper.d.ts +0 -7
  36. package/dist/helper/burn-request-helper.d.ts.map +0 -1
  37. package/dist/helper/burn-request-helper.js +0 -26
  38. package/dist/helper/burn-request-helper.js.map +0 -1
  39. package/dist/helper/teleport-request-helper.d.ts +0 -47
  40. package/dist/helper/teleport-request-helper.d.ts.map +0 -1
  41. package/dist/helper/teleport-request-helper.js +0 -146
  42. package/dist/helper/teleport-request-helper.js.map +0 -1
  43. package/dist/teleport-dao-payments.d.ts +0 -76
  44. package/dist/teleport-dao-payments.d.ts.map +0 -1
  45. package/dist/teleport-dao-payments.js +0 -217
  46. package/dist/teleport-dao-payments.js.map +0 -1
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,152 +1,152 @@
1
- import type {
2
- ExtendedUtxo,
3
- SignerInfo,
4
- TargetAddress,
5
- } from "./transaction-builder/transaction-builder"
6
- import { BitcoinBaseWallet } from "./bitcoin-wallet-base"
7
- import { generateWrapOpReturn } from "./helper/teleswap-helper"
8
-
9
- export type TransferRequest = {
10
- changeAddress?: string
11
- lockerAddress: string
12
- amount: number
13
- fullAmount?: boolean
14
- //-----------
15
- chainId: number
16
- appId: number
17
- recipientAddress: string // 20 bytes
18
- percentageFee: number // 2 bytes in satoshi
19
- speed?: number | boolean // 1 byte
20
- isExchange?: boolean
21
- exchangeTokenAddress?: string // 20 bytes
22
- outputAmount?: number // 28 bytes
23
- deadline?: number // 4 bytes
24
- isFixedToken?: boolean // 1 byte
25
- feeSpeed?: "normal" | "fast" | "slow"
26
- staticFeeRate?: number
27
- }
28
-
29
- export class TeleswapWallet extends BitcoinBaseWallet {
30
- // payment
31
- async sendToMultipleAddress(
32
- receivers: TargetAddress[],
33
- feeSpeed: "normal" | "fast" | "slow" = "normal",
34
- ) {
35
- if (!this.signerInfo || !this.privateKey) {
36
- throw new Error("account not initialized")
37
- }
38
- let extendedUtxo = await this.getExtendedUtxo(this.signerInfo)
39
- let feeRate = await this.transactionBuilder._getFeeRate(feeSpeed)
40
- let unsignedTx = await this.transactionBuilder.processUnsignedTransaction({
41
- extendedUtxo,
42
- targets: receivers,
43
- changeAddress: this.currentAccount,
44
- feeRate,
45
- fullAmount: false,
46
- })
47
- let signedPsbt = await this.signer.signPsbt(unsignedTx, this.privateKey)
48
- let signedTx = this.signer.finalizePsbts([signedPsbt])
49
- let txId = await this.transactionBuilder.sendTx(signedTx)
50
- return txId
51
- }
52
-
53
- // send
54
-
55
- async wrapUnsigned(
56
- recipientAddress: string,
57
- amount: string,
58
- networkFee: string,
59
- signer: SignerInfo,
60
- lockerAddress: string,
61
- exchange?: {
62
- outputToken: string
63
- outputAmount: string
64
- bridgePercentageFee?: number
65
- },
66
- {
67
- chainId = 137, // 80001
68
- appId = exchange ? 1 : 0,
69
- } = {},
70
- fullAmount = false,
71
- staticExtendedUtxo?: ExtendedUtxo[],
72
- staticFeeRate?: number,
73
- changeAddress?: string,
74
- ) {
75
- const dataHex = generateWrapOpReturn({
76
- chainId,
77
- appId,
78
- recipientAddress,
79
- networkFee,
80
- speed: false,
81
- isExchange: !!exchange,
82
- outputAmount: exchange?.outputAmount,
83
- outputToken: exchange?.outputToken,
84
- bridgePercentageFee: exchange?.bridgePercentageFee,
85
- })
86
- let extendedUtxo = staticExtendedUtxo || (await this.getExtendedUtxo(signer))
87
- let feeRate = staticFeeRate || (await this.btcInterface.getFeeRate("normal"))
88
-
89
- const targets = fullAmount
90
- ? [this.transactionBuilder.getOpReturnTarget(dataHex)]
91
- : [
92
- {
93
- address: lockerAddress,
94
- value: +amount,
95
- },
96
- this.transactionBuilder.getOpReturnTarget(dataHex),
97
- ]
98
-
99
- const unsignedTx = this.transactionBuilder.processUnsignedTransaction({
100
- extendedUtxo,
101
- feeRate,
102
- targets,
103
- changeAddress: changeAddress || signer.address,
104
- fullAmount,
105
- })
106
-
107
- return unsignedTx
108
- }
109
-
110
- async wrap(
111
- recipientAddress: string,
112
- amount: string,
113
- networkFee: string,
114
- lockerAddress: string,
115
- exchange?: {
116
- outputToken: string
117
- outputAmount: string
118
- bridgePercentageFee?: number
119
- },
120
- {
121
- chainId = 137, // 80001
122
- appId = exchange ? 1 : 0,
123
- } = {},
124
- fullAmount = false,
125
- staticExtendedUtxo?: ExtendedUtxo[],
126
- staticFeeRate?: number,
127
- changeAddress?: string,
128
- ) {
129
- if (!this.signerInfo || !this.privateKey) {
130
- throw new Error("account not initialized")
131
- }
132
- let unsignedTransaction = await this.wrapUnsigned(
133
- recipientAddress,
134
- amount,
135
- networkFee,
136
- this.signerInfo,
137
- lockerAddress,
138
- exchange,
139
- {
140
- chainId,
141
- appId,
142
- },
143
- fullAmount,
144
- staticExtendedUtxo,
145
- staticFeeRate,
146
- changeAddress,
147
- )
148
- let signedPsbt = await this.signer.signPsbt(unsignedTransaction, this.privateKey)
149
- return this.sendSignedPsbt(signedPsbt)
150
- }
151
- }
152
- export default TeleswapWallet
1
+ import type {
2
+ ExtendedUtxo,
3
+ SignerInfo,
4
+ TargetAddress,
5
+ } from "./transaction-builder/transaction-builder"
6
+ import { BitcoinBaseWallet } from "./bitcoin-wallet-base"
7
+ import { generateWrapOpReturn } from "./helper/teleswap-helper"
8
+
9
+ export type TransferRequest = {
10
+ changeAddress?: string
11
+ lockerAddress: string
12
+ amount: number
13
+ fullAmount?: boolean
14
+ //-----------
15
+ chainId: number
16
+ appId: number
17
+ recipientAddress: string // 20 bytes
18
+ percentageFee: number // 2 bytes in satoshi
19
+ speed?: number | boolean // 1 byte
20
+ isExchange?: boolean
21
+ exchangeTokenAddress?: string // 20 bytes
22
+ outputAmount?: number // 28 bytes
23
+ deadline?: number // 4 bytes
24
+ isFixedToken?: boolean // 1 byte
25
+ feeSpeed?: "normal" | "fast" | "slow"
26
+ staticFeeRate?: number
27
+ }
28
+
29
+ export class TeleswapWallet extends BitcoinBaseWallet {
30
+ // payment
31
+ async sendToMultipleAddress(
32
+ receivers: TargetAddress[],
33
+ feeSpeed: "normal" | "fast" | "slow" = "normal",
34
+ ) {
35
+ if (!this.signerInfo || !this.privateKey) {
36
+ throw new Error("account not initialized")
37
+ }
38
+ let extendedUtxo = await this.getExtendedUtxo(this.signerInfo)
39
+ let feeRate = await this.transactionBuilder._getFeeRate(feeSpeed)
40
+ let unsignedTx = await this.transactionBuilder.processUnsignedTransaction({
41
+ extendedUtxo,
42
+ targets: receivers,
43
+ changeAddress: this.currentAccount,
44
+ feeRate,
45
+ fullAmount: false,
46
+ })
47
+ let signedPsbt = await this.signer.signPsbt(unsignedTx, this.privateKey)
48
+ let signedTx = this.signer.finalizePsbts([signedPsbt])
49
+ let txId = await this.transactionBuilder.sendTx(signedTx)
50
+ return txId
51
+ }
52
+
53
+ // send
54
+
55
+ async wrapUnsigned(
56
+ recipientAddress: string,
57
+ amount: string,
58
+ networkFee: string,
59
+ signer: SignerInfo,
60
+ lockerAddress: string,
61
+ exchange?: {
62
+ outputToken: string
63
+ outputAmount: string
64
+ bridgePercentageFee?: number
65
+ },
66
+ {
67
+ chainId = 137, // 80001
68
+ appId = exchange ? 1 : 0,
69
+ } = {},
70
+ fullAmount = false,
71
+ staticExtendedUtxo?: ExtendedUtxo[],
72
+ staticFeeRate?: number,
73
+ changeAddress?: string,
74
+ ) {
75
+ const dataHex = generateWrapOpReturn({
76
+ chainId,
77
+ appId,
78
+ recipientAddress,
79
+ networkFee,
80
+ speed: false,
81
+ isExchange: !!exchange,
82
+ outputAmount: exchange?.outputAmount,
83
+ outputToken: exchange?.outputToken,
84
+ bridgePercentageFee: exchange?.bridgePercentageFee,
85
+ })
86
+ let extendedUtxo = staticExtendedUtxo || (await this.getExtendedUtxo(signer))
87
+ let feeRate = staticFeeRate || (await this.btcInterface.getFeeRate("normal"))
88
+
89
+ const targets = fullAmount
90
+ ? [this.transactionBuilder.getOpReturnTarget(dataHex)]
91
+ : [
92
+ {
93
+ address: lockerAddress,
94
+ value: +amount,
95
+ },
96
+ this.transactionBuilder.getOpReturnTarget(dataHex),
97
+ ]
98
+
99
+ const unsignedTx = this.transactionBuilder.processUnsignedTransaction({
100
+ extendedUtxo,
101
+ feeRate,
102
+ targets,
103
+ changeAddress: changeAddress || signer.address,
104
+ fullAmount,
105
+ })
106
+
107
+ return unsignedTx
108
+ }
109
+
110
+ async wrap(
111
+ recipientAddress: string,
112
+ amount: string,
113
+ networkFee: string,
114
+ lockerAddress: string,
115
+ exchange?: {
116
+ outputToken: string
117
+ outputAmount: string
118
+ bridgePercentageFee?: number
119
+ },
120
+ {
121
+ chainId = 137, // 80001
122
+ appId = exchange ? 1 : 0,
123
+ } = {},
124
+ fullAmount = false,
125
+ staticExtendedUtxo?: ExtendedUtxo[],
126
+ staticFeeRate?: number,
127
+ changeAddress?: string,
128
+ ) {
129
+ if (!this.signerInfo || !this.privateKey) {
130
+ throw new Error("account not initialized")
131
+ }
132
+ let unsignedTransaction = await this.wrapUnsigned(
133
+ recipientAddress,
134
+ amount,
135
+ networkFee,
136
+ this.signerInfo,
137
+ lockerAddress,
138
+ exchange,
139
+ {
140
+ chainId,
141
+ appId,
142
+ },
143
+ fullAmount,
144
+ staticExtendedUtxo,
145
+ staticFeeRate,
146
+ changeAddress,
147
+ )
148
+ let signedPsbt = await this.signer.signPsbt(unsignedTransaction, this.privateKey)
149
+ return this.sendSignedPsbt(signedPsbt)
150
+ }
151
+ }
152
+ export default TeleswapWallet
@@ -1,44 +1,44 @@
1
- import { BaseTransactionBuilder } from "./transaction-builder"
2
- import { BitcoinInterface } from "../bitcoin-interface"
3
- import * as bitcoin from "bitcoinjs-lib"
4
- import { BitcoinConnectionInfo } from "../type"
5
-
6
- export class BitcoinTransactionBuilder extends BaseTransactionBuilder {
7
- btcInterface: BitcoinInterface
8
- constructor(
9
- connectionInfo: BitcoinConnectionInfo,
10
- networkName: string,
11
- network = bitcoin.networks.bitcoin,
12
- ) {
13
- super({
14
- network,
15
- testnet: networkName?.includes("_testnet"),
16
- dustLimit: 1000,
17
- })
18
- this.btcInterface = new BitcoinInterface(connectionInfo, networkName)
19
- }
20
-
21
- async _getUtxo(userAddress: string) {
22
- let utxos = await this.btcInterface.getUtxo(userAddress)
23
- return utxos.map((tx) => ({
24
- hash: tx.txId as string,
25
- value: +tx.value,
26
- index: +tx.index,
27
- }))
28
- }
29
-
30
- async _getFeeRate(speed: "normal" | "slow" | "fast" = "normal") {
31
- return this.btcInterface.getFeeRate(speed)
32
- }
33
-
34
- async _getTransactionHex(transactionId: string): Promise<string> {
35
- return this.btcInterface.getRawTransaction(transactionId)
36
- }
37
-
38
- async sendTx(txHex: string): Promise<string> {
39
- let txId = await (
40
- this.btcInterface.rpcProvider || this.btcInterface.apiProvider
41
- ).sendRawTransaction(txHex)
42
- return txId
43
- }
44
- }
1
+ import { BaseTransactionBuilder } from "./transaction-builder"
2
+ import { BitcoinInterface } from "../bitcoin-interface"
3
+ import * as bitcoin from "bitcoinjs-lib"
4
+ import { BitcoinConnectionInfo } from "../type"
5
+
6
+ export class BitcoinTransactionBuilder extends BaseTransactionBuilder {
7
+ btcInterface: BitcoinInterface
8
+ constructor(
9
+ connectionInfo: BitcoinConnectionInfo,
10
+ networkName: string,
11
+ network = bitcoin.networks.bitcoin,
12
+ ) {
13
+ super({
14
+ network,
15
+ testnet: networkName?.includes("_testnet"),
16
+ dustLimit: 1000,
17
+ })
18
+ this.btcInterface = new BitcoinInterface(connectionInfo, networkName)
19
+ }
20
+
21
+ async _getUtxo(userAddress: string) {
22
+ let utxos = await this.btcInterface.getUtxo(userAddress)
23
+ return utxos.map((tx) => ({
24
+ hash: tx.txId as string,
25
+ value: +tx.value,
26
+ index: +tx.index,
27
+ }))
28
+ }
29
+
30
+ async _getFeeRate(speed: "normal" | "slow" | "fast" = "normal") {
31
+ return this.btcInterface.getFeeRate(speed)
32
+ }
33
+
34
+ async _getTransactionHex(transactionId: string): Promise<string> {
35
+ return this.btcInterface.getRawTransaction(transactionId)
36
+ }
37
+
38
+ async sendTx(txHex: string): Promise<string> {
39
+ let txId = await (
40
+ this.btcInterface.rpcProvider || this.btcInterface.apiProvider
41
+ ).sendRawTransaction(txHex)
42
+ return txId
43
+ }
44
+ }
@@ -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"