Skip to content

Commit

Permalink
wip: ignore unidentified locks to debug polycrypt
Browse files Browse the repository at this point in the history
  • Loading branch information
Keith-CY committed Dec 15, 2023
1 parent 56096fe commit a855395
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 16 deletions.
17 changes: 12 additions & 5 deletions packages/neuron-wallet/src/controllers/offline-sign.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { getMultisigStatus } from '../utils/multisig'
import { generateRPC } from '../utils/ckb-rpc'
import ShowGlobalDialogSubject from '../models/subjects/show-global-dialog'
import NetworksService from '../services/networks'
import logger from '../utils/logger'

export default class OfflineSignController {
public async exportTransactionAsJSON({
Expand Down Expand Up @@ -99,11 +100,17 @@ export default class OfflineSignController {
.then(({ tx: t, metadata }) => {
// TODO: maybe unidentified inputs can be skipped in offline sign
if (metadata.locks.skipped.size) {
throw new Error(
`Fail to sign transaction, following lock scripts cannot be identified: ${[
...metadata.locks.skipped.values(),
]}`
)
try {
throw new Error(
`Fail to sign transaction, following lock scripts cannot be identified: ${[
...metadata.locks.skipped.values(),
]}`
)
} catch (err) {
// FIXME: remove this before being merged into develop branch
logger.debug('Ignore the following error for debugging polyscrypt')
logger.error(err)
}
}
return t
})
Expand Down
1 change: 1 addition & 0 deletions packages/neuron-wallet/src/services/hardware/hardware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export abstract class Hardware {
} else if (args.length === 42) {
return addressInfos.find(i => i.blake160 === args)!.path
} else {
// FIXME: should not be a fallback
const addressInfo = AssetAccountInfo.findSignPathForCheque(addressInfos, args)
return addressInfo!.path
}
Expand Down
38 changes: 27 additions & 11 deletions packages/neuron-wallet/src/services/transaction-sender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,18 @@ export default class TransactionSender {
const tx = skipSign
? Transaction.fromObject(transaction)
: await this.sign(walletID, transaction, password, skipLastInput).then(({ tx, metadata }) => {
if (metadata.locks.skipped.size) {
throw new Error(
`Fail to send transaction, following lock scripts cannot be identified: ${[
...metadata.locks.skipped.values(),
]} `
)
try {
if (metadata.locks.skipped.size) {
throw new Error(
`Fail to send transaction, following lock scripts cannot be identified: ${[
...metadata.locks.skipped.values(),
]} `
)
}
} catch (err) {
// FIXME: remove this before being merged into develop branch
logger.debug('Ignore the following error for debugging polyscrypt')
logger.error(err)
}
return tx
})
Expand Down Expand Up @@ -165,8 +171,13 @@ export default class TransactionSender {
} else if (args.length === 42) {
path = addressInfos.find(i => i.blake160 === args)?.path
} else {
const addressInfo = AssetAccountInfo.findSignPathForCheque(addressInfos, args)
path = addressInfo?.path
// FIXME: should not be a fallback
try {
const addressInfo = AssetAccountInfo.findSignPathForCheque(addressInfos, args)
path = addressInfo?.path
} catch {
logger.error(`Failed to find args: ${args}`)
}
}

return pathAndPrivateKeys.find(p => p.path === path)?.privateKey
Expand Down Expand Up @@ -303,9 +314,14 @@ export default class TransactionSender {
path = matchAddress?.path
matchArgs = matchAddress?.blake160
} else {
const addressInfo = AssetAccountInfo.findSignPathForCheque(addressInfos, args)
path = addressInfo?.path
matchArgs = addressInfo?.blake160
// FIXME: should not be a fallback
try {
const addressInfo = AssetAccountInfo.findSignPathForCheque(addressInfos, args)
path = addressInfo?.path
matchArgs = addressInfo?.blake160
} catch {
logger.error(`Failed to find args: ${args}`)
}
}
return !!path
})
Expand Down

1 comment on commit a855395

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Packaging for test is done in 7220380801

Please # to comment.