diff --git a/account/interface.go b/account/interface.go index 325d878..40b43be 100644 --- a/account/interface.go +++ b/account/interface.go @@ -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) } } diff --git a/order/batch_storer.go b/order/batch_storer.go index c30299a..34dfe09 100644 --- a/order/batch_storer.go +++ b/order/batch_storer.go @@ -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