Setting BTC Pay Server invoice expiration time to never?

468 views Asked by At

This is a follow up question to this post but my question is more programming related so I'm hoping this is the right place to post it.

I too am trying to use BTC Pay Server as a wallet. Thera are two problems:

  1. As described in the article, you have to specify an amount when creating an invoice.
  2. It has a security feature that basically results in you not being able to re-use deposit addresses.

The workaround for problem 1 is to set the invoice amount to 0.000001 BTC. So low that the client will always overpay. That works for me to.

But my problem is that address must not expire ever. I checked the code:

  1. Here you can see the Invoice object.
  2. Here you can see the code in use.

It looks like I might be able to use this:

public function setExpirationTime($expirationTime)
{
    if (is_a($expirationTime, 'DateTime')) {
        $this->expirationTime = $expirationTime;
    } else if (is_numeric($expirationTime)) {
        $expirationDateTime = new \DateTime('', new \DateTimeZone("UTC"));
        $expirationDateTime->setTimestamp($expirationTime);
        $this->expirationTime = $expirationDateTime;
    }
    return $this;
}

And set the expiration time to the year 3000. So my questions are:

  1. Will BTC Pay server ditch my address if I attempt to use this to make it never expire?
  2. Will I still receive the funds if a user sends to an expired address/
  3. Or is there perhaps a better way to get BTC Pay server to act as a wallet as I want it to?

Thanks!

1

There are 1 answers

2
Rahul Iyer On BEST ANSWER
  1. Will BTC Pay server ditch my address if I attempt to use this to make it never expire?

Actually, you may encounter the year 2038 problem if the type for expirationTime is DateTime. If that really is the case, it will be set a negative value when you try to pass a value larger than 2038. It is unclear what will happen next.

If the system the code is running on is 64bit, then the Y2038 problem does not apply.

  1. Will I still receive the funds if a user sends to an expired address

https://docs.btcpayserver.org/FAQ/FAQ-Stores/#payment-invalid-if-transactions-fails-to-confirm-minutes-after-invoice-expiration

If the customer pays the invoice, but it fails to get the defined number of confirmations within the set period, it is marked as "invalid." The merchant can then decide whether to accept the invoice afterward manually or decline it and require additional payment from the customer. This is an additional protection mechanism against the volatility

So not exactly - some work is required on your part to accept it, if it expires.

  1. Or is there perhaps a better way to get BTC Pay server to act as a wallet as I want it to?

Instead of setting it to the year 3000, why don't you just set the invoice a year ahead at a time ?