Service for managing webhooks in Satoshi Showdown. Handles the lifecycle of webhooks including creation, processing, and deletion. Interacts with the BlockCypher API for blockchain event monitoring and manages local database records for webhooks. This service is integral to the platform's event-driven architecture, particularly for monitoring blockchain transactions.
- Source:
Requires
- module:models/webhookModel
- module:services/transactionService
- module:services/walletService
- module:utils/apiUtil
- module:utils/errorUtil
- module:utils/logUtil
Methods
(async, inner) createWebhook(address, transactionRef) → {Promise.<Object>}
Creates a new webhook in the Satoshi Showdown application and registers it with BlockCypher. This webhook monitors blockchain events for a specific address and tracks transaction confirmations.
Parameters:
Name | Type | Description |
---|---|---|
address |
string | The blockchain address to monitor. |
transactionRef |
string | The reference ID of the associated transaction. |
- Source:
Throws:
-
If an error occurs during webhook creation or registration.
- Type
- Error
Returns:
A promise resolving to the newly created webhook object.
- Type
- Promise.<Object>
(async, inner) processWebhook(urlId, headers, data)
Processes a received webhook by updating its status and associated transaction and wallet records. Efficiently handles the headers, body, and confirmation status of the incoming webhook data.
Parameters:
Name | Type | Description |
---|---|---|
urlId |
string | The unique identifier of the webhook. |
headers |
Object | The HTTP headers of the incoming webhook request. |
data |
Object | The JSON payload of the webhook request. |
- Source:
Throws:
-
If the webhook with the specified URL ID is not found.
- Type
- NotFoundError