@exodus/bitcoin-plugin 1.16.1 → 1.16.2
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/bitcoin-plugin",
|
|
3
|
-
"version": "1.16.
|
|
3
|
+
"version": "1.16.2",
|
|
4
4
|
"description": "Exodus bitcoin-plugin",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"files": [
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"@scure/btc-signer": "^1.1.0",
|
|
50
50
|
"jest-when": "^3.5.1"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "0f08592c1cf03d33312f0fca501187dc21ea1b45"
|
|
53
53
|
}
|
|
@@ -1,26 +1,34 @@
|
|
|
1
|
-
import { createSimulateTransactions } from '@exodus/web3-bitcoin-utils'
|
|
1
|
+
import { createSimulateTransactions as createSimulateBitcoinTransactions } from '@exodus/web3-bitcoin-utils'
|
|
2
2
|
import { Psbt } from '@exodus/bitcoinjs-lib'
|
|
3
3
|
|
|
4
4
|
import assert from 'minimalistic-assert'
|
|
5
5
|
|
|
6
|
-
// This function accepts either a
|
|
7
|
-
export const
|
|
6
|
+
// This function accepts either a list of transactions created by a wallet (unsignedTxs) or a web3 transaction (transactionBuffers).
|
|
7
|
+
export const createSimulateTransactions = ({ prepareForSigning }) => {
|
|
8
8
|
assert('prepareForSigning', '"prepareForSigning" should be passed')
|
|
9
9
|
|
|
10
|
-
return function simulateTransaction({
|
|
11
|
-
if (
|
|
10
|
+
return function simulateTransaction({ transactionBuffers, unsignedTxs, ...restParameters }) {
|
|
11
|
+
if (transactionBuffers && unsignedTxs) {
|
|
12
12
|
throw new Error('Can not supply both "transactionBuffer" and "unsignedTx".')
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
const
|
|
15
|
+
const simulateTransactions = createSimulateBitcoinTransactions()
|
|
16
16
|
|
|
17
|
-
if (
|
|
18
|
-
|
|
17
|
+
if (transactionBuffers) {
|
|
18
|
+
assert(
|
|
19
|
+
transactionBuffers.length === 1,
|
|
20
|
+
'Simulation for multiple transactions is not supported.'
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
const psbtBase64 = Psbt.fromBuffer(transactionBuffers[0]).toBase64()
|
|
19
24
|
|
|
20
|
-
return
|
|
25
|
+
return simulateTransactions({ transactions: [psbtBase64], ...restParameters })
|
|
21
26
|
}
|
|
22
27
|
|
|
23
|
-
if (
|
|
28
|
+
if (unsignedTxs) {
|
|
29
|
+
assert(unsignedTxs.length === 1, 'Simulation for multiple transactions is not supported.')
|
|
30
|
+
|
|
31
|
+
const unsignedTx = unsignedTxs[0]
|
|
24
32
|
const psbtBase64 = prepareForSigning(unsignedTx).toBase64()
|
|
25
33
|
const walletAddresses = Object.keys(unsignedTx.txMeta.addressPathsMap).reduce(
|
|
26
34
|
(acc, current) => {
|
|
@@ -40,7 +48,7 @@ export const createSimulateTransaction = ({ prepareForSigning }) => {
|
|
|
40
48
|
return acc
|
|
41
49
|
}, {})
|
|
42
50
|
|
|
43
|
-
return
|
|
51
|
+
return simulateTransactions({
|
|
44
52
|
transactions: [psbtBase64],
|
|
45
53
|
walletAddresses,
|
|
46
54
|
indexToAddressRecord,
|
package/src/web3/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createSimulateTransactions } from './createSimulateTransaction'
|
|
2
2
|
|
|
3
3
|
export const createWeb3API = (deps) => {
|
|
4
4
|
return {
|
|
5
|
-
|
|
5
|
+
simulateTransactions: createSimulateTransactions(deps),
|
|
6
6
|
}
|
|
7
7
|
}
|