Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

wip: ignore unidentified locks to debug polycrypt #2991

Draft
wants to merge 4 commits into
base: alpha/skip-unidentified-inputs
Choose a base branch
from
Draft
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
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 polycrypt')
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 polycrypt')
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