mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-01-22 09:43:47 +00:00
wallet: simplify signature handling
Don't use an additional buffer, drop one branch. Signed-off-by: Roman Khimov <roman@nspcc.ru>
This commit is contained in:
parent
9e112fc024
commit
35d5495d39
1 changed files with 4 additions and 6 deletions
|
@ -150,14 +150,12 @@ func (a *Account) SignTx(net netmode.Magic, t *transaction.Transaction) error {
|
|||
if a.privateKey == nil {
|
||||
return errors.New("account key is not available (need to decrypt?)")
|
||||
}
|
||||
sign := a.privateKey.SignHashable(uint32(net), t)
|
||||
|
||||
invoc := append([]byte{byte(opcode.PUSHDATA1), keys.SignatureLen}, sign...)
|
||||
if len(a.Contract.Parameters) == 1 {
|
||||
t.Scripts[pos].InvocationScript = invoc
|
||||
} else {
|
||||
t.Scripts[pos].InvocationScript = append(t.Scripts[pos].InvocationScript, invoc...)
|
||||
if len(a.Contract.Parameters) == 1 && t.Scripts[pos].InvocationScript != nil {
|
||||
t.Scripts[pos].InvocationScript = t.Scripts[pos].InvocationScript[:0]
|
||||
}
|
||||
t.Scripts[pos].InvocationScript = append(t.Scripts[pos].InvocationScript, byte(opcode.PUSHDATA1), keys.SignatureLen)
|
||||
t.Scripts[pos].InvocationScript = append(t.Scripts[pos].InvocationScript, a.privateKey.SignHashable(uint32(net), t)...)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue