account: request signature before updating account due to modification

This ensures that a trader cannot progress their account state without
the server acknowledging their request.
This commit is contained in:
Wilmer Paulino 2020-11-10 12:16:43 -08:00
parent 7ad78efe34
commit c6ddfa1593
No known key found for this signature in database
GPG key ID: 6DF57B9F9514972F

View file

@ -1262,15 +1262,11 @@ func (m *Manager) spendAccount(ctx context.Context, account *Account,
}))
}
prevAccountState := account.Copy()
if err := m.cfg.Store.UpdateAccount(account, modifiers...); err != nil {
return nil, nil, err
}
// If we require the auctioneer's signature, request it now.
// If we require the auctioneer's signature, request it now before
// updating the account on disk.
if witnessType == multiSigWitness {
witness, err := m.constructMultiSigWitness(
ctx, prevAccountState, spendPkg, modifiers, isClose,
ctx, account, spendPkg, modifiers, isClose,
)
if err != nil {
return nil, nil, err
@ -1278,6 +1274,11 @@ func (m *Manager) spendAccount(ctx context.Context, account *Account,
spendPkg.tx.TxIn[spendPkg.accountInputIdx].Witness = witness
}
prevAccountState := account.Copy()
if err := m.cfg.Store.UpdateAccount(account, modifiers...); err != nil {
return nil, nil, err
}
// As this is a generic account modification, we'll add some additional
// information to make accounting for this transaction a bit easier.
deposit := prevAccountState.Value < account.Value