Bitcoin Forum
May 26, 2024, 11:11:04 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Succeed placing xpub to generate unlimited receiving address. But how to pay?  (Read 203 times)
artofwar (OP)
Member
**
Offline Offline

Activity: 142
Merit: 26


View Profile
November 05, 2018, 06:17:39 PM
 #1

Hello there,

I have succeeded creating unlimited address for my user for my website.

so now everytime they want to deposit, my xpub will generate addresses for them.

but how to do automatic payment? like when they request for withdrawal, fund from my hot wallet will pay them instantly.

Can someone explian?
MadGamer
Legendary
*
Offline Offline

Activity: 1568
Merit: 1031


View Profile
November 06, 2018, 10:41:52 AM
 #2

I'm going to assume that you have used bitcoind for this purpose? If so, you could use this command so whenever a user makes a withdrawal request, Its executed:

Code:
sendtoaddress <bitcoinaddress> <amount> 
mocacinno
Legendary
*
Offline Offline

Activity: 3402
Merit: 4984


https://merel.mobi => buy facemasks with BTC/LTC


View Profile WWW
November 06, 2018, 10:51:37 AM
 #3

There are to many unknown variables to answer your question...

MadGamer can be correct, but since you're talking about deriving addresses from an xpub, you might aswell derive them using the bitwasp library, use a python script or run an electrum daemon.

The first thing you should do is detect incoming payments... This can be done with the walletnotify option in core, or by querying an api, or with websockets if you're using an electrum daemon.

The next thing is: when you detect an address being funded, you should know which software you're using for a hot wallet... Depending on the software, there are different ways to initiate a payment. core: json-rpc, electrumd: websocket, python, bitwasp: creating + signing a transaction, online wallet: api

