|
1 | 1 | 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'; |
3 | 7 | import { ref, computed } from 'vue';
|
4 | 8 | import { fPublicMode, strCurrency, togglePublicMode } from '../settings.js';
|
5 | 9 | import { cOracle } from '../prices.js';
|
6 |
| -import { ledgerSignTransaction } from '../ledger.js'; |
| 10 | +import { LedgerController } from '../ledger.js'; |
7 | 11 | import { defineStore } from 'pinia';
|
8 | 12 | import { lockableFunction } from '../lock.js';
|
9 | 13 | import { blockCount as rawBlockCount } from '../global.js';
|
@@ -85,10 +89,22 @@ export const useWallet = defineStore('wallet', () => {
|
85 | 89 | });
|
86 | 90 | const createAndSendTransaction = lockableFunction(
|
87 | 91 | async (network, address, value, opts) => {
|
88 |
| - const tx = wallet.createTransaction(address, value, opts); |
| 92 | + let tx; |
89 | 93 | 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 | + ); |
91 | 106 | } else {
|
| 107 | + tx = wallet.createTransaction(address, value, opts); |
92 | 108 | await wallet.sign(tx);
|
93 | 109 | }
|
94 | 110 | const res = await network.sendTransaction(tx.serialize());
|
|
0 commit comments