Skip to content

Commit

Permalink
fix: fix withdraw dao bug
Browse files Browse the repository at this point in the history
  • Loading branch information
classicalliu committed Nov 7, 2019
1 parent 2756a15 commit 9b1c0ed
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
16 changes: 11 additions & 5 deletions packages/neuron-wallet/src/services/wallets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,8 @@ export default class WalletService {
finalFee = TransactionGenerator.txFee(txSize, feeRateInt)
}

const cellStatus = await core.rpc.getLiveCell(withdrawingOutPoint, true)
const sdkWithdrawingOutPoint = ConvertTo.toSdkOutPoint(withdrawingOutPoint)
const cellStatus = await core.rpc.getLiveCell(sdkWithdrawingOutPoint, true)
if (cellStatus.status !== 'live') {
throw new CellIsNotYetLive()
}
Expand Down Expand Up @@ -689,9 +690,12 @@ export default class WalletService {

const outputs: Cell[] = [output]

const previousOutput = TypeConvert.toOutput(cellStatus.cell.output)
const input: Input = {
previousOutput: withdrawingOutPoint,
since: minimalSince.toString(),
lock: previousOutput.lock,
lockHash: LockUtils.computeScriptHash(previousOutput.lock)
}

return {
Expand All @@ -715,7 +719,7 @@ export default class WalletService {
outputsData: outputs.map(o => o.data || '0x'),
witnesses: [],
witnessArgs: [{
lock: '',
lock: undefined,
inputType: '0x0000000000000000',
outputType: undefined,
}]
Expand Down Expand Up @@ -786,7 +790,7 @@ export default class WalletService {
}

public signWitness = (
lock: string,
lock: string | undefined,
privateKey: string,
txHash: string,
inputType: string | undefined = undefined,
Expand All @@ -797,10 +801,12 @@ export default class WalletService {
inputType,
outputType,
}
return core.signWitnesses(privateKey)({
const result = core.signWitnesses(privateKey)({
transactionHash: txHash,
witnesses: [witnessArg]
})[0] as string
})

return result[0] as string
}

// Derivate all child private keys for specified BIP44 paths.
Expand Down
2 changes: 1 addition & 1 deletion packages/neuron-wallet/src/types/cell-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export interface CellDep {
}

export interface WitnessArgs {
lock: string
lock: string | undefined
inputType: string | undefined
outputType: string | undefined
}
Expand Down

0 comments on commit 9b1c0ed

Please sign in to comment.