You'll probably need some kind of intermediate script that either polls for incoming transactions (either as a daemon, or from the crontab), or which is called by your wallet if a funding tx is detected (depending on your wallet). This script will probably need to call the payment function of whatever hot wallet you have.
I'd strongly suggest not putting your hot wallet on the same machine where you've put your xpub, it kind of defeats the purpose of using an xpub to derive new addresses to start from (unless i'm missing something here).

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
artofwar (OP)
Member
**
Offline Offline

Activity: 142
Merit: 26


View Profile
November 06, 2018, 12:19:47 PM
 #4

There are to many unknown variables to answer your question...

MadGamer can be correct, but since you're talking about deriving addresses from an xpub, you might aswell derive them using the bitwasp library, use a python script or run an electrum daemon.

The first thing you should do is detect incoming payments... This can be done with the walletnotify option in core, or by querying an api, or with websockets if you're using an electrum daemon.

The next thing is: when you detect an address being funded, you should know which software you're using for a hot wallet... Depending on the software, there are different ways to initiate a payment. core: json-rpc, electrumd: websocket, python, bitwasp: creating + signing a transaction, online wallet: api

You'll probably need some kind of intermediate script that either polls for incoming transactions (either as a daemon, or from the crontab), or which is called by your wallet if a funding tx is detected (depending on your wallet). This script will probably need to call the payment function of whatever hot wallet you have.
I'd strongly suggest not putting your hot wallet on the same machine where you've put your xpub, it kind of defeats the purpose of using an xpub to derive new addresses to start from (unless i'm missing something here).


im using btcpay server. It allowed me to insert my xpub (created using elctrum) and generate deposit addresses. Detecting payments using nbxplorer.

Im pretty new to bitcoin, but I think I understand the basic of it. xpub=masterpublic key, xprv=masterprivate key.

So now for receiving payment I use btcpayserver that create millions of deposit addresses from my masterpublic key and directly sync with my elctrum.

now for payment I need to create a new wallet?
mocacinno
Legendary
*
Offline Offline

Activity: 3402
Merit: 4984


https://merel.mobi => buy facemasks with BTC/LTC


View Profile WWW
November 06, 2018, 12:23:27 PM
 #5

im using btcpay server. It allowed me to insert my xpub (created using elctrum) and generate deposit addresses. Detecting payments using nbxplorer.

Im pretty new to bitcoin, but I think I understand the basic of it. xpub=masterpublic key, xprv=masterprivate key.

So now for receiving payment I use btcpayserver that create millions of deposit addresses from my masterpublic key and directly sync with my elctrum.

now for payment I need to create a new wallet?

First things first, you are right:
xpub = master public key, which can be used to derive deposit addresses
xprv = master private key, which can be used to derive private keys, these private keys can be used to calculate the public key, the public key can be hashed to generate the address

I have never used btcpayserver, but if you created a wallet by entering your xpub, it's a watch-only wallet, so yes, you'll need a different wallet to handle payouts.
What you could do is use the electrum wallet from which you exported the xpub, if it's a "real" wallet (generated from a seed or an xprv), it should keep track of the same addresses as generated by your btcpayserver, so if you run electrum as a daemon, it should be able to function as a hot wallet.

If you run btcpayserver and electrum on the same machine, you might aswell directly import the xprv in btcpayserver? I don't know how safe btcpayserver is since i have never used it tough!

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
artofwar (OP)
Member
**
Offline Offline

Activity: 142
Merit: 26


View Profile
November 06, 2018, 12:31:30 PM
 #6

im using btcpay server. It allowed me to insert my xpub (created using elctrum) and generate deposit addresses. Detecting payments using nbxplorer.

Im pretty new to bitcoin, but I think I understand the basic of it. xpub=masterpublic key, xprv=masterprivate key.

So now for receiving payment I use btcpayserver that create millions of deposit addresses from my masterpublic key and directly sync with my elctrum.

now for payment I need to create a new wallet?

First things first, you are right:
xpub = master public key, which can be used to derive deposit addresses
xprv = master private key, which can be used to derive private keys, these private keys can be used to calculate the public key, the public key can be hashed to generate the address

I have never used btcpayserver, but if you created a wallet by entering your xpub, it's a watch-only wallet, so yes, you'll need a different wallet to handle payouts.
What you could do is use the electrum wallet from which you exported the xpub, if it's a "real" wallet (generated from a seed or an xprv), it should keep track of the same addresses as generated by your btcpayserver, so if you run electrum as a daemon, it should be able to function as a hot wallet.

If you run btcpayserver and electrum on the same machine, you might aswell directly import the xprv in btcpayserver? I don't know how safe btcpayserver is since i have never used it tough!

can we ran this electrum daemon if we have pruned bitcoin core(prune=5000)

also, can you point the link for electrum daemon?
mocacinno
Legendary
*
Offline Offline

Activity: 3402
Merit: 4984


https://merel.mobi => buy facemasks with BTC/LTC


View Profile WWW
November 07, 2018, 06:33:50 AM
 #7

can we ran this electrum daemon if we have pruned bitcoin core(prune=5000)

also, can you point the link for electrum daemon?

yes, electrum can be run next to core, eventough i'm wondering why you'd use electrum if you're also running bitcoin core... I have no experience with btcpayserver, but if it's using core in the background i wonder if btcpayserver is also able to handle payouts if you import the xprv instead of the xpub??? If not, you should be able to import the xprv into the bitcoin core instance you're running anyways and use core's json-rpc interface to handle payouts (i've never done this myself, but iirc, it should be possible, altough i don't know if the derivation path is the same between both implementations???)

Here's the link you were asking for: http://docs.electrum.org/en/latest/merchant.html

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
artofwar (OP)
Member
**
Offline Offline

Activity: 142
Merit: 26


View Profile
November 09, 2018, 07:05:05 PM
 #8

can we ran this electrum daemon if we have pruned bitcoin core(prune=5000)

also, can you point the link for electrum daemon?

yes, electrum can be run next to core, eventough i'm wondering why you'd use electrum if you're also running bitcoin core... I have no experience with btcpayserver, but if it's using core in the background i wonder if btcpayserver is also able to handle payouts if you import the xprv instead of the xpub??? If not, you should be able to import the xprv into the bitcoin core instance you're running anyways and use core's json-rpc interface to handle payouts (i've never done this myself, but iirc, it should be possible, altough i don't know if the derivation path is the same between both implementations???)

Here's the link you were asking for: http://docs.electrum.org/en/latest/merchant.html

Hi thanks for your suggestion. we use electrum daemon now. but electrum cant notify incoming payments. so we need to hack blockchain.info to receive txhash for spesific payment and get notification from there.

(was thinking on using a stupid trick like selenium automation to check every transaction)
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!