[] neofs-adm: Fix signature creation for multiactor scenario

`SignTx` from neo-go appended verification script only if `Scripts`
array was not completely filled.

```
can't persist transactions: transaction b9cd02fb81721c7316c908687301eeaf8ef384e381476632c24a77bdf9ffacd5 failed to verify: witness : unknown verification contract
```

Signed-off-by: Evgenii Stratonikov <evgeniy@morphbits.ru>
This commit is contained in:
Evgenii Stratonikov 2022-10-25 11:06:56 +03:00 committed by fyrchik
parent 2dcf8d51be
commit 4fe1aad30f

View file

@ -130,13 +130,15 @@ func (c *initializeContext) multiSign(tx *transaction.Transaction, accType strin
return fmt.Errorf("incomplete signature: %w", err) return fmt.Errorf("incomplete signature: %w", err)
} }
if len(tx.Scripts) == 0 {
tx.Scripts = make([]transaction.Witness, len(tx.Signers))
}
for i := range tx.Signers { for i := range tx.Signers {
if tx.Signers[i].Account == h { if tx.Signers[i].Account == h {
tx.Scripts[i] = *w if i < len(tx.Scripts) {
tx.Scripts[i] = *w
} else if i == len(tx.Scripts) {
tx.Scripts = append(tx.Scripts, *w)
} else {
panic("BUG: invalid signing order")
}
return nil return nil
} }
} }