From d29b13454f1837202e597b5179626ceee50160bb Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Fri, 17 Feb 2023 23:43:22 +0300 Subject: [PATCH] [#239] morph/client: Simplify code interacting with magic numbers It can't be uint64 in fact, but this error is buried deeply in the NetworkInfo API structure, so we're not touching MagicNumber() for now. Signed-off-by: Roman Khimov Signed-off-by: Evgenii Stratonikov --- pkg/morph/client/notary.go | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/pkg/morph/client/notary.go b/pkg/morph/client/notary.go index 069c3578..7399c19c 100644 --- a/pkg/morph/client/notary.go +++ b/pkg/morph/client/notary.go @@ -412,16 +412,11 @@ func (c *Client) NotarySignAndInvokeTX(mainTx *transaction.Transaction) error { return err } - // error appears only if client - // is in inactive mode; that has - // been already checked above - magicNumber, _ := c.MagicNumber() - // mainTX is expected to be pre-validated: second witness must exist and be empty mainTx.Scripts[1].VerificationScript = multiaddrAccount.GetVerificationScript() mainTx.Scripts[1].InvocationScript = append( []byte{byte(opcode.PUSHDATA1), 64}, - multiaddrAccount.PrivateKey().SignHashable(uint32(magicNumber), mainTx)..., + multiaddrAccount.SignHashable(c.rpcActor.GetNetwork(), mainTx)..., ) //lint:ignore SA1019 https://git.frostfs.info/TrueCloudLab/frostfs-node/issues/202 @@ -667,12 +662,12 @@ func (c *Client) notaryWitnesses(invokedByAlpha bool, multiaddr *wallet.Account, // to pass Notary module verification var invokeScript []byte - magicNumber, _ := c.MagicNumber() + magicNumber := c.rpcActor.GetNetwork() if invokedByAlpha { invokeScript = append( []byte{byte(opcode.PUSHDATA1), 64}, - multiaddr.PrivateKey().SignHashable(uint32(magicNumber), tx)..., + multiaddr.SignHashable(magicNumber, tx)..., ) } else { // we can't provide alphabet node signature @@ -694,7 +689,7 @@ func (c *Client) notaryWitnesses(invokedByAlpha bool, multiaddr *wallet.Account, // then we have invoker witness invokeScript = append( []byte{byte(opcode.PUSHDATA1), 64}, - c.acc.PrivateKey().SignHashable(uint32(magicNumber), tx)..., + c.acc.SignHashable(magicNumber, tx)..., ) w = append(w, transaction.Witness{