* feat: add market hour configuration for optimal payment timing
This commit adds market hour configuration to help users determine optimal
times for making payments with lower fees. The configuration is managed
through environment variables and exposed via the GetInfo RPC.
Changes:
- Add MarketHour message type to protobuf service definition
- Add market hour configuration fields to Config struct
- Update covenant and covenantless services to handle market hour data
- Extend GetInfo RPC response to include market hour information
- Set default market hour period to 24 hours
- Initialize market hour fields after other service fields
Configuration:
- ARK_FIRST_MARKET_HOUR: Initial market hour timestamp
(default: current server start time)
- ARK_MARKET_HOUR_PERIOD: Time between market hours in seconds
(default: 86400)
- ARK_MARKET_HOUR_ROUND_LIFETIME: Round lifetime for market hours
(default: 0, falls back to ARK_ROUND_LIFETIME)
* feat: add admin RPC for updating market hour configuration
Add new UpdateMarketHour RPC to AdminService for configuring market hour parameters:
- Add request/response messages to admin.proto
- Add UpdateMarketHour method to Service interface
- Implement market hour updates in covenant and covenantless services
- Add validation for market hour parameters
- Implement admin gRPC handler
The RPC allows updating:
- First market hour timestamp
- Market hour period
- Market hour round lifetime (optional, defaults to round lifetime
* feat: add market hour persistence with sqlite
- Add MarketHourRepo interface in domain layer
- Implement market hour persistence using SQLite
- Add market hour queries to sqlc/query.sql
- Update service initialization to load market hours from DB
- Add fallback to config values if no DB entry exists
- Update RepoManager interface with new MarketHourRepo method
* SDK - GetTransactionsStream add to rest/grpc
no session, pattern or user messages provided
* SDK - AppDataRepository added, store refactor
This patch introduces a significant refactor of the Ark SDK codebase. The primary changes involve:
1. **Domain Package Introduction**: A new `domain` package has been created under `store`, encapsulating core data structures and interfaces such as `ConfigData`, `Transaction`, `SdkRepository`, and various repository interfaces. This enhances modularity and separation of concerns.
2. **Replacement of Store with Domain Objects**: All references to the `store` package's `StoreData` have been replaced with `domain.ConfigData`. This change reflects a shift towards using domain-driven design, where the core business logic is represented by domain objects.
3. **Repository Pattern Implementation**: The code has been refactored to use repositories for accessing and managing data. `ConfigRepository` and `TransactionRepository` interfaces are introduced, providing methods for managing configuration data and transactions, respectively.
4. **New Storage Implementations**: New storage implementations using BadgerDB are introduced for persisting transactions (`transaction_repository.go`). This change indicates a move towards more robust and scalable data storage solutions.
5. **Service Layer Introduction**: A service layer (`service.go`) is introduced, which acts as a facade for the underlying data repositories. This layer abstracts the data access logic and provides a unified interface for interacting with configuration and transaction data.
6. **Code Simplification and Cleanup**: The patch removes redundant code and simplifies the existing codebase by consolidating store-related logic and enhancing the overall structure of the code.
7. **Testing Enhancements**: Test cases are updated to reflect the changes in the data access layer, ensuring that the new repository pattern and domain objects are properly tested.
Overall, this refactor aims to improve the maintainability, scalability, and testability of the codebase by adopting best practices such as domain-driven design, repository pattern, and separation of concerns.
* 'SDK listen for tx stream
This diff represents a substantial refactor and enhancement of the `ark-sdk` client, which involves modifications to multiple files, primarily in the `pkg/client-sdk` and `server/internal/core/application` directories. Here's a summary of the key changes:
1. **Configuration and Initialization**:
- Refactor to replace file-based configuration store with a domain-based approach.
- Introduced `ListenTransactionStream` configuration to allow real-time transaction event listening.
2. **Client SDK Enhancements**:
- The client SDK now supports asynchronous transaction streaming and handling.
- Introduced methods to get transaction event channels and stop the client gracefully.
- Expanded the `ArkClient` interface to include these new functionalities.
3. **Transaction Handling**:
- Added support for listening to and processing transaction events in real-time.
- Implemented methods to handle different types of transactions, including boarding, redeem, and round transactions.
- Expanded the `Transaction` struct to include more metadata, such as `BoardingVOut`.
4. **Repository Changes**:
- Introduced `VtxoRepository` for managing VTXO-related operations.
- Modified `AppDataRepository` to include `VtxoRepository`.
5. **Example and Test Adjustments**:
- Updated example code to utilize the new transaction streaming capabilities.
- Adjusted tests to reflect changes in client initialization and configuration handling.
6. **Dependency Updates**:
- Updated `go.mod` and `go.sum` to include new dependencies such as `badger` for data storage and potentially updated versions of existing packages.
These changes collectively enhance the functionality of the `ark-sdk` client by enabling real-time transaction handling, improving configuration management, and providing a more robust and scalable client architecture. This update seems to be aimed at improving the efficiency and responsiveness of the client application, likely in response to increased demands for real-time data processing and analysis.'
* merge
* go work sync
* test fix
* Tiny refactor (#2)
* tiny refactor
* renaming
* Renamings
* Fixes (#3)
---------
Co-authored-by: Pietralberto Mazza <18440657+altafan@users.noreply.github.com>
* RPC GetPaymentsStream
This introduces a new feature to the ArkService API that allows clients to subscribe to payment events. Here's a breakdown of the changes:
1. **OpenAPI Specification (`service.swagger.json`):**
- A new endpoint `/v1/payments` is added to the API, supporting a `GET` operation for streaming payment events.
- New definitions `v1GetPaymentsStreamResponse`, `v1RoundPayment`, and `v1AsyncPayment` are added to describe the structure of the streaming responses.
2. **Protobuf Definition (`service.proto`):**
- Added a new RPC method `GetPaymentsStream` that streams `GetPaymentsStreamResponse` messages.
- Defined new message types: `GetPaymentsStreamRequest`, `GetPaymentsStreamResponse`, `RoundPayment`, and `AsyncPayment`.
3. **Generated Protobuf Code (`service.pb.go`, `service.pb.gw.go`, `service_grpc.pb.go`):**
- The generated code is updated to include the new RPC method and message types.
- The gateway code includes functions to handle HTTP requests and responses for the new streaming endpoint.
4. **Application Logic (`covenant.go`, `covenantless.go`):**
- New payment events channels are introduced (`paymentEventsCh`).
- Payment events are propagated to these channels when a round is finalized or an async payment is completed.
- New event types `RoundPaymentEvent` and `AsyncPaymentEvent` are defined, implementing a `PaymentEvent` interface.
5. **gRPC Handlers (`arkservice.go`):**
- Added logic to handle `GetPaymentsStream` requests and manage payment listeners.
- A new goroutine is started to listen to payment events and forward them to active listeners.
Overall, this patch extends the ArkService to support real-time streaming of payment events, allowing clients to receive updates on both round payments and async payments as they occur.
* Move emit events in updateVtxoSet & Use generics and parsers (#1)
* Move sending event to updateVtxoSet
* Use generics and parsers
* pr review refactor
* pr review refactor
* fix
---------
Co-authored-by: Pietralberto Mazza <18440657+altafan@users.noreply.github.com>
* failing test
* fix duplicate input register
* fix btc-embedded coin selection
* rename test
* add checks in failing test case
* fixes GetEventStream
* add TODO comment in createPoolTx
* update with master changes
* fix server unit test
* increase liquidity of testing ASP
* simplify AliceSeveralPaymentsBob test
* Drop unused ComputeOutputScript & use ParseTaprootScript internally
* Add pending field to vtxo domain
* Add check to handle async change as claimed vtxo & Move check to prevent spending penidng vtxos to app level
* Rename utils.go to parser.go & Fixes
* Ignore sent-and-reversible vtxos in ListVtxos
* Fixes
Co-authored-by: Louis Singer <louisinger@users.noreply.github.com>
* Fix e2e test
Co-authored-by: Louis Singer <louisinger@users.noreply.github.com>
Co-authored-by: João Bordalo <bordalix@users.noreply.github.com>
* Fix
* Add PendingChange field to vtxo
* Add PendingChange field to Transaction
* Fixes
* Remove logs
---------
Co-authored-by: Louis Singer <louisinger@users.noreply.github.com>
Co-authored-by: João Bordalo <bordalix@users.noreply.github.com>
* [proto] add APIs to send and receive musig2 signing data
* [common] add serialization functions for nonces and signatures
* [application] implements tree signing
* fix: remove old debug logs
* [proto] cleaning
* [common] fix musig2.go
* [application] fixes and logs
* [interface] fix: stop forwarding 2 times the events
* [client] add musig2 support + sign the tree when joining a round
* [interface] add new APIs into permissions.go
* [application][proto] rework PingResponse (return all events type)
* [common] split SetKeys into 2 distinct methods
* [client] fixes according to musig2.go changes
* [sdk] support tree signing + new PingResponse
* [sdk] fixes
* [application] revert event channel type
* [application] use domain.RoundEvent as lastEvent type
* [application] remove IsCovenantLess
* comments
* [application] revert roundAborted changes
* [interface] remove bitcointree dependencie
* api-spec: move the api-spec to root and init go.mod
* go mod tidy
* move buf files in the root as well
* gh action for api-spec changes only
* gh action for api-spec on push and pr
* introduce go.work and remove all replaces
* solve dependencies and force btcd/btcec@v2.3.3
* go work sync
* force btcd/btcec@v2.3.3
* go mod tidy
* Add method to compute vtxo taproot script
* Drop debug logs
* Refactor client:
* Remove dep from stubs in interface
* Remove redeem branch, out of scope (moved to ark client)
* Add example for covenant and covenantless sdk
* Simplify explorer - No need for bitcoin and liquid impls
* Refactor wallet:
* wallet struct for common operations (create, lock/unlock, getType, isLocked)
* liquidWallet struct for liquid operations (derive/get addresses, sign tx)
* bitcoinWallet struct for bitcoin operations (derive/get addresses, sign tx)
* Update utils:
* drop methods to parse tree (moved to ark client)
* add methods for encryption, network parsing, key generation
* add methods for covenant/covenantless redeem branches (move to common?)
* Add support for covenantless sdk:
* move interface to dedicated file
* arkCLient struct for common operations (Init, lock/unlock, get config data, receive)
* covenantArkClient struct for covenant operations (onboard, balance, send, redeem)
* covenantlessArkClient struct for covenantless operations (onboard, balance, send, redeem)
* Fix wasm
* Fixes
* Make explorer use utils.Cache
* Renamings
* Lint
* Fix e2e tests
* Fix e2e test