Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ export default class IndexerCacheService {
lockScript: addressMeta.generateSingleMultiSignLockScript(),
argsLen: 28,
},
{
lockScript: addressMeta.generateLegacySingleMultiSignLockScript(),
argsLen: 28,
},
{
lockScript: addressMeta.generateChequeLockScriptWithReceiverLockHash(),
argsLen: 40,
Expand Down
6 changes: 5 additions & 1 deletion packages/neuron-wallet/src/database/address/meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 9 additions & 4 deletions packages/neuron-wallet/src/services/cells.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
(
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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: '',
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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,
Expand Down Expand Up @@ -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({
Expand Down
9 changes: 9 additions & 0 deletions packages/neuron-wallet/tests/database/address/meta.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down