Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bitcoin testnet explorer not working #565

Open
s-h-ubham opened this issue Dec 8, 2024 · 1 comment
Open

Bitcoin testnet explorer not working #565

s-h-ubham opened this issue Dec 8, 2024 · 1 comment

Comments

@s-h-ubham
Copy link

I was trying to hit webhook on bitcoin testnet, but was not able to get any response. The bitcoin address that I registered on blockCyper to get response is tb1qzhzke5anja85xpqt4vg2qz27xw4xelfe4zzf0t. I did a transaction from testnet faucet to my address and waited for about 2 hours but didn't get any response. After debugging for a long time I got to know the blocks on the blockCypher explorer were not updated for bitcoin testnet. I don't know if the delay in my response is related to something to this or something else.

code snippet:

@Post("register-webhook")
  async registerWebhook(
    @Body() body: { webhookUrl: string,address: string},
    @Res() res: Response,
    @Response() response: any
  ) {
    console.log("webhookUrl::::",body.webhookUrl)
    console.log("webhookUrl::::",body.address)


    try {
      const result = await this.blockcypherService.registerWebhook(
        body.address, @Post("register-webhook")
  async registerWebhook(
    @Body() body: { webhookUrl: string,address: string},
    @Res() res: Response,
    @Response() response: any
  ) {
    console.log("webhookUrl::::",body.webhookUrl)
    console.log("webhookUrl::::",body.address)


    try {
      const result = await this.blockcypherService.registerWebhook(
        body.address,
        body.webhookUrl
      );
      return successResponse("Webhook registered successfully", result, response);
   
    } catch (error) {
      return failResponse(true, error?.message, response);
    }
  }
  @Post("webhook")
  handleWebhook(@Req() req: any, @Res() res: Response) {
    const { address, txid, confirmations } = req.body;

    console.log("Transaction received:");
    console.log(`Address: ${address}`);
    console.log(`Transaction ID: ${txid}`);
    console.log(`Confirmations: ${confirmations}`);

    // TODO: Process the transaction (e.g., update database, send email)
    // res.status(200).send("Webhook received");
    return successResponse("Webhook registered successfully");
  }
        body.webhookUrl
      );
      return successResponse("Webhook registered successfully", result, response);
   
    } catch (error) {
      return failResponse(true, error?.message, response);
    }
  }
  @Post("webhook")
  handleWebhook(@Req() req: any, @Res() res: Response) {
    const { address, txid, confirmations } = req.body;

    console.log("Transaction received:");
    console.log(`Address: ${address}`);
    console.log(`Transaction ID: ${txid}`);
    console.log(`Confirmations: ${confirmations}`);

    // TODO: Process the transaction (e.g., update database, send email)
    // res.status(200).send("Webhook received");
    return successResponse("Webhook registered successfully");
  }
async registerWebhook(address: string, webhookUrl: string): Promise<any> {
    const payload = {
      event: "unconfirmed-tx", // Trigger on confirmed transactions
      address, // Bitcoin address to monitor
      url: webhookUrl, // Your server's webhook endpoint
    };

    try {
      const response = await [axios.post](http://axios.post/)(
        `${this.baseUrl}?token=${this.apiToken}`,
        payload
      );
      console.log("Webhook registered successfully:", response.data);
      return response.data;
    } catch (error) {
      console.error(
        "Error registering webhook:",
        error.response?.data || error.message
      );
      throw new Error("Failed to register webhook");
    }
  }

Can someone please help me with this.

@S-Brenda
Copy link

@s-h-ubham,

This will be reviewed by the support team. Visit the live support page to initiate a chat with an agent for further assistance via live chat.
Regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants