Skip to content
This repository has been archived by the owner on Apr 25, 2024. It is now read-only.

Fix/unchained wallets integration #354

Merged
merged 8 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 27 additions & 27 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@
"node": ">=20"
},
"overrides": {
"jspdf": "2.5.1"
"jspdf": "2.5.1",
"@ledgerhq/hw-transport-webusb": {
"@ledgerhq/hw-transport": "6.28.1",
"@ledgerhq/devices": "8.0.0"
}
},
"devDependencies": {
"@babel/plugin-transform-runtime": "^7.21.0",
Expand Down Expand Up @@ -144,7 +148,7 @@
"redux-thunk": "^2.3.0",
"reselect": "^4.0.0",
"sass": "^1.56.2",
"unchained-bitcoin": "^1.2.0",
"unchained-bitcoin": "^1.2.1",
"unchained-wallets": "^1.0.3"
}
}
13 changes: 8 additions & 5 deletions src/actions/transactionActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,13 @@ export function setMaxSpendOnOutput(outputIndex) {
new BigNumber(0)
);

const spendAllAmount = satoshisToBitcoins(
new BigNumber(confirmedBalance)
.minus(outputs.length > 1 ? totalOutputValue : 0)
.minus(estimatedFee)
const spendAllAmount = new BigNumber(
satoshisToBitcoins(
bucko13 marked this conversation as resolved.
Show resolved Hide resolved
new BigNumber(confirmedBalance)
.minus(outputs.length > 1 ? totalOutputValue : 0)
.minus(estimatedFee)
.toFixed(8)
)
);

if (
Expand All @@ -292,7 +295,7 @@ export function setMaxSpendOnOutput(outputIndex) {
"Not enough available funds for max spend. Clear other outputs or wait for incoming deposits to confirm."
)
);
return dispatch(setOutputAmount(outputIndex, spendAllAmount));
return dispatch(setOutputAmount(outputIndex, spendAllAmount.toString()));
};
}

Expand Down
18 changes: 9 additions & 9 deletions src/components/ScriptExplorer/SignatureImporter.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -631,16 +631,16 @@ function mapStateToProps(state, ownProps) {
...state.spend.transaction,
requiredSigners: state.settings.requiredSigners,
ledgerPolicyHmacs: state.wallet.common.ledgerPolicyHmacs,
extendedPublicKeys: Object.values(
state.quorum.extendedPublicKeyImporters
).map((key) => ({
bip32Path: getMaskedDerivation({
extendedPublicKeys: Object.values(state.quorum.extendedPublicKeyImporters)
.filter((key) => key.extendedPublicKey)
.map((key) => ({
bip32Path: getMaskedDerivation({
xpub: key.extendedPublicKey,
bip32Path: key.bip32Path,
}),
xfp: key.rootXfp,
xpub: key.extendedPublicKey,
bip32Path: key.bip32Path,
}),
xfp: key.rootXfp,
xpub: key.extendedPublicKey,
})),
})),
};
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/TestSuiteRun/TestRun.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class TestRunBase extends React.Component {
const { test } = this.props;
const interaction = test.interaction();
const nameBits = test.name().split(" ");
const body = interaction.request().data.toBase64();
const body = interaction.request();
const timestamp = moment().format("HHmm");
const filename = `${timestamp}-${nameBits[2]}-${nameBits[1][0]}.psbt`;
downloadFile(body, filename);
Expand Down
5 changes: 4 additions & 1 deletion src/tests/registration.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ class RegisterWalletPolicyTest extends Test {
}

description() {
const keyOrigins = this.params.braidDetails.extendedPublicKeys.sort(
(a, b) => a.base58String.localeCompare(b.base58String)
);
return (
<Box>
<p>
Expand Down Expand Up @@ -47,7 +50,7 @@ class RegisterWalletPolicyTest extends Test {
Registering Quorum
</TableCell>
</TableRow>
{this.params.braidDetails.extendedPublicKeys.map((key, index) => (
{keyOrigins.map((key, index) => (
<React.Fragment key={key.rootFingerprint}>
<TableRow>
<TableCell colSpan={6} style={{ textAlign: "center" }}>
Expand Down
3 changes: 1 addition & 2 deletions src/utils/constants.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import BigNumber from "bignumber.js";
import { satoshisToBitcoins } from "unchained-bitcoin";

export const DUST_IN_SATOSHIS = 546;
export const DUST_IN_BTC = satoshisToBitcoins(BigNumber(DUST_IN_SATOSHIS));
export const DUST_IN_BTC = satoshisToBitcoins(DUST_IN_SATOSHIS.toString());
export const DEFAULT_PREFIX = "m";
export const CHANGE_INDEX = "/1";
export const DEFAULT_CHANGE_PREFIX = DEFAULT_PREFIX + CHANGE_INDEX;
2 changes: 1 addition & 1 deletion src/utils/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import BigNumber from "bignumber.js";
import { estimateMultisigTransactionFee } from "unchained-bitcoin/lib/fees";
import { estimateMultisigTransactionFee } from "unchained-bitcoin";

import { DUST_IN_SATOSHIS } from "./constants";

Expand Down
10 changes: 10 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,14 @@ export default defineConfig({
__GIT_SHA__: JSON.stringify(process.env.__GIT_SHA__),
__APP_VERSION__: JSON.stringify(process.env.npm_package_version),
},
optimizeDeps: {
include: [
/*
Add packages you want to develop locally with caravan here
for example, uncomment the ones below if working on either package
*/
// "unchained-bitcoin",
// "unchained-wallets",
],
},
Comment on lines +27 to +36
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also requires a counterpart in:

commonjsOptions: {
      include: [/unchained-bitcoin/, /unchained-wallets/],
},

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's weird that I was able to get things to work without that.

});