Bitcoin Forum
September 18, 2019, 08:31:22 AM *
News: Latest Bitcoin Core release: 0.18.1 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: [Electrum] merchant script  (Read 4033 times)
ThomasV
Legendary
*
Offline Offline

Activity: 1897
Merit: 1025



View Profile WWW
October 08, 2012, 01:37:46 PM
Last edit: October 08, 2012, 08:35:09 PM by ThomasV
 #1

I just added a new script to Electrum, named "merchant.py"

It is a daemon that manages payments for a web server. It creates Bitcoin addresses using a master public key (so you do not leave your private keys on the server), detects when payments are received and notifies your web application.

The workflow goes like this:

 - the server sends a request to the daemon via POST. the request contains an ID, an amount to be paid, an expiration period.
 - the daemon answers with a bitcoin address, where the customer needs to send the coins.
 - later, the daemon will send a POST to the webserver, to notify that payment has been received OR that the request has expired

This is, IMO, as simple as it can get.

Since addresses are generated using an Electrum master public key, it is possible to visualize payments in the Electrum client; you will, however, need to manually adjust your "gap limit".
There are a few unfinished things, such as requesting a given number of confirmations, but I thought it would be ok to publish it now.

The script is being used at https://ecdsa.org

Electrum: the convenience of a web wallet, without the risks
1568795482
Hero Member
*
Offline Offline

Posts: 1568795482

View Profile Personal Message (Offline)

Ignore
1568795482
Reply with quote  #2

1568795482
Report to moderator
1568795482
Hero Member
*
Offline Offline

Posts: 1568795482

View Profile Personal Message (Offline)

Ignore
1568795482
Reply with quote  #2

1568795482
Report to moderator
"Your bitcoin is secured in a way that is physically impossible for others to access, no matter for what reason, no matter how good the excuse, no matter a majority of miners, no matter what." -- Greg Maxwell
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1568795482
Hero Member
*
Offline Offline

Posts: 1568795482

View Profile Personal Message (Offline)

Ignore
1568795482
Reply with quote  #2

1568795482
Report to moderator
1568795482
Hero Member
*
Offline Offline

Posts: 1568795482

View Profile Personal Message (Offline)

Ignore
1568795482
Reply with quote  #2

1568795482
Report to moderator
arsenische
Legendary
*
Offline Offline

Activity: 1178
Merit: 1010


View Profile
November 13, 2012, 10:49:20 PM
Last edit: November 14, 2012, 01:24:22 AM by arsenische
 #2

This is, IMO, as simple as it can get.

Since addresses are generated using an Electrum master public key, it is possible to visualize payments in the Electrum client; you will, however, need to manually adjust your "gap limit".
There are a few unfinished things, such as requesting a given number of confirmations, but I thought it would be ok to publish it now.

The script is being used at https://ecdsa.org


Great script, thanks a lot!

---

For people who don't know where to get master public key value, here is a hint:
Code:
electrum eval wallet.master_public_key
(run from command line)

---

I hacked the script and limited its functionality to solely bitcoin address generation. No database or running electrum is required. Not sure if anybody else needs it, but here it is:
  electrum-address-generator.py - generates deterministic bitcoin address by index via command line or passwordless RPC call (getaddress <index>)
  electrum-address-generator.conf.template - specifies listening port and master_public_key (edit it and rename to electrum-address-generator.conf)

finway
Hero Member
*****
Offline Offline

Activity: 714
Merit: 500


View Profile
November 14, 2012, 01:10:07 AM
 #3

Great!

wabber
Member
**
Offline Offline

Activity: 85
Merit: 10


View Profile
November 14, 2012, 08:42:06 AM
 #4

I like it because it's so simple. Looks easy to setup and easy to use.
No blockchain is needed and the interface is trivial to use.
ThomasV
Legendary
*
Offline Offline

Activity: 1897
Merit: 1025



View Profile WWW
November 14, 2012, 09:04:56 AM
 #5

note: the version of this script included in the 1.3 package does not work.
Please use the version in the git repo.

Electrum: the convenience of a web wallet, without the risks
Stn
Full Member
***
Offline Offline

Activity: 227
Merit: 100


View Profile
October 24, 2013, 07:13:28 AM
 #6

however, need to manually adjust your "gap limit".
I caught this phrase several times in different sources. Adjust to what? Any recommendations?
fbueller
Sr. Member
****
Offline Offline

Activity: 412
Merit: 250


View Profile
October 24, 2013, 02:18:15 PM
 #7

It depends on what you set your client up with. The electrum client regards the gap limit the total number of addresses derived from the one MPK to watch, as it's expecting payments on them.

If you don't expect to receive much, you could just leave it at 200 and be happy your client won't start missing addresses above this. Whereas, if you were expecting frequent transactions to addresses generated from the mpk you should set a high gap limit, like 2000. I don't think there IS a limit, and am not sure if there is any performance concerns by watching so many addresses.

