@exodus/bitcoin-api 2.3.5 → 2.3.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.
- package/package.json +5 -7
- package/src/tx-send/index.js +3 -14
- package/src/tx-sign/default-create-tx.js +11 -1
- package/src/tx-sign/index.js +1 -1
- package/src/utxos-utils.js +5 -18
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/bitcoin-api",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.6",
|
|
4
4
|
"description": "Exodus bitcoin-api",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"files": [
|
|
@@ -20,12 +20,14 @@
|
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@exodus/asset-lib": "^3.7.2",
|
|
22
22
|
"@exodus/basic-utils": "^2.0.1",
|
|
23
|
+
"@exodus/bip-schnorr": "0.6.6-fork-1",
|
|
23
24
|
"@exodus/bip44-constants": "^195.0.0",
|
|
24
25
|
"@exodus/bitcoinjs-lib": "6.0.2-beta.5",
|
|
25
26
|
"@exodus/models": "^8.10.4",
|
|
26
27
|
"@exodus/secp256k1": "4.0.2-exodus.0",
|
|
27
28
|
"@exodus/simple-retry": "0.0.6",
|
|
28
29
|
"@exodus/timer": "^1.0.0",
|
|
30
|
+
"@noble/secp256k1": "~1.5.3",
|
|
29
31
|
"bech32": "^1.1.3",
|
|
30
32
|
"coininfo": "5.1.0",
|
|
31
33
|
"delay": "4.0.1",
|
|
@@ -36,11 +38,7 @@
|
|
|
36
38
|
"url-join": "4.0.0"
|
|
37
39
|
},
|
|
38
40
|
"devDependencies": {
|
|
39
|
-
"@exodus/
|
|
40
|
-
"@exodus/bcash-meta": "^1.0.0",
|
|
41
|
-
"@exodus/bip-schnorr": "0.6.6-fork-1",
|
|
42
|
-
"@exodus/bitcoin-meta": "^1.0.1",
|
|
43
|
-
"@noble/secp256k1": "~1.5.3"
|
|
41
|
+
"@exodus/bitcoin-meta": "^1.0.1"
|
|
44
42
|
},
|
|
45
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "0ac89c74616ae95eee3c4628ea3babd98dd1495b"
|
|
46
44
|
}
|
package/src/tx-send/index.js
CHANGED
|
@@ -92,21 +92,10 @@ export const getSizeAndChangeScriptFactory = ({ bitcoinJsLib = defaultBitcoinjsL
|
|
|
92
92
|
assert(rawTx, 'rawTx is required')
|
|
93
93
|
assert(typeof changeUtxoIndex === 'number', 'changeUtxoIndex must be a number')
|
|
94
94
|
|
|
95
|
-
const getSize = (tx) => {
|
|
96
|
-
if (typeof tx.size === 'number') return tx.size
|
|
97
|
-
if (typeof tx.virtualSize === 'function') {
|
|
98
|
-
return tx.virtualSize()
|
|
99
|
-
}
|
|
100
|
-
if (typeof tx.virtualSize === 'number') {
|
|
101
|
-
return tx.virtualSize
|
|
102
|
-
}
|
|
103
|
-
return undefined
|
|
104
|
-
}
|
|
105
|
-
|
|
106
95
|
if (tx) {
|
|
107
96
|
return {
|
|
108
|
-
script: tx.outs?.[changeUtxoIndex]?.script
|
|
109
|
-
size:
|
|
97
|
+
script: tx.outs?.[changeUtxoIndex]?.script,
|
|
98
|
+
size: tx.virtualSize,
|
|
110
99
|
}
|
|
111
100
|
}
|
|
112
101
|
// Trezor doesn't return tx!! we need to reparse it!
|
|
@@ -114,7 +103,7 @@ export const getSizeAndChangeScriptFactory = ({ bitcoinJsLib = defaultBitcoinjsL
|
|
|
114
103
|
try {
|
|
115
104
|
return {
|
|
116
105
|
script: parsedTx.outs?.[changeUtxoIndex]?.script.toString('hex'),
|
|
117
|
-
size:
|
|
106
|
+
size: tx.virtualSize?.(),
|
|
118
107
|
}
|
|
119
108
|
} catch (e) {
|
|
120
109
|
console.warn(
|
|
@@ -24,6 +24,16 @@ const canParseTx = (rawTxBuffer) => {
|
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
export const serializeTx = ({ tx }) => {
|
|
28
|
+
// for desktop compatibility
|
|
29
|
+
return {
|
|
30
|
+
virtualSize: tx.virtualSize?.(),
|
|
31
|
+
outs: tx.outs?.map((out) => ({
|
|
32
|
+
script: out.script.toString('hex'),
|
|
33
|
+
})),
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
27
37
|
export const signTxFactory = ({ assetName, resolvePurpose, keys, coinInfo, network, ecc }) => {
|
|
28
38
|
assert(assetName, 'assetName is required')
|
|
29
39
|
assert(resolvePurpose, 'resolvePurpose is required')
|
|
@@ -134,6 +144,6 @@ export const signTxFactory = ({ assetName, resolvePurpose, keys, coinInfo, netwo
|
|
|
134
144
|
const txId = tx.getId()
|
|
135
145
|
|
|
136
146
|
// tx needs to be serializable for desktop RPC send => sign communication
|
|
137
|
-
return { rawTx, txId, tx: {
|
|
147
|
+
return { rawTx, txId, tx: serializeTx({ tx }) }
|
|
138
148
|
}
|
|
139
149
|
}
|
package/src/tx-sign/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { signTxFactory } from './default-create-tx'
|
|
1
|
+
export { signTxFactory, serializeTx } from './default-create-tx'
|
package/src/utxos-utils.js
CHANGED
|
@@ -12,18 +12,12 @@ export function getUtxos({ accountState, asset }) {
|
|
|
12
12
|
)
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
export function getConfirmedUtxos({
|
|
16
|
-
assert(asset, 'asset is required')
|
|
15
|
+
export function getConfirmedUtxos({ utxos }) {
|
|
17
16
|
assert(utxos, 'utxos is required')
|
|
18
|
-
|
|
19
|
-
return UtxoCollection.fromArray(
|
|
20
|
-
utxos.toArray().filter(({ confirmations }) => confirmations > 0),
|
|
21
|
-
{ currency }
|
|
22
|
-
)
|
|
17
|
+
return utxos.filter(({ confirmations }) => confirmations > 0)
|
|
23
18
|
}
|
|
24
19
|
|
|
25
|
-
export function getConfirmedOrRfbDisabledUtxos({
|
|
26
|
-
assert(asset, 'asset is required')
|
|
20
|
+
export function getConfirmedOrRfbDisabledUtxos({ utxos, allowUnconfirmedRbfEnabledUtxos }) {
|
|
27
21
|
assert(utxos, 'utxos is required')
|
|
28
22
|
assert(
|
|
29
23
|
allowUnconfirmedRbfEnabledUtxos !== undefined,
|
|
@@ -32,11 +26,7 @@ export function getConfirmedOrRfbDisabledUtxos({ asset, utxos, allowUnconfirmedR
|
|
|
32
26
|
if (allowUnconfirmedRbfEnabledUtxos) {
|
|
33
27
|
return utxos
|
|
34
28
|
}
|
|
35
|
-
|
|
36
|
-
return UtxoCollection.fromArray(
|
|
37
|
-
utxos.toArray().filter((utxo) => utxo.confirmations > 0 || !utxo.rbfEnabled),
|
|
38
|
-
{ currency }
|
|
39
|
-
)
|
|
29
|
+
return utxos.filter((utxo) => utxo.confirmations > 0 || !utxo.rbfEnabled)
|
|
40
30
|
}
|
|
41
31
|
|
|
42
32
|
export function getUsableUtxos({ asset, utxos, feeData, txSet }) {
|
|
@@ -58,8 +48,5 @@ export function getUsableUtxos({ asset, utxos, feeData, txSet }) {
|
|
|
58
48
|
})
|
|
59
49
|
return largeUnconfirmedTxs.size === 0
|
|
60
50
|
? utxos
|
|
61
|
-
:
|
|
62
|
-
utxos.toArray().filter((utxo) => !largeUnconfirmedTxs.has(utxo.txId)),
|
|
63
|
-
{ currency: asset.currency }
|
|
64
|
-
)
|
|
51
|
+
: utxos.filter((utxo) => !largeUnconfirmedTxs.has(utxo.txId))
|
|
65
52
|
}
|