mirror of
https://github.com/lightninglabs/pool.git
synced 2026-08-16 13:00:39 +02:00
account+order: use proper account batch key when storing batch
This commit is contained in:
parent
a25b1bdaa4
commit
8a38d2ad2e
2 changed files with 5 additions and 13 deletions
|
|
@ -195,11 +195,11 @@ func ExpiryModifier(expiry uint32) Modifier {
|
|||
}
|
||||
}
|
||||
|
||||
// BatchKeyModifier is a functional option that modifies the batch key of an
|
||||
// account.
|
||||
func BatchKeyModifier(batchKey *btcec.PublicKey) Modifier {
|
||||
// IncrementBatchKey is a functional option that increments the batch key of an
|
||||
// account by adding the curve's base point.
|
||||
func IncrementBatchKey() Modifier {
|
||||
return func(account *Account) {
|
||||
account.BatchKey = batchKey
|
||||
account.BatchKey = clmscript.IncrementKey(account.BatchKey)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ import (
|
|||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/lightninglabs/agora/client/account"
|
||||
"github.com/lightninglabs/agora/client/clmrpc"
|
||||
"github.com/lightninglabs/agora/client/clmscript"
|
||||
)
|
||||
|
||||
// batchStorer is a type that implements BatchStorer and can persist a batch to
|
||||
|
|
@ -60,13 +59,6 @@ func (s *batchStorer) Store(batch *Batch) error {
|
|||
orderIndex++
|
||||
}
|
||||
|
||||
// Before we can update our accounts, we need to know the next batch ID.
|
||||
batchKey, err := btcec.ParsePubKey(batch.ID[:], btcec.S256())
|
||||
if err != nil {
|
||||
return fmt.Errorf("error parsing batch ID: %v", err)
|
||||
}
|
||||
nextBatchKey := clmscript.IncrementKey(batchKey)
|
||||
|
||||
// Next create our account modifiers.
|
||||
accounts := make([]*account.Account, len(batch.AccountDiffs))
|
||||
accountModifiers := make([][]account.Modifier, len(accounts))
|
||||
|
|
@ -93,7 +85,7 @@ func (s *batchStorer) Store(batch *Batch) error {
|
|||
Index: uint32(diff.OutpointIndex),
|
||||
Hash: batch.BatchTX.TxHash(),
|
||||
}),
|
||||
account.BatchKeyModifier(nextBatchKey),
|
||||
account.IncrementBatchKey(),
|
||||
)
|
||||
|
||||
// The account was fully spent on-chain. We need to wait for the
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue