@exodus/bitcoin-api 2.7.3 → 2.7.5
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-api",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.5",
|
|
4
4
|
"description": "Exodus bitcoin-api",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"files": [
|
|
@@ -43,5 +43,5 @@
|
|
|
43
43
|
"@scure/btc-signer": "^1.1.0",
|
|
44
44
|
"jest-when": "^3.5.1"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "7596b820ccf23528fae15ccee13c269fa930434b"
|
|
47
47
|
}
|
package/src/tx-sign/common.js
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
export function extractTransaction({ psbt,
|
|
2
|
-
|
|
1
|
+
export function extractTransaction({ psbt, skipFinalize }) {
|
|
2
|
+
// If a dapp authored the TX, it expects a serialized PSBT response.
|
|
3
|
+
// Note: we wouldn't be able to finalise inputs in some cases that's why we serialize before finalizing inputs.
|
|
4
|
+
|
|
5
|
+
if (skipFinalize) {
|
|
6
|
+
const rawPSBT = psbt.toBuffer()
|
|
7
|
+
|
|
8
|
+
return { plainTx: { rawPSBT } }
|
|
9
|
+
} else {
|
|
3
10
|
// Serialize tx
|
|
11
|
+
psbt.finalizeAllInputs()
|
|
12
|
+
const tx = psbt.extractTransaction()
|
|
13
|
+
const rawTx = tx.toBuffer()
|
|
14
|
+
const txId = tx.getId()
|
|
15
|
+
|
|
4
16
|
// tx needs to be serializable for desktop RPC send => sign communication
|
|
5
|
-
|
|
6
|
-
return {
|
|
7
|
-
rawTx: extractedTx.toBuffer(),
|
|
8
|
-
txId: extractedTx.getId(),
|
|
9
|
-
tx: serializeTx({ tx: extractedTx }),
|
|
10
|
-
}
|
|
11
|
-
} else {
|
|
12
|
-
// Web3 transactions can't be expected to be extractable.
|
|
13
|
-
return { plainTx: { rawPSBT: psbt.toBuffer() } }
|
|
17
|
+
return { rawTx, txId, tx: serializeTx({ tx }) }
|
|
14
18
|
}
|
|
15
19
|
}
|
|
16
20
|
|
|
@@ -68,7 +68,6 @@ export function createSignWithWallet({
|
|
|
68
68
|
// desktop / BE / mobile with bip-schnorr signing
|
|
69
69
|
const signingKey = isTaprootAddress ? tweakSigner({ signer: key, ECPair, network }) : key
|
|
70
70
|
await psbt.signInputAsync(index, toAsyncSigner({ keyPair: signingKey }), sigHashTypes)
|
|
71
|
-
psbt.finalizeInput(index)
|
|
72
71
|
}
|
|
73
72
|
}
|
|
74
73
|
}
|
|
@@ -37,6 +37,7 @@ export const signTxFactory = ({ assetName, resolvePurpose, keys, coinInfo, netwo
|
|
|
37
37
|
|
|
38
38
|
await signWithWallet(psbt, inputsToSign)
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
const skipFinalize = !!unsignedTx.txData.psbtBuffer
|
|
41
|
+
return extractTransaction({ psbt, skipFinalize })
|
|
41
42
|
}
|
|
42
43
|
}
|
|
@@ -39,7 +39,8 @@ export const signHardwareFactory = ({ assetName, resolvePurpose, keys, coinInfo
|
|
|
39
39
|
accountIndex,
|
|
40
40
|
})
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
const skipFinalize = !!unsignedTx.txData.psbtBuffer
|
|
43
|
+
return extractTransaction({ psbt, skipFinalize })
|
|
43
44
|
}
|
|
44
45
|
}
|
|
45
46
|
|
|
@@ -87,8 +88,6 @@ export function applySignatures(psbt, signatures, inputsToSign) {
|
|
|
87
88
|
],
|
|
88
89
|
})
|
|
89
90
|
}
|
|
90
|
-
|
|
91
|
-
psbt.finalizeInput(inputIndex)
|
|
92
91
|
} else {
|
|
93
92
|
throw new Error(
|
|
94
93
|
`expected to sign for inputIndex ${inputIndex} but no signature was produced`
|