Bitcoin Forum
November 18, 2019, 12:50:44 AM *
News: Help collect the most notable posts made over the last 10 years.
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Generating payment addresses from a user's public key  (Read 207 times)
VictorBTC
Newbie
*
Offline Offline

Activity: 13
Merit: 3


View Profile
September 01, 2019, 08:20:55 PM
Merited by o_e_l_e_o (1)
 #1

Hi, I've already implemented a custom script for that purpose, it works in the following way.

1. User provides it's public key (xpub)
2. the scripts takes this xpub key and every time an order is made it generates a new payment address
3. After that a cron job queries the blockhain for the generated address and checks whether the payment has been made.
4. if balance for the address is equal to the order price the order is marked as paid.

It works, however I am wondering whether there is a better way to implement this task now?

I can't use any existing gateways like bitpay and others. It should be a custom application/script and we cannot run a full bitcoin node for that.

I would be grateful for any suggestions.
The Bitcoin Forum is turning 10 years old! Join the community in sharing and exploring the notable posts made over the years.
pooya87
Legendary
*
Offline Offline

Activity: 1820
Merit: 2060


Remember tonight for it's the beginning of forever


View Profile
September 02, 2019, 03:48:22 AM
Merited by ETFbitcoin (1), LoyceV (1), hugeblack (1)
 #2

1. User provides it's public key (xpub)
i'm confused, why does the "user" provide his xpub if it is "you" who is accepting payments?

3. After that a cron job queries the blockhain for the generated address and checks whether the payment has been made.
4. if balance for the address is equal to the order price the order is marked as paid.
we cannot run a full bitcoin node for that.
so you are relying on a third party to do this verification for you? it doesn't sound safe, specially if the payments are not small.
also you should look for "transaction" not just balance. of course since RBF is a thing you have to keep looking. the benefit of this is that as soon as you receive the transaction you can show a message to the user so that they don't have to wait in the dark without knowing if the site is broken or not.
a message saying "we've receive this transaction (txid) which has (low/medium/high) fee and needs (x) number of confirmation, it currently has (y)".

you could also run bitcoin core in pruned mode which requires less resources. again it depends on the size and frequency of payments you are receiving.

ETFbitcoin
Legendary
*
Offline Offline

Activity: 1820
Merit: 2087

Use SegWit and enjoy lower fees.


View Profile WWW
September 02, 2019, 05:19:45 PM
 #3

1. User provides it's public key (xpub)
i'm confused, why does the "user" provide his xpub if it is "you" who is accepting payments?

I think he made  some kind of marketplace with integrated payment gateway, expect users have full control of their Bitcoin by sharing their xpub key.

It should be a custom application/script and we cannot run a full bitcoin node for that.

Then your only option is Electrum, but AFAIK handling multiple wallet/watch-only wallet is very tricky.

But why can't you run bitcoin full node?

bob123
Legendary
*
Offline Offline

Activity: 1078
Merit: 1575



View Profile WWW
September 03, 2019, 10:39:19 AM
 #4

The best way would be to simply run a full node.
It would be the easiest to implement and the most safest way.

Can you elaborate on the reasons why you can't run a full node ? It doesn't take much effort to set it up and it costs close to nothing to keep it running. The power costs are low and a 500GB HDD costs about 30$.
If you want to run a marketplace or a website, this shouldn't be a problem at all. So i assume there are other problems you are facing ? Maybe we can find a solution for them.

VictorBTC
Newbie
*
Offline Offline

Activity: 13
Merit: 3


View Profile
September 11, 2019, 05:58:52 PM
 #5

1. User provides it's public key (xpub)
i'm confused, why does the "user" provide his xpub if it is "you" who is accepting payments?

3. After that a cron job queries the blockhain for the generated address and checks whether the payment has been made.
4. if balance for the address is equal to the order price the order is marked as paid.
we cannot run a full bitcoin node for that.
so you are relying on a third party to do this verification for you? it doesn't sound safe, specially if the payments are not small.
also you should look for "transaction" not just balance. of course since RBF is a thing you have to keep looking. the benefit of this is that as soon as you receive the transaction you can show a message to the user so that they don't have to wait in the dark without knowing if the site is broken or not.
a message saying "we've receive this transaction (txid) which has (low/medium/high) fee and needs (x) number of confirmation, it currently has (y)".

you could also run bitcoin core in pruned mode which requires less resources. again it depends on the size and frequency of payments you are receiving.

Thanks all for your replies.

The main idea is allow an administrator to receive payments from other users that will order goods on the marketplace.

There is no way we can run the full node.
So what is the best option in this case? Can I use current flow (with an xpub key) in that case? I understand that is not safe to query a third party service to check a transaction state.
But we have some limitations.
I just want to know maybe there are any other types of wallets that allows an owner to provide some public key to generate new payment addresses.

Thanks
bob123
Legendary
*
Offline Offline

Activity: 1078
Merit: 1575



View Profile WWW
September 12, 2019, 08:11:23 AM
Merited by ETFbitcoin (1)
 #6

There is no way we can run the full node.

Are you sure ? What is the reason for that ?

A hard drive costs around 25$ and basically any CPU would be suitable. You could even use a raspberry pi to run a full node.



So what is the best option in this case? Can I use current flow (with an xpub key) in that case?

Yes, definitely.



I understand that is not safe to query a third party service to check a transaction state.
But we have some limitations.

What are your limitations ?
Are you going to start a service which sells goods but can't afford a 50$ device to run a full node ?

If you can not run your own node, the only option is to rely on a 3rd party.

You could either query an API provided by a blockchain explorer or query an electrum server.



I just want to know maybe there are any other types of wallets that allows an owner to provide some public key to generate new payment addresses.

I guess you mean to provide the master public key to derive multiple addresses ?
In this case, yes. You could go for electrum.

bob123
Legendary
*
Offline Offline

Activity: 1078
Merit: 1575



View Profile WWW
September 18, 2019, 08:02:51 AM
Merited by bones261 (2), ETFbitcoin (1), hugeblack (1)
 #7

What's kind problem you are facing to use Bitpay??

The problem is that bitpay is cancer.

They only allow paying the invoice with their own application. They do not simply display an address and an amount.
You explicitly have to use a tool (DeBitpay) to convert the invoice into standard address/amount information.

They are trying to force users to use their (shitty) application to store/send funds.


And additional - that's the biggest problem - they are a centralized service holding the keys.
That's absolutely against the philosophy of bitcoin. You don't need to accept BTC if you don't hold your own keys. Can as well use CC then.
BTC has been made to be your own bank, not to let someone else store your money. We have banks and FIAT for that.

TryNinja
Legendary
*
Offline Offline

Activity: 1190
Merit: 1629



View Profile
September 18, 2019, 12:18:40 PM
Merited by ETFbitcoin (1)
 #8

What's kind problem you are facing to use Bitpay??
They also blocked some donations destinated to the rain forest recovery, funds donated to the Hong Kong Free Press movement and they just randomly freeze many user's payments out of the air from time to time. It's just not worth it when you can have an open source, self hosted node accepting payments. No middleman, trully descentralized and as censorship resistent as Bitcoin. I'm talking about BTC Pay Server btw. Smiley

Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!