@@ -4,6 +4,7 @@ import { dialog, SaveDialogReturnValue, BrowserWindow } from 'electron'
44import WalletsService , { Wallet , WalletProperties , FileKeystoreWallet } from 'services/wallets'
55import Keystore from 'models/keys/keystore'
66import Keychain from 'models/keys/keychain'
7+ import ChainInfo from 'models/chain-info'
78import { validateMnemonic , mnemonicToSeedSync } from 'models/keys/mnemonic'
89import { AccountExtendedPublicKey , ExtendedPrivateKey } from 'models/keys/key'
910import { ResponseCode } from 'utils/const'
@@ -22,6 +23,7 @@ import i18n from 'utils/i18n'
2223import AddressService from 'services/addresses'
2324import WalletCreatedSubject from 'models/subjects/wallet-created-subject'
2425import { TransactionWithoutHash , OutPoint } from 'types/cell-types'
26+ import { MainnetAddressRequired , TestnetAddressRequired } from 'exceptions/address'
2527
2628export default class WalletsController {
2729 public static async getAll ( ) : Promise < Controller . Response < Pick < Wallet , 'id' | 'name' > [ ] > > {
@@ -339,7 +341,16 @@ export default class WalletsController {
339341 feeRate = '1000'
340342 }
341343
344+ const isMainnet = ChainInfo . getInstance ( ) . isMainnet ( )
342345 params . items . forEach ( item => {
346+ if ( isMainnet && ! item . address . startsWith ( 'ckb' ) ) {
347+ throw new MainnetAddressRequired ( item . address )
348+ }
349+
350+ if ( ! isMainnet && ! item . address . startsWith ( 'ckt' ) ) {
351+ throw new TestnetAddressRequired ( item . address )
352+ }
353+
343354 if ( ! this . verifyAddress ( item . address ) ) {
344355 throw new InvalidAddress ( item . address )
345356 }
0 commit comments