wallet: don't fail in SignTx when no contract provided

Unfortunately valid NEP-6 can have no contract inside of account, so this
should be accounted for.
This commit is contained in:
Roman Khimov 2022-08-24 15:36:52 +03:00
parent 2f8896f7a1
commit 7a930a8e11

View file

@ -84,6 +84,9 @@ func NewAccount() (*Account, error) {
// SignTx signs transaction t and updates it's Witnesses.
func (a *Account) SignTx(net netmode.Magic, t *transaction.Transaction) error {
if a.Contract == nil {
return errors.New("account has no contract")
}
if len(a.Contract.Parameters) == 0 {
if len(t.Signers) != len(t.Scripts) { // Sequential signing vs. existing scripts.
t.Scripts = append(t.Scripts, transaction.Witness{})