Skip to content

Commit 1871d01

Browse files
committed
fix: lightnetwork topup auto select account mismatch
1 parent 1a16ad7 commit 1871d01

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

packages/kit/src/views/LightningNetwork/components/LNSwapMenu.tsx

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { isLightningNetworkByNetworkId } from '@onekeyhq/shared/src/engine/engin
1111
import backgroundApiProxy from '../../../background/instance/backgroundApiProxy';
1212
import { useAccount, useNavigation, useNetwork } from '../../../hooks';
1313
import { TabRoutes } from '../../../routes/routesEnum';
14+
import { setRecipient } from '../../../store/reducers/swap';
1415

1516
import type { MessageDescriptor } from 'react-intl';
1617

@@ -55,11 +56,23 @@ function LNSwapMenu({
5556
if (account) {
5657
if (isWithdraw) {
5758
backgroundApiProxy.serviceSwap.setSendingAccountSimple(account);
58-
} else {
59-
backgroundApiProxy.serviceSwap.setRecipientToAccount(
60-
account,
61-
network,
62-
);
59+
} else if (network?.id && account) {
60+
const lnurlMap =
61+
await backgroundApiProxy.serviceLightningNetwork.batchGetLnUrlByAccounts(
62+
{
63+
networkId: network.id,
64+
accounts: [account],
65+
},
66+
);
67+
const address = lnurlMap[account.id] ?? account.address;
68+
const data = {
69+
address,
70+
name: account.name,
71+
accountId: account.id,
72+
networkId: network.id,
73+
networkImpl: network.impl,
74+
};
75+
backgroundApiProxy.dispatch(setRecipient(data));
6376
}
6477
}
6578
navigation.getParent()?.navigate(TabRoutes.Swap);

0 commit comments

Comments
 (0)