Skip to content

Commit

Permalink
chore(BUX-586): renames spvwalletmodels to models, renames SPV to Spv…
Browse files Browse the repository at this point in the history
…WalletEngine
  • Loading branch information
jakubmkowalski committed Feb 19, 2024
1 parent b31ad16 commit 96b4aac
Show file tree
Hide file tree
Showing 52 changed files with 171 additions and 173 deletions.
2 changes: 1 addition & 1 deletion actions/access_keys/count.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func (a *Action) count(w http.ResponseWriter, req *http.Request, _ httprouter.Pa

// Record a new transaction (get the hex from parameters)a
var count int64
if count, err = a.Services.SPV.GetAccessKeysByXPubIDCount(
if count, err = a.Services.SpvWalletEngine.GetAccessKeysByXPubIDCount(
req.Context(),
reqXPubID,
metadata,
Expand Down
2 changes: 1 addition & 1 deletion actions/access_keys/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func (a *Action) create(w http.ResponseWriter, req *http.Request, _ httprouter.P
metadata := params.GetJSON("metadata")

// Create a new accessKey
accessKey, err := a.Services.SPV.NewAccessKey(
accessKey, err := a.Services.SpvWalletEngine.NewAccessKey(
req.Context(),
reqXPub,
engine.WithMetadatas(metadata),
Expand Down
2 changes: 1 addition & 1 deletion actions/access_keys/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (a *Action) get(w http.ResponseWriter, req *http.Request, _ httprouter.Para
}

// Get access key
accessKey, err := a.Services.SPV.GetAccessKey(
accessKey, err := a.Services.SpvWalletEngine.GetAccessKey(
req.Context(), reqXPubID, id,
)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion actions/access_keys/revoke.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (a *Action) revoke(w http.ResponseWriter, req *http.Request, _ httprouter.P
}

// Create a new accessKey
accessKey, err := a.Services.SPV.RevokeAccessKey(
accessKey, err := a.Services.SpvWalletEngine.RevokeAccessKey(
req.Context(),
reqXPub,
id,
Expand Down
6 changes: 3 additions & 3 deletions actions/access_keys/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/bitcoin-sv/spv-wallet/actions"
"github.com/bitcoin-sv/spv-wallet/engine"
"github.com/bitcoin-sv/spv-wallet/mappings"
spvwalletmodels "github.com/bitcoin-sv/spv-wallet/models"
"github.com/bitcoin-sv/spv-wallet/models"
"github.com/julienschmidt/httprouter"
apirouter "github.com/mrz1836/go-api-router"
)
Expand Down Expand Up @@ -40,7 +40,7 @@ func (a *Action) search(w http.ResponseWriter, req *http.Request, _ httprouter.P

// Record a new transaction (get the hex from parameters)a
var accessKeys []*engine.AccessKey
if accessKeys, err = a.Services.SPV.GetAccessKeysByXPubID(
if accessKeys, err = a.Services.SpvWalletEngine.GetAccessKeysByXPubID(
req.Context(),
reqXPubID,
metadata,
Expand All @@ -51,7 +51,7 @@ func (a *Action) search(w http.ResponseWriter, req *http.Request, _ httprouter.P
return
}

accessKeyContracts := make([]*spvwalletmodels.AccessKey, 0)
accessKeyContracts := make([]*models.AccessKey, 0)
for _, accessKey := range accessKeys {
accessKeyContracts = append(accessKeyContracts, mappings.MapToAccessKeyContract(accessKey))
}
Expand Down
8 changes: 4 additions & 4 deletions actions/admin/access_keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/bitcoin-sv/spv-wallet/actions"
"github.com/bitcoin-sv/spv-wallet/engine"
"github.com/bitcoin-sv/spv-wallet/mappings"
spvwalletmodels "github.com/bitcoin-sv/spv-wallet/models"
"github.com/bitcoin-sv/spv-wallet/models"
"github.com/julienschmidt/httprouter"
apirouter "github.com/mrz1836/go-api-router"
)
Expand Down Expand Up @@ -37,7 +37,7 @@ func (a *Action) accessKeysSearch(w http.ResponseWriter, req *http.Request, _ ht
}

var accessKeys []*engine.AccessKey
if accessKeys, err = a.Services.SPV.GetAccessKeys(
if accessKeys, err = a.Services.SpvWalletEngine.GetAccessKeys(
req.Context(),
metadata,
conditions,
Expand All @@ -47,7 +47,7 @@ func (a *Action) accessKeysSearch(w http.ResponseWriter, req *http.Request, _ ht
return
}

accessKeyContracts := make([]*spvwalletmodels.AccessKey, 0)
accessKeyContracts := make([]*models.AccessKey, 0)
for _, accessKey := range accessKeys {
accessKeyContracts = append(accessKeyContracts, mappings.MapToAccessKeyContract(accessKey))
}
Expand Down Expand Up @@ -78,7 +78,7 @@ func (a *Action) accessKeysCount(w http.ResponseWriter, req *http.Request, _ htt
}

var count int64
if count, err = a.Services.SPV.GetAccessKeysCount(
if count, err = a.Services.SpvWalletEngine.GetAccessKeysCount(
req.Context(),
metadata,
conditions,
Expand Down
4 changes: 2 additions & 2 deletions actions/admin/destinations.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (a *Action) destinationsSearch(w http.ResponseWriter, req *http.Request, _
}

var destinations []*engine.Destination
if destinations, err = a.Services.SPV.GetDestinations(
if destinations, err = a.Services.SpvWalletEngine.GetDestinations(
req.Context(),
metadata,
conditions,
Expand Down Expand Up @@ -72,7 +72,7 @@ func (a *Action) destinationsCount(w http.ResponseWriter, req *http.Request, _ h
}

var count int64
if count, err = a.Services.SPV.GetDestinationsCount(
if count, err = a.Services.SpvWalletEngine.GetDestinationsCount(
req.Context(),
metadata,
conditions,
Expand Down
16 changes: 8 additions & 8 deletions actions/admin/paymail_addresses.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ func (a *Action) paymailGetAddress(w http.ResponseWriter, req *http.Request, _ h
return
}

opts := a.Services.SPV.DefaultModelOptions()
opts := a.Services.SpvWalletEngine.DefaultModelOptions()

paymailAddress, err := a.Services.SPV.GetPaymailAddress(req.Context(), address, opts...)
paymailAddress, err := a.Services.SpvWalletEngine.GetPaymailAddress(req.Context(), address, opts...)
if err != nil {
apirouter.ReturnResponse(w, req, http.StatusExpectationFailed, err.Error())
return
Expand Down Expand Up @@ -66,7 +66,7 @@ func (a *Action) paymailAddressesSearch(w http.ResponseWriter, req *http.Request
}

var paymailAddresses []*engine.PaymailAddress
if paymailAddresses, err = a.Services.SPV.GetPaymailAddresses(
if paymailAddresses, err = a.Services.SpvWalletEngine.GetPaymailAddresses(
req.Context(),
metadata,
conditions,
Expand Down Expand Up @@ -102,7 +102,7 @@ func (a *Action) paymailAddressesCount(w http.ResponseWriter, req *http.Request,
}

var count int64
if count, err = a.Services.SPV.GetPaymailAddressesCount(
if count, err = a.Services.SpvWalletEngine.GetPaymailAddressesCount(
req.Context(),
metadata,
conditions,
Expand Down Expand Up @@ -153,14 +153,14 @@ func (a *Action) paymailCreateAddress(w http.ResponseWriter, req *http.Request,
return
}

opts := a.Services.SPV.DefaultModelOptions()
opts := a.Services.SpvWalletEngine.DefaultModelOptions()

if metadata != nil {
opts = append(opts, engine.WithMetadatas(*metadata))
}

var paymailAddress *engine.PaymailAddress
paymailAddress, err = a.Services.SPV.NewPaymailAddress(req.Context(), xpub, address, publicName, avatar, opts...)
paymailAddress, err = a.Services.SpvWalletEngine.NewPaymailAddress(req.Context(), xpub, address, publicName, avatar, opts...)
if err != nil {
apirouter.ReturnResponse(w, req, http.StatusExpectationFailed, err.Error())
return
Expand Down Expand Up @@ -190,10 +190,10 @@ func (a *Action) paymailDeleteAddress(w http.ResponseWriter, req *http.Request,
return
}

opts := a.Services.SPV.DefaultModelOptions()
opts := a.Services.SpvWalletEngine.DefaultModelOptions()

// Delete a new paymail address
err := a.Services.SPV.DeletePaymailAddress(req.Context(), address, opts...)
err := a.Services.SpvWalletEngine.DeletePaymailAddress(req.Context(), address, opts...)
if err != nil {
apirouter.ReturnResponse(w, req, http.StatusExpectationFailed, err.Error())
return
Expand Down
4 changes: 2 additions & 2 deletions actions/admin/record.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ func (a *Action) transactionRecord(w http.ResponseWriter, req *http.Request, _ h
opts := make([]engine.ModelOps, 0)

// Record a new transaction (get the hex from parameters)
transaction, err := a.Services.SPV.RecordRawTransaction(
transaction, err := a.Services.SpvWalletEngine.RecordRawTransaction(
req.Context(),
hex,
opts...,
)
if err != nil {
if errors.Is(err, datastore.ErrDuplicateKey) {
// already registered, just return the registered transaction
if transaction, err = a.Services.SPV.GetTransactionByHex(req.Context(), hex); err != nil {
if transaction, err = a.Services.SpvWalletEngine.GetTransactionByHex(req.Context(), hex); err != nil {
apirouter.ReturnResponse(w, req, http.StatusUnprocessableEntity, err.Error())
return
}
Expand Down
2 changes: 1 addition & 1 deletion actions/admin/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
// @Router /v1/admin/stats [get]
// @Security x-auth-xpub
func (a *Action) stats(w http.ResponseWriter, req *http.Request, _ httprouter.Params) {
stats, err := a.Services.SPV.GetStats(req.Context())
stats, err := a.Services.SpvWalletEngine.GetStats(req.Context())
if err != nil {
apirouter.ReturnResponse(w, req, http.StatusExpectationFailed, err.Error())
return
Expand Down
8 changes: 4 additions & 4 deletions actions/admin/transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/bitcoin-sv/spv-wallet/actions"
"github.com/bitcoin-sv/spv-wallet/engine"
"github.com/bitcoin-sv/spv-wallet/mappings"
spvwalletmodels "github.com/bitcoin-sv/spv-wallet/models"
"github.com/bitcoin-sv/spv-wallet/models"
"github.com/julienschmidt/httprouter"
apirouter "github.com/mrz1836/go-api-router"
)
Expand Down Expand Up @@ -37,7 +37,7 @@ func (a *Action) transactionsSearch(w http.ResponseWriter, req *http.Request, _
}

var transactions []*engine.Transaction
if transactions, err = a.Services.SPV.GetTransactions(
if transactions, err = a.Services.SpvWalletEngine.GetTransactions(
req.Context(),
metadata,
conditions,
Expand All @@ -47,7 +47,7 @@ func (a *Action) transactionsSearch(w http.ResponseWriter, req *http.Request, _
return
}

contracts := make([]*spvwalletmodels.Transaction, 0)
contracts := make([]*models.Transaction, 0)
for _, transaction := range transactions {
contracts = append(contracts, mappings.MapToTransactionContractForAdmin(transaction))
}
Expand Down Expand Up @@ -78,7 +78,7 @@ func (a *Action) transactionsCount(w http.ResponseWriter, req *http.Request, _ h
}

var count int64
if count, err = a.Services.SPV.GetTransactionsCount(
if count, err = a.Services.SpvWalletEngine.GetTransactionsCount(
req.Context(),
metadata,
conditions,
Expand Down
4 changes: 2 additions & 2 deletions actions/admin/utxos.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (a *Action) utxosSearch(w http.ResponseWriter, req *http.Request, _ httprou
}

var utxos []*engine.Utxo
if utxos, err = a.Services.SPV.GetUtxos(
if utxos, err = a.Services.SpvWalletEngine.GetUtxos(
req.Context(),
metadata,
conditions,
Expand Down Expand Up @@ -72,7 +72,7 @@ func (a *Action) utxosCount(w http.ResponseWriter, req *http.Request, _ httprout
}

var count int64
if count, err = a.Services.SPV.GetUtxosCount(
if count, err = a.Services.SpvWalletEngine.GetUtxosCount(
req.Context(),
metadata,
conditions,
Expand Down
4 changes: 2 additions & 2 deletions actions/admin/xpubs.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (a *Action) xpubsSearch(w http.ResponseWriter, req *http.Request, _ httprou
}

var xpubs []*engine.Xpub
if xpubs, err = a.Services.SPV.GetXPubs(
if xpubs, err = a.Services.SpvWalletEngine.GetXPubs(
req.Context(),
metadata,
conditions,
Expand Down Expand Up @@ -73,7 +73,7 @@ func (a *Action) xpubsCount(w http.ResponseWriter, req *http.Request, _ httprout
}

var count int64
if count, err = a.Services.SPV.GetXPubsCount(
if count, err = a.Services.SpvWalletEngine.GetXPubsCount(
req.Context(),
metadata,
conditions,
Expand Down
2 changes: 1 addition & 1 deletion actions/destinations/count.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func (a *Action) count(w http.ResponseWriter, req *http.Request, _ httprouter.Pa

// Record a new transaction (get the hex from parameters)
var count int64
if count, err = a.Services.SPV.GetDestinationsByXpubIDCount(
if count, err = a.Services.SpvWalletEngine.GetDestinationsByXpubIDCount(
req.Context(),
reqXPubID,
metadata,
Expand Down
6 changes: 3 additions & 3 deletions actions/destinations/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func (a *Action) create(w http.ResponseWriter, req *http.Request, _ httprouter.P

// Get the xPub from the request (via authentication)
reqXPub, _ := engine.GetXpubFromRequest(req)
xPub, err := a.Services.SPV.GetXpub(req.Context(), reqXPub)
xPub, err := a.Services.SpvWalletEngine.GetXpub(req.Context(), reqXPub)
if err != nil {
apirouter.ReturnResponse(w, req, http.StatusUnprocessableEntity, err.Error())
return
Expand All @@ -53,15 +53,15 @@ func (a *Action) create(w http.ResponseWriter, req *http.Request, _ httprouter.P
metadata[engine.ReferenceIDField] = referenceID
}

opts := a.Services.SPV.DefaultModelOptions()
opts := a.Services.SpvWalletEngine.DefaultModelOptions()

if metadata != nil {
opts = append(opts, engine.WithMetadatas(metadata))
}

// Get a new destination
var destination *engine.Destination
if destination, err = a.Services.SPV.NewDestination(
if destination, err = a.Services.SpvWalletEngine.NewDestination(
req.Context(),
xPub.RawXpub(),
uint32(0), // todo: use a constant? protect this?
Expand Down
6 changes: 3 additions & 3 deletions actions/destinations/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ func (a *Action) get(w http.ResponseWriter, req *http.Request, _ httprouter.Para
var destination *engine.Destination
var err error
if id != "" {
destination, err = a.Services.SPV.GetDestinationByID(
destination, err = a.Services.SpvWalletEngine.GetDestinationByID(
req.Context(), reqXPubID, id,
)
} else if address != "" {
destination, err = a.Services.SPV.GetDestinationByAddress(
destination, err = a.Services.SpvWalletEngine.GetDestinationByAddress(
req.Context(), reqXPubID, address,
)
} else {
destination, err = a.Services.SPV.GetDestinationByLockingScript(
destination, err = a.Services.SpvWalletEngine.GetDestinationByLockingScript(
req.Context(), reqXPubID, lockingScript,
)
}
Expand Down
6 changes: 3 additions & 3 deletions actions/destinations/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/bitcoin-sv/spv-wallet/actions"
"github.com/bitcoin-sv/spv-wallet/engine"
"github.com/bitcoin-sv/spv-wallet/mappings"
spvwalletmodels "github.com/bitcoin-sv/spv-wallet/models"
"github.com/bitcoin-sv/spv-wallet/models"
"github.com/julienschmidt/httprouter"
apirouter "github.com/mrz1836/go-api-router"
)
Expand Down Expand Up @@ -40,7 +40,7 @@ func (a *Action) search(w http.ResponseWriter, req *http.Request, _ httprouter.P

// Record a new transaction (get the hex from parameters)a
var destinations []*engine.Destination
if destinations, err = a.Services.SPV.GetDestinationsByXpubID(
if destinations, err = a.Services.SpvWalletEngine.GetDestinationsByXpubID(
req.Context(),
reqXPubID,
metadata,
Expand All @@ -51,7 +51,7 @@ func (a *Action) search(w http.ResponseWriter, req *http.Request, _ httprouter.P
return
}

contracts := make([]*spvwalletmodels.Destination, 0)
contracts := make([]*models.Destination, 0)
for _, destination := range destinations {
contracts = append(contracts, mappings.MapToDestinationContract(destination))
}
Expand Down
6 changes: 3 additions & 3 deletions actions/destinations/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ func (a *Action) update(w http.ResponseWriter, req *http.Request, _ httprouter.P
var destination *engine.Destination
var err error
if id != "" {
destination, err = a.Services.SPV.UpdateDestinationMetadataByID(
destination, err = a.Services.SpvWalletEngine.UpdateDestinationMetadataByID(
req.Context(), reqXPubID, id, metadata,
)
} else if address != "" {
destination, err = a.Services.SPV.UpdateDestinationMetadataByAddress(
destination, err = a.Services.SpvWalletEngine.UpdateDestinationMetadataByAddress(
req.Context(), reqXPubID, address, metadata,
)
} else {
destination, err = a.Services.SPV.UpdateDestinationMetadataByLockingScript(
destination, err = a.Services.SpvWalletEngine.UpdateDestinationMetadataByLockingScript(
req.Context(), reqXPubID, lockingScript, metadata,
)
}
Expand Down
Loading

0 comments on commit 96b4aac

Please sign in to comment.