You can reset your client, use the seed and the mpk to recover your private key, and set the gap limit to something higher if you generate more addresses than your current gap limit.

Bitwasp Developer.
Stn
Full Member
***
Offline Offline

Activity: 227
Merit: 100


View Profile
October 25, 2013, 04:01:43 AM
 #8

It depends on what you set your client up with.

I have set my client up with the default value which is unknown to me right now. I can find out it of course but it doesn't matter. I still don't understand if my rate of unused addresses say 50% what gap limit I'm obliged to?

I don't understand whole magic of this gap limit adjustment. If I need permanent supply of new addresses why should I care if they generated by 20, by 200 or by 2000 items per bunch? What correlation between gap limit ("bunch size" if I got it right) and  number of unused addresses?
ThomasV
Legendary
*
Offline Offline

Activity: 1897
Merit: 1025



View Profile WWW
October 25, 2013, 04:28:45 AM
 #9

the gap limit is hidden from the gui in 1.9, so I guess suggesting to modify it was a bad idea.
I will try to find a better solution for the merchant script

Electrum: the convenience of a web wallet, without the risks
Abdussamad
Legendary
*
Offline Offline

Activity: 2226
Merit: 1183



View Profile WWW
October 26, 2013, 07:05:12 PM
 #10

It depends on what you set your client up with.

I have set my client up with the default value which is unknown to me right now. I can find out it of course but it doesn't matter. I still don't understand if my rate of unused addresses say 50% what gap limit I'm obliged to?

I don't understand whole magic of this gap limit adjustment. If I need permanent supply of new addresses why should I care if they generated by 20, by 200 or by 2000 items per bunch? What correlation between gap limit ("bunch size" if I got it right) and  number of unused addresses?

Gap limit basically means the number of extra addresses the client tracks and displays at any one point in time. Extra addresses are counted from the used address with the highest index that electrum was tracking. It means the following:

The default gap limit is 5 so you have 5 empty addresses to start with index 0 - 4

You receive bitcoins in address with index 0. Electrum now starts tracking addresses with index 0-5.

You receive coins to address with index 4. Electrum now starts tracking addresses 0 - 9.

What does this mean? It doesn't affect coins sent to addresses with high index numbers. You have the seed and are always in control of any coins sent to derived addresses. But you may not know about those coins if the gap limit is too low. So if you have hundreds of transactions in a day with large gaps of unused addresses between transactions you may have to increase the gap limit to see those addresses in electrum.

Stn
Full Member
***
Offline Offline

Activity: 227
Merit: 100


View Profile
October 27, 2013, 03:05:12 AM
 #11

I'm seems getting it. Correct if I'm wrong. All these concerns with the gap limit applied to the case when new addresses generated outside of the client using deterministic features. If new addresses created by the client itself I should not care any gap limit as the client will be aware anyhow of these new addresses.

So question now turns to is merchant.py script isolated from the client? Or client aware of it activities and tracks addresses created by the merchant.py?
fbueller
Sr. Member
****
Offline Offline

Activity: 412
Merit: 250


View Profile
October 28, 2013, 02:13:33 PM
 #12

This is correct. It knows about everything's created in it's own wallet, and will track the default, 5, addresses that can be generated from the keys there. But it needs to be told how many addresses to watch if coins are to be sent to addresses beyond those 5!

Bitwasp Developer.
johnny508
Member
**
Offline Offline

Activity: 138
Merit: 13


View Profile
November 18, 2015, 05:38:38 PM
 #13

has anybody successfully implemented this into a woocommerce store?  if so, could you give an overview of how u accomplished it?

im struggling to find something for woocommerce that doesn't require a full middleman service like bitpay.

TelegramTwitter ❰❰❰❰❰❰  TERRAGREEN  ❱❱❱❱❱❱ Reddit  ● Medium
●●● ▬▬ Facebook  ❰❰❰  Blockchain Based Renewable Energy Platform  ❱❱❱  LinkedIn ▬▬ ●●●
● ▬▬▬▬▬ ● ▬▬▬▬▬ ●●●  GREENPAPER  ●  ICO Website  ●  ANN THREAD  ●●● ▬▬▬▬▬ ● ▬▬▬▬▬ ●
CrappyJavaScriptDev
Newbie
*
Offline Offline

Activity: 16
Merit: 0


View Profile
November 19, 2015, 06:39:09 AM
 #14

has anybody successfully implemented this into a woocommerce store?  if so, could you give an overview of how u accomplished it?

im struggling to find something for woocommerce that doesn't require a full middleman service like bitpay.


Stumbled upon this a while back

https://wordpress.org/plugins/bitcoin-payments-for-woocommerce/installation/

Haven't used it so don't know if it works (last updated a year ago).
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!