@@ -4,7 +4,7 @@ import { AccountExtendedPublicKey, PathAndPrivateKey } from 'models/keys/key'
44import Keystore from 'models/keys/keystore'
55import Store from 'models/store'
66import LockUtils from 'models/lock-utils'
7- import { Witness , TransactionWithoutHash , Input } from 'types/cell-types'
7+ import { TransactionWithoutHash , Input } from 'types/cell-types'
88import ConvertTo from 'types/convert-to'
99import Blake2b from 'utils/blake2b'
1010import { WalletNotFound , IsRequired , UsedName } from 'exceptions'
@@ -380,16 +380,16 @@ export default class WalletService {
380380 const paths = addressInfos . map ( info => info . path )
381381 const pathAndPrivateKeys = this . getPrivateKeys ( wallet , paths , password )
382382
383- const witnesses : Witness [ ] = inputs ! . map ( ( input : Input ) => {
384- const blake160 : string = input . lock ! . args ! [ 0 ]
383+ const witnesses : string [ ] = inputs ! . map ( ( input : Input ) => {
384+ const blake160 : string = input . lock ! . args !
385385 const info = addressInfos . find ( i => i . blake160 === blake160 )
386386 const { path } = info !
387387 const pathAndPrivateKey = pathAndPrivateKeys . find ( p => p . path === path )
388388 if ( ! pathAndPrivateKey ) {
389389 throw new Error ( 'no private key found' )
390390 }
391391 const { privateKey } = pathAndPrivateKey
392- const witness = this . signWitness ( { data : [ ] } , privateKey , txHash )
392+ const witness = this . signWitness ( '' , privateKey , txHash )
393393 return witness
394394 } )
395395
@@ -443,19 +443,15 @@ export default class WalletService {
443443 return addr ! . address
444444 }
445445
446- public signWitness = ( witness : Witness , privateKey : string , txHash : string ) : Witness => {
446+ public signWitness = ( witness : string , privateKey : string , txHash : string ) : string => {
447447 const addrObj = core . generateAddress ( privateKey )
448- const oldData = witness . data
448+ const oldData = witness
449449 const blake2b = new Blake2b ( )
450450 blake2b . update ( txHash )
451- oldData . forEach ( data => {
452- blake2b . update ( data )
453- } )
451+ blake2b . update ( oldData )
454452 const message = blake2b . digest ( )
455453 const signature = addrObj . signRecoverable ( message )
456- const newWitness : Witness = {
457- data : [ signature ] ,
458- }
454+ const newWitness = signature
459455 return newWitness
460456 }
461457
0 commit comments