I need to use blockchain API for my retailer however the pockets solely monitoring final 20 generated handle.
Quote from https://blockchain.data/api/api_receive:
As outlined in BIP 44, pockets software program is not going to scan previous 20 unused
addresses. Given sufficient requests from this API that do not have a
matching fee, you can generate addresses previous this horizon,
which might make spending funds paid to these addresses fairly
troublesome. For that reason, this API will return an error and refuse
to generate new addresses if it detects it might create a spot of over
20 unused addresses. In the event you encounter this error, you’ll both want
to change to a brand new xPub (throughout the similar pockets is okay), or obtain a
fee to one of many earlier 20 created addresses
I googled about this downside and located some options corresponding to:
Options that I discovered
- Examine hole with blockchain checkgap API and do not generate new handle till they’ve been paid.
- Improve hole restrict on the obtain api.
- Ship cash to the final unused handle.
Issues with these Options
- If I’ve 20 unpaid handle and so they by no means been paid, resolution #1 cannot clear up the issue. it simply say I’ve 20 unpaid handle.
- Answer #2 cannot clear up the primary downside. Even I set the hole restrict to the 100, How concerning the time that 101 curious customers solely need to see the checkout web page and shut it. I’ll get 100 unused handle once more.
- Answer #three shouldn’t be a pleasant resolution to me. It looks like a nasty apply to me and this can be a resolution that solved by spending cash.
If I get it proper, when Blockchain producing the handle, It will likely be there till it is getting paid. Right me if I am improper, Blockchain is not going to callback till the consumer pay the quantity. so I do that to unravel the issue:
- Examine the hole by API. If hole>19 goto #three else #2.
- Generate the handle and retailer it inside
unpaid_addressdesk based mostly on the “index quantity” that blockchain returns with handle. set expiration time for 30 minutes and go to the #4.
- Get the primary expired unpaid handle from
unpaid_addressdesk. If there is not something, present sorry server is busy, else goto #4.
- present the handle to the consumer and say you might have 15 minutes to pay to this handle. (15 minutes lower than expire time to keep away from issues).
- If blockchain callback my URL and It has been paid earlier than the expire time, I take away the handle from
unpaid_addresselse the handle has been there for the following request by different consumer. I’ll give that handle to the following consumer for paying.
This resolution give me the power to by no means exceed hole restrict. However I do not know if it is secure to offer the handle to a consumer and if he did not pay on 30 minutes, give it to a different consumer.
What do you assume? Is it secure? or is there higher resolution?
About giving the handle to a number of customers
- First consumer see the checkout web page in 8:20AM and ship the quantity to the handle. however there isn’t a affirmation in 15 minutes. the affirmation are available in 11:00AM.
- Second consumer see the checkout web page in 9:00AM and ship the quantity to the identical handle. there’s affirmation in 9:10AM so I’ll return callback end result as paid.
What concerning the first consumer affirmation on 11:00AM?