diff --git a/.ckb-light-version b/.ckb-light-version index 5aff472ddf..b043aa648f 100644 --- a/.ckb-light-version +++ b/.ckb-light-version @@ -1 +1 @@ -v0.4.1 +v0.5.0 diff --git a/.ckb-version b/.ckb-version index 9bb8722956..4177f84ed3 100644 --- a/.ckb-version +++ b/.ckb-version @@ -1 +1 @@ -v0.201.0 +v0.202.0 diff --git a/compatible.json b/compatible.json index 87521b060c..01f03dd534 100644 --- a/compatible.json +++ b/compatible.json @@ -1,5 +1,6 @@ { "fullVersions": [ + "0.202", "0.201", "0.200", "0.121", @@ -23,6 +24,7 @@ "0.103" ], "lightVersions": [ + "0.5", "0.4", "0.3", "0.2" @@ -30,6 +32,7 @@ "compatible": { "0.111": { "full": [ + "0.202", "0.201", "0.200", "0.121", @@ -47,6 +50,7 @@ "0.109" ], "light": [ + "0.5", "0.4", "0.3", "0.2" @@ -54,6 +58,7 @@ }, "0.110": { "full": [ + "0.202", "0.201", "0.200", "0.121", @@ -71,6 +76,7 @@ "0.109" ], "light": [ + "0.5", "0.4", "0.3", "0.2" @@ -94,6 +100,7 @@ }, "0.112": { "full": [ + "0.202", "0.201", "0.200", "0.121", @@ -111,6 +118,7 @@ "0.109" ], "light": [ + "0.5", "0.4", "0.3", "0.2" @@ -118,6 +126,7 @@ }, "0.114": { "full": [ + "0.202", "0.201", "0.200", "0.121", @@ -135,6 +144,7 @@ "0.109" ], "light": [ + "0.5", "0.4", "0.3", "0.2" @@ -142,6 +152,7 @@ }, "0.116": { "full": [ + "0.202", "0.201", "0.200", "0.121", @@ -159,6 +170,7 @@ "0.109" ], "light": [ + "0.5", "0.4", "0.3", "0.2" @@ -166,6 +178,7 @@ }, "0.117": { "full": [ + "0.202", "0.201", "0.200", "0.121", @@ -183,6 +196,7 @@ "0.109" ], "light": [ + "0.5", "0.4", "0.3", "0.2" @@ -190,6 +204,7 @@ }, "0.119": { "full": [ + "0.202", "0.201", "0.200", "0.121", @@ -207,6 +222,7 @@ "0.109" ], "light": [ + "0.5", "0.4", "0.3", "0.2" @@ -214,6 +230,7 @@ }, "0.120": { "full": [ + "0.202", "0.201", "0.200", "0.121", @@ -231,6 +248,7 @@ "0.109" ], "light": [ + "0.5", "0.4", "0.3", "0.2" @@ -238,6 +256,7 @@ }, "0.121": { "full": [ + "0.202", "0.201", "0.200", "0.121", @@ -255,6 +274,7 @@ "0.109" ], "light": [ + "0.5", "0.4", "0.3", "0.2" @@ -262,6 +282,7 @@ }, "0.201": { "full": [ + "0.202", "0.201", "0.200", "0.121", @@ -279,6 +300,7 @@ "0.109" ], "light": [ + "0.5", "0.4", "0.3", "0.2" diff --git a/packages/neuron-wallet/.env b/packages/neuron-wallet/.env index 8151ad7ef4..c5b2f95000 100644 --- a/packages/neuron-wallet/.env +++ b/packages/neuron-wallet/.env @@ -121,6 +121,6 @@ MAINNET_MULTISIG_TXHASH=0x6888aa39ab30c570c2c30d9d5684d3769bf77265a7973211a3c087 TESTNET_MULTISIG_TXHASH=0x2eefdeb21f3a3edf697c28a52601b4419806ed60bb427420455cc29a090b26d5 # CKB NODE OPTIONS -CKB_NODE_ASSUME_VALID_TARGET='0x8d98cc0af11e54e7c66b10d188cea7bd1ec33acee624eb0fddd9bb6951cf720e' -CKB_NODE_ASSUME_VALID_TARGET_BLOCK_NUMBER=16284813 -CKB_NODE_DATA_SIZE=125 +CKB_NODE_ASSUME_VALID_TARGET='0x983fed642041094a75fbc6a06b4d88c3d4db9ebe43b14f103ec5b8086cd5d96c' +CKB_NODE_ASSUME_VALID_TARGET_BLOCK_NUMBER=16516767 +CKB_NODE_DATA_SIZE=126 diff --git a/packages/neuron-wallet/src/block-sync-renderer/sync/indexer-cache-service.ts b/packages/neuron-wallet/src/block-sync-renderer/sync/indexer-cache-service.ts index 99f29b49e4..e2895f96bb 100644 --- a/packages/neuron-wallet/src/block-sync-renderer/sync/indexer-cache-service.ts +++ b/packages/neuron-wallet/src/block-sync-renderer/sync/indexer-cache-service.ts @@ -111,6 +111,10 @@ export default class IndexerCacheService { lockScript: addressMeta.generateSingleMultiSignLockScript(), argsLen: 28, }, + { + lockScript: addressMeta.generateLegacySingleMultiSignLockScript(), + argsLen: 28, + }, { lockScript: addressMeta.generateChequeLockScriptWithReceiverLockHash(), argsLen: 40, diff --git a/packages/neuron-wallet/src/database/address/meta.ts b/packages/neuron-wallet/src/database/address/meta.ts index 2a2cb6b9fe..ddaae60b58 100644 --- a/packages/neuron-wallet/src/database/address/meta.ts +++ b/packages/neuron-wallet/src/database/address/meta.ts @@ -100,13 +100,17 @@ export default class AddressMeta implements Address { return SystemScriptInfo.generateSecpScript(this.blake160) } - public generateSingleMultiSignLockScript(): Script { + public generateLegacySingleMultiSignLockScript(): Script { return SystemScriptInfo.generateMultiSignScript( Multisig.hash([this.blake160]), SystemScriptInfo.LEGACY_MULTISIG_CODE_HASH ) } + public generateSingleMultiSignLockScript(): Script { + return SystemScriptInfo.generateMultiSignScript(Multisig.hash([this.blake160]), SystemScriptInfo.MULTISIG_CODE_HASH) + } + public generateACPLockScript(): Script { const assetAccountInfo = new AssetAccountInfo() return assetAccountInfo.generateAnyoneCanPayScript(this.blake160) diff --git a/packages/neuron-wallet/src/exceptions/transaction.ts b/packages/neuron-wallet/src/exceptions/transaction.ts index 33152ace76..d3fe707419 100644 --- a/packages/neuron-wallet/src/exceptions/transaction.ts +++ b/packages/neuron-wallet/src/exceptions/transaction.ts @@ -24,6 +24,13 @@ export class TransactionInputParameterMiss extends Error { } } +export class UnrecognizedLockScript extends Error { + public code = 117 + constructor(message: string) { + super(message) + } +} + export default { TransactionNotFound, CapacityTooSmall, diff --git a/packages/neuron-wallet/src/locales/ar.ts b/packages/neuron-wallet/src/locales/ar.ts index 2f00419a5c..5138acb4f5 100644 --- a/packages/neuron-wallet/src/locales/ar.ts +++ b/packages/neuron-wallet/src/locales/ar.ts @@ -228,6 +228,12 @@ export default { ignore: 'تجاهل واستمرار', }, }, + 'unrecognized-multisig-transaction': { + message: 'هذه معاملة متعددة التوقيعات. يرجى الموافقة عليها من عنوان التوقيع المتعدد باستخدام المحفظة المناسبة.', + buttons: { + cancel: 'إلغاء', + }, + }, }, prompt: { password: { diff --git a/packages/neuron-wallet/src/locales/en.ts b/packages/neuron-wallet/src/locales/en.ts index 842c05b5d6..a05c9e463b 100644 --- a/packages/neuron-wallet/src/locales/en.ts +++ b/packages/neuron-wallet/src/locales/en.ts @@ -230,6 +230,13 @@ export default { ignore: 'Ignore and continue', }, }, + 'unrecognized-multisig-transaction': { + message: + 'This is a multisig transaction. Please approve it from the multisig address using the appropriate wallet. ', + buttons: { + cancel: 'Cancel', + }, + }, }, prompt: { password: { diff --git a/packages/neuron-wallet/src/locales/es.ts b/packages/neuron-wallet/src/locales/es.ts index 21a53720b1..48e51295c9 100644 --- a/packages/neuron-wallet/src/locales/es.ts +++ b/packages/neuron-wallet/src/locales/es.ts @@ -233,6 +233,13 @@ export default { ignore: 'Ignorar y continuar', }, }, + 'unrecognized-multisig-transaction': { + message: + 'Esta es una transacción multisignatura. Por favor, apróbala desde la dirección multisignatura utilizando la billetera correspondiente.', + buttons: { + cancel: 'Cancelar', + }, + }, }, prompt: { password: { diff --git a/packages/neuron-wallet/src/locales/fr.ts b/packages/neuron-wallet/src/locales/fr.ts index c87442f556..e8ac3b4420 100644 --- a/packages/neuron-wallet/src/locales/fr.ts +++ b/packages/neuron-wallet/src/locales/fr.ts @@ -234,6 +234,13 @@ export default { ignore: 'Ignorer et continuer', }, }, + 'unrecognized-multisig-transaction': { + message: + "Il s'agit d'une transaction multisignature. Veuillez l'approuver depuis l'adresse multisignature en utilisant le portefeuille approprié.", + buttons: { + cancel: 'Annuler', + }, + }, }, prompt: { password: { diff --git a/packages/neuron-wallet/src/locales/zh-tw.ts b/packages/neuron-wallet/src/locales/zh-tw.ts index 7567c2f8d3..ffbec8ce4b 100644 --- a/packages/neuron-wallet/src/locales/zh-tw.ts +++ b/packages/neuron-wallet/src/locales/zh-tw.ts @@ -216,6 +216,12 @@ export default { ignore: '忽略並繼續', }, }, + 'unrecognized-multisig-transaction': { + message: '這是一筆多簽交易。請使用對應的錢包在多簽地址中批准該交易。', + buttons: { + cancel: '取消', + }, + }, }, prompt: { password: { diff --git a/packages/neuron-wallet/src/locales/zh.ts b/packages/neuron-wallet/src/locales/zh.ts index 52b09f1210..5062f023ae 100644 --- a/packages/neuron-wallet/src/locales/zh.ts +++ b/packages/neuron-wallet/src/locales/zh.ts @@ -217,6 +217,12 @@ export default { ignore: '忽略并继续', }, }, + 'unrecognized-multisig-transaction': { + message: '这是一笔多签交易。请使用对应的钱包在多签地址中批准该交易。', + buttons: { + cancel: '取消', + }, + }, }, prompt: { password: { diff --git a/packages/neuron-wallet/src/services/cells.ts b/packages/neuron-wallet/src/services/cells.ts index cdfa8a39d1..e9bfd8b2fe 100644 --- a/packages/neuron-wallet/src/services/cells.ts +++ b/packages/neuron-wallet/src/services/cells.ts @@ -320,7 +320,7 @@ export default class CellsService { ( output.hasData = 0 AND output.typeHash IS NULL AND - output.lockCodeHash = :multiSignlockCodeHash + output.lockCodeHash in (:...multiSignlockCodeHash) ) OR ( @@ -353,7 +353,7 @@ export default class CellsService { `, { liveStatus: OutputStatus.Live, - multiSignlockCodeHash: SystemScriptInfo.LEGACY_MULTISIG_CODE_HASH, + multiSignlockCodeHash: [SystemScriptInfo.LEGACY_MULTISIG_CODE_HASH, SystemScriptInfo.MULTISIG_CODE_HASH], chequeLockCodeHash, nftIssuerCodehash, nftClassCodehash, @@ -467,7 +467,9 @@ export default class CellsService { data: 'withdraw-able', }) } - } else if (o.lockCodeHash === SystemScriptInfo.LEGACY_MULTISIG_CODE_HASH) { + } else if ( + [SystemScriptInfo.LEGACY_MULTISIG_CODE_HASH, SystemScriptInfo.MULTISIG_CODE_HASH].includes(o.lockCodeHash) + ) { cell.setCustomizedAssetInfo({ lock: CustomizedLock.SingleMultiSign, type: '', @@ -770,7 +772,9 @@ export default class CellsService { if (inputs.find(el => el.lockHash === cell.lockHash!)) { totalSize += TransactionSize.emptyWitness() } else { - if (lockClass.codeHash === SystemScriptInfo.LEGACY_MULTISIG_CODE_HASH) { + if ( + [SystemScriptInfo.LEGACY_MULTISIG_CODE_HASH, SystemScriptInfo.MULTISIG_CODE_HASH].includes(lockClass.codeHash) + ) { const multisigConfig = multisigConfigMap[cell.lockHash] if (!multisigConfig) { throw new MultisigConfigNeedError() @@ -1374,6 +1378,7 @@ export default class CellsService { case assetAccountInfo.getChequeInfo().codeHash: return LockScriptCategory.Cheque case SystemScriptInfo.LEGACY_MULTISIG_CODE_HASH: + case SystemScriptInfo.MULTISIG_CODE_HASH: if (output.lock.args.length === LOCKTIME_ARGS_LENGTH) { return LockScriptCategory.MULTI_LOCK_TIME } diff --git a/packages/neuron-wallet/src/services/transaction-sender.ts b/packages/neuron-wallet/src/services/transaction-sender.ts index dc2000bc51..847ea40dfc 100644 --- a/packages/neuron-wallet/src/services/transaction-sender.ts +++ b/packages/neuron-wallet/src/services/transaction-sender.ts @@ -32,6 +32,7 @@ import { NoMatchAddressForSign, SignTransactionFailed, TransactionIsNotCommittedYet, + UnrecognizedLockScript, } from '../exceptions' import AssetAccountInfo from '../models/asset-account-info' import MultisigConfigModel from '../models/multisig-config' @@ -206,19 +207,32 @@ export default class TransactionSender { } catch (error) { const BLOCK_UNRECOGNIZED = 0 const IGNORE_UNRECOGNIZED_AND_CONTINUE = 1 + + let message = t('messageBox.unrecognized-lock-script.message') + let buttons = [ + t('messageBox.unrecognized-lock-script.buttons.cancel'), + t('messageBox.unrecognized-lock-script.buttons.ignore'), + ] + + const input = tx.inputs.find(input => input.lockHash === lockHash) + if (input && input.lock && SystemScriptInfo.isMultiSignCodeHash(input.lock.codeHash)) { + message = t('messageBox.unrecognized-multisig-transaction.message') + buttons = [t('messageBox.unrecognized-multisig-transaction.buttons.cancel')] + } + const res = await dialog.showMessageBox({ type: 'warning', - message: t('messageBox.unrecognized-lock-script.message'), - buttons: [ - t('messageBox.unrecognized-lock-script.buttons.cancel'), - t('messageBox.unrecognized-lock-script.buttons.ignore'), - ], + message, + buttons, defaultId: BLOCK_UNRECOGNIZED, cancelId: IGNORE_UNRECOGNIZED_AND_CONTINUE, }) if (res.response === IGNORE_UNRECOGNIZED_AND_CONTINUE) { continue } + if (res.response === BLOCK_UNRECOGNIZED) { + throw new UnrecognizedLockScript(message) + } throw error } diff --git a/packages/neuron-wallet/tests/block-sync-renderer/indexer-cache-service.intg.test.ts b/packages/neuron-wallet/tests/block-sync-renderer/indexer-cache-service.intg.test.ts index 4d6022b2d3..2341254466 100644 --- a/packages/neuron-wallet/tests/block-sync-renderer/indexer-cache-service.intg.test.ts +++ b/packages/neuron-wallet/tests/block-sync-renderer/indexer-cache-service.intg.test.ts @@ -70,6 +70,7 @@ const addressMeta = AddressMeta.fromObject(address) const addressMetas = [addressMeta] const defaultLockScript = addressMeta.generateDefaultLockScript() const singleMultiSignLockScript = addressMeta.generateSingleMultiSignLockScript() +const legacySingleMultiSignLockScript = addressMeta.generateLegacySingleMultiSignLockScript() const chequeLockScript = addressMeta.generateChequeLockScriptWithReceiverLockHash() const acpLockScript = addressMeta.generateACPLockScript() const legacyAcpLockScript = addressMeta.generateLegacyACPLockScript() @@ -83,6 +84,11 @@ const formattedSingleMultiSignLockScript = { hashType: singleMultiSignLockScript.hashType, args: singleMultiSignLockScript.args + '0'.repeat(14), } +const formattedLegacySingleMultiSignLockScript = { + codeHash: legacySingleMultiSignLockScript.codeHash, + hashType: legacySingleMultiSignLockScript.hashType, + args: legacySingleMultiSignLockScript.args + '0'.repeat(14), +} const formattedChequeLockScript = { codeHash: chequeLockScript.codeHash, hashType: chequeLockScript.hashType, @@ -276,6 +282,17 @@ describe('indexer cache service', () => { stubbedCellCollectorConstructor.mockReset() when(stubbedCellCollectorConstructor) + .calledWith( + expect.anything(), + expect.objectContaining({ + lock: { + ...formattedLegacySingleMultiSignLockScript, + args: formattedLegacySingleMultiSignLockScript.args.slice(0, 42), + }, + argsLen: 28, + }) + ) + .mockReturnValue(fakeCollectorObj) .calledWith( expect.anything(), expect.objectContaining({ diff --git a/packages/neuron-wallet/tests/database/address/meta.test.ts b/packages/neuron-wallet/tests/database/address/meta.test.ts index af9b7f4b62..17c2b130ef 100644 --- a/packages/neuron-wallet/tests/database/address/meta.test.ts +++ b/packages/neuron-wallet/tests/database/address/meta.test.ts @@ -42,6 +42,15 @@ describe('Address Dao tests', () => { it('#generateSingleMultiSignLockScript', () => { const script = addressMeta.generateSingleMultiSignLockScript() + expect(script).toEqual({ + args: Multisig.hash([address.blake160]), + codeHash: '0x36c971b8d41fbd94aabca77dc75e826729ac98447b46f91e00796155dddb0d29', + hashType: 'data1', + }) + }) + + it('#generateLegacySingleMultiSignLockScript', () => { + const script = addressMeta.generateLegacySingleMultiSignLockScript() expect(script).toEqual({ args: Multisig.hash([address.blake160]), codeHash: '0x5c5069eb0857efc65e1bca0c07df34c31663b3622fd3876c876320fc9634e2a8', diff --git a/yarn.lock b/yarn.lock index 1dd50c50fc..cb81a668d7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -15623,9 +15623,9 @@ symbol-tree@^3.2.4: integrity sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw== tar-fs@^2.0.0: - version "2.1.2" - resolved "https://registry.yarnpkg.com/tar-fs/-/tar-fs-2.1.2.tgz#425f154f3404cb16cb8ff6e671d45ab2ed9596c5" - integrity sha512-EsaAXwxmx8UB7FRKqeozqEPop69DXcmYwTQwXvyAPF352HJsPdkVhvTaDPYqfNgruveJIJy3TA2l+2zj8LJIJA== + version "2.1.3" + resolved "https://registry.yarnpkg.com/tar-fs/-/tar-fs-2.1.3.tgz#fb3b8843a26b6f13a08e606f7922875eb1fbbf92" + integrity sha512-090nwYJDmlhwFwEW3QQl+vaNnxsO2yVsd45eTKRBzSzu+hlb1w2K9inVq5b0ngXuLVqQ4ApvsUHHnu/zQNkWAg== dependencies: chownr "^1.1.1" mkdirp-classic "^0.5.2"