# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Added

- Parser for Unified Addresses that validates the address
- Tests for UA parsing from wallets
- Function to scan new transactions using known viewing keys
- Function to identify the owners and VKs needed for tx scans

### Changed

- MongoDB driver updated to support MongoDB 6.
- Full validation of Sapling addresses to parser.

### Removed

- `makeZcashCall` function moved to the generic `zcash-haskell` library.
- `RpcResponse`, `RpcCall` types moved to the generic `zcash-haskell` library.

## [1.7.0]

### Added

- Parameter to config for number of confirmations for scan
- Endpoint for language for invoices

### Changed

- Modified payment confirmation to use new WooCommerce plugin API endpoint.
- Consolidated the `invdata`, `orderid` and `orderx` endpoints
- The `xerotoken` endpoint uses `session` for authentication
- The order by ID/token endpoint includes shop name

### Fixed

- The viewing key obfuscation of blank viewing keys

## [1.6.0]

### Added

- New JSON serialization for WooTokens.
- New `/api/ownervk` endpoint to save viewing keys
- Use of `zcash-haskell` library to validate Sapling viewing keys

### Changed

- Modified the process of scanning for payments to only scan addresses that have an active ZGo session and have enabled payment confirmations
- Modified the process to mark paid orders to ensure only payments to the shop's wallet get marked as paid
- Modified the `items` endpoint to use the login session to identify records

## [1.5.0] - 2023-05-15

### Added

- `isUserValid` function
- New middleware to validated requests come from an existing user
- New endpoint for the language data of the login page
- New `OwnerData` to represent informational values
- New `OwnerSettings` to abstract configuration settings for owners

### Changed

- Modified API tests to use `session` parameter.
- Modified `api/owner` endpoint to use a specific data structure to create new owners
- Modified `api/owner` endpoint to use session as input

## [1.4.1] - 2023-05-02

### Fixed

- Correct potential node errors when saving viewing keys

## [1.4.0] - 2023-05-02

### Added

- New type for Pro sessions
- New functions to save and read Pro sessions from DB
- New function to turn off Pro session

### Fixed

- Handling of potential failures of RPC calls to `zcashd` ([#6](https://git.vergara.tech/Vergara_Tech/zgo-backend/issues/6)).

## [1.3.0] - 2023-03-16

### Added

- New type to handle UI translation objects
- New endpoints for API to get/set translation
- Tests for translation endpoints
- Formal parser of ZGo-related tokens in memos

### Changed

- Remove old code for PIN generation
- Xero reference field to include the amount of ZEC received
- Separate periodic tasks from API server
- Zcash transaction monitoring changed to use memo parser

### Fixed

- Xero token generation for brand new users

## [1.2.5] - 2023-02-01

### Fixed

- Replaced the PIN generation with the cryptographically-secure `crypto-rng`.

## [1.2.4] - 2023-01-30

### Changed

- Enhance payments to account for early payments on active sessions.

## [1.2.3] - 2023-01-27

### Changed

- Implement `BLAKE3` for PIN hashing.

## [1.2.2] - 2023-01-25

### Fixed

- Corrected selection criteria for expiring owners query

## [1.2.1] - 2023-01-24

### Added

- New configuration fields for SMTP

### Fixed

- Owner expiration query
- Xero token expiration query

## [1.2.0] - 2023-01-09

### Added

- New utility to refresh Xero tokens periodically.
- New module for WooCommerce interaction.
- New `/auth` endpoint to authenticate with the WooCommerce plugin and corresponding tests
- New `/woopayment` endpoint to generate a new order from the WooCommerce plugin and corresponding tests
- New `/wootoken` endpoint to generate a new token and query the token from the database.

### Changed

- Refactored code for requesting Xero tokens to make it reusable.
- Changed API authentication to allow for endpoints that don't require an `Authorization` header to support the WooCommerce integration
- Enhanced the on-chain order confirmation functionality to support WooCommerce integration and future integrations.

## [1.1.1] - 2022-10-08

### Changed

- Refactored the `api/owner` POST endpoint.
- Added logic to remove extra whitespace from viewing key strings

## [1.1.0] - 2022-10-01

### Added

- Feature to record a payment when detected on-chain
- Function to record a payment in Xero
- Tests for Xero account code
- Fields in `XeroToken` for Xero payment account code
- Support for the YWallet memo format
- API endpoint to request a Xero invoice
- API endpoint to generate ZGo order from external invoice
- Type `XeroInvResponse`
- Type `XeroInvoice`
- Type `XeroToken`
- Type `Xero`
- API endpoint to query Xero configuration
- Field `crmToken` for `Owner`
- Field `externalInvoice` and `shortCode` for `Order`

### Changed

- Improved error handling for API server
- CoinGecko price feed to include New Zealand dollar (NZD)

## [1.0.0] - 2022-07-27

### Added

- New functionality to read transactions for the given viewing keys
- New functionality to mark orders as paid once payment is found on-chain
- New `Config` type to house the configuration parameters
- New field in `Owner` type to store toggle for payment confirmation
- New field in `Owner` type to store viewing key

### Changed

- Added chronological sorting to list of orders
- Added logic in `/api/owner` endpoint to validate viewing key before saving
- Updated tests for `/api/owner` to account for invalid viewing keys
- Added alphabetic sorting to list of items
- Refactored code to use new `Config` type
- Enhance `decodeHexText` to support Unicode
- Enhance `encodeHexText` to support Unicode
- Update tests for encode/decode of memos

### Fixed

- Fixed the PIN generation
- Fixed calculation of order total to ensure 8 decimal places
- Fixed test for looking for an order with incorrect ID
- Fixed payment scan to focus only on new transactions

## [0.1.0.2] - 2022-05-25

### Added

- Changelog
- `paid` field in ZGoOrder type
- Test for `api/order/:id` endpoint with an invalid ID

### Fixed

- Bug #1: crash when invalid ID was provided to `api/order/:id`

## [0.1.0.1] - 2022-05-20

### Added

- Parametrized fullnode credentials

## [0.1.0.0] - 2022-05-19

### Added

- BOSL license
- API end points
  - Country
  - Block
  - Node address
  - User
  - Owner
  - Order
  - Item
- Processing
  - Zcash transactions to ZGo items
  - Convert login memos to Users
  - Mark Owners as paid when payment is found on chain
  - Mark Owners as expired when expiration date is reached