Skip to content

Commit ec6fdbd

Browse files
authored
Ledger queue (#527)
* Ledger refactor * Remove unused params * Add queue
1 parent 77ed216 commit ec6fdbd

File tree

7 files changed

+362
-229
lines changed

7 files changed

+362
-229
lines changed

scripts/composables/use_wallet.js

+20-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
import { getEventEmitter } from '../event_bus.js';
2-
import { hasEncryptedWallet, wallet } from '../wallet.js';
2+
import {
3+
hasEncryptedWallet,
4+
wallet,
5+
getNewAddress as guiGetNewAddress,
6+
} from '../wallet.js';
37
import { ref, computed } from 'vue';
48
import { fPublicMode, strCurrency, togglePublicMode } from '../settings.js';
59
import { cOracle } from '../prices.js';
6-
import { ledgerSignTransaction } from '../ledger.js';
10+
import { LedgerController } from '../ledger.js';
711
import { defineStore } from 'pinia';
812
import { lockableFunction } from '../lock.js';
913
import { blockCount as rawBlockCount } from '../global.js';
@@ -85,10 +89,22 @@ export const useWallet = defineStore('wallet', () => {
8589
});
8690
const createAndSendTransaction = lockableFunction(
8791
async (network, address, value, opts) => {
88-
const tx = wallet.createTransaction(address, value, opts);
92+
let tx;
8993
if (wallet.isHardwareWallet()) {
90-
await ledgerSignTransaction(wallet, tx);
94+
const [changeAddress] = await guiGetNewAddress({
95+
verify: true,
96+
nReceiving: 0,
97+
});
98+
tx = wallet.createTransaction(address, value, {
99+
...opts,
100+
changeAddress,
101+
});
102+
await LedgerController.getInstance().signTransaction(
103+
wallet,
104+
tx
105+
);
91106
} else {
107+
tx = wallet.createTransaction(address, value, opts);
92108
await wallet.sign(tx);
93109
}
94110
const res = await network.sendTransaction(tx.serialize());

scripts/dashboard/Dashboard.vue

+5-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import {
3030
isStandardAddress,
3131
} from '../misc.js';
3232
import { getNetwork } from '../network/network_manager.js';
33-
import { strHardwareName } from '../ledger';
33+
import { LedgerController } from '../ledger';
3434
import { guiAddContactPrompt } from '../contacts-book';
3535
import { scanQRCode } from '../scanner';
3636
import { useWallet } from '../composables/use_wallet.js';
@@ -116,7 +116,10 @@ async function importWallet({
116116
createAlert(
117117
'info',
118118
tr(ALERTS.WALLET_HARDWARE_WALLET, [
119-
{ hardwareWallet: strHardwareName },
119+
{
120+
hardwareWallet:
121+
LedgerController.getInstance().getHardwareName(),
122+
},
120123
]),
121124
12500
122125
);

0 commit comments

Comments
 (0)