mirror of
https://github.com/lightninglabs/pool.git
synced 2026-08-18 13:08:33 +02:00
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:
parent
7ad78efe34
commit
c6ddfa1593
1 changed files with 8 additions and 7 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue