Bitcoin Forum

Bitcoin => Electrum => Topic started by: Tungsten on April 05, 2013, 01:38:21 AM



Title: How to import bitcoin addresses generated using Master Public Key?
Post by: Tungsten on April 05, 2013, 01:38:21 AM
I've generated bitcoin address using mpk, using index with high value =  184926
How do i import it into my wallet?


Title: Re: How to import bitcoin addresses generated using Master Public Key?
Post by: ThomasV on April 05, 2013, 07:54:43 AM
there is no special way to import them; you don't want to set your gap limit to such a high value.
just import them as if they were exogeneous


Title: Re: How to import bitcoin addresses generated using Master Public Key?
Post by: Tungsten on April 05, 2013, 11:01:25 AM
there is no special way to import them; you don't want to set your gap limit to such a high value.
just import them as if they were exogeneous


Thank you.

My scenario is - online merchant uses accepbit.com model to generate addresses from MPK for each order.

How does merchant gets hold of the funds after making few thousand sales?

What are the steps?


Title: Re: How to import bitcoin addresses generated using Master Public Key?
Post by: kangasbros on April 05, 2013, 03:25:17 PM
there is no special way to import them; you don't want to set your gap limit to such a high value.
just import them as if they were exogeneous


Thank you.

My scenario is - online merchant uses accepbit.com model to generate addresses from MPK for each order.

How does merchant gets hold of the funds after making few thousand sales?

What are the steps?


I guess you have to program that yourself, electrum doesn't do that kind of thing by default (AFAIK).


Title: Re: How to import bitcoin addresses generated using Master Public Key?
Post by: Tungsten on April 05, 2013, 03:33:01 PM
...

I guess you have to program that yourself, electrum doesn't do that kind of thing by default (AFAIK).

So if someone used acceptbit.com to make a sales - he than has to write a special program to get hold of funds???


Title: Re: How to import bitcoin addresses generated using Master Public Key?
Post by: kangasbros on April 05, 2013, 04:41:08 PM
...

I guess you have to program that yourself, electrum doesn't do that kind of thing by default (AFAIK).

So if someone used acceptbit.com to make a sales - he than has to write a special program to get hold of funds???


acceptbit.com is just a proof-of-concept sone in a weekend hackatohon. I should probably state this more clearly on the frontpage.


Title: Re: How to import bitcoin addresses generated using Master Public Key?
Post by: Tungsten on April 05, 2013, 04:46:28 PM
acceptbit.com is just a proof-of-concept sone in a weekend hackatohon. I should probably state this more clearly on the frontpage.

The only thing the front page is missing is "Step 4" to describe in details how people can get hold of Bitcoins received.
Otherwise it looks like deposit-only solution.


Title: Re: How to import bitcoin addresses generated using Master Public Key?
Post by: Tachikoma on April 06, 2013, 08:57:35 AM
People supply their MPK. The funds end up directly in their Electrum wallet. There is no step 4.


Title: Re: How to import bitcoin addresses generated using Master Public Key?
Post by: Tungsten on April 06, 2013, 10:51:09 AM
People supply their MPK. The funds end up directly in their Electrum wallet. There is no step 4.

Step 4: Adjust "Gap Limit" of your Electrum wallet to be equal or higher than number of payments addresses generated at your acceptbit.com merchant URL.
Otherwise you'll never see the payments beyond the 5-th address.

Gleb


Title: Re: How to import bitcoin addresses generated using Master Public Key?
Post by: Tachikoma on April 07, 2013, 01:47:53 PM
This is not the case. This is only the case if you give out 5 sequencial addresses which all five go unused for some reason.


Title: Re: How to import bitcoin addresses generated using Master Public Key?
Post by: Tungsten on April 07, 2013, 02:01:36 PM
This is not the case. This is only the case if you give out 5 sequencial addresses which all five go unused for some reason.

This is actually real scenario.
1. Visitor comes to online store and clicks "buy product X for bitcoins" out of curiocity.
2. Temporary bitcoin address is generated, as no one knows if that a real buyer or just clicker.
3. Above process happen few times before real buyer comes. He got address with, say, index #7 before unused addresses expires for reuse.
4. Merchant never sees money coming unless he adjusts gap limit according to missing Step 4 instructions.

Gleb


Title: Re: How to import bitcoin addresses generated using Master Public Key?
Post by: BkkCoins on April 09, 2013, 02:34:13 AM
If you store the index number (instead of, or in addition to the address), then it is fairly easy to generate a private key to match the address. I could whip up a little utility to do that if you want or a function. Once you have the key you can import it as normal.

Or maybe better write a script to sweep the balances to a given address so that you don't end up with a wallet containing thousands of addresses. If I recall correctly you can use cmd line mode to create a transaction with a private key and not have to import it.


Title: Re: How to import bitcoin addresses generated using Master Public Key?
Post by: ThomasV on April 09, 2013, 08:28:30 AM
I wrote a merchant script for Electrum some time ago.
it writes IDs in a database.

I think we should improve the client, so that it takes a list of IDs from a database in order to generate a sequence of addresses


Title: Re: How to import bitcoin addresses generated using Master Public Key?
Post by: ThomasV on April 09, 2013, 09:25:41 AM
I wrote a merchant script for Electrum some time ago.
it writes IDs in a database.

I think we should improve the client, so that it takes a list of IDs from a database in order to generate a sequence of addresses


maybe a new plugin could do that.
it could connect to a service like acceptbit.com, and get a list of IDs that have been used to generate addresses


Title: Re: How to import bitcoin addresses generated using Master Public Key?
Post by: Tungsten on April 09, 2013, 02:05:10 PM
I wrote a merchant script for Electrum some time ago.
it writes IDs in a database.

I think we should improve the client, so that it takes a list of IDs from a database in order to generate a sequence of addresses


maybe a new plugin could do that.
it could connect to a service like acceptbit.com, and get a list of IDs that have been used to generate addresses

I think this would violate beautiful "deterministicability" principle (what a term!) of Electrum. Deterministic wallets are very resilient to being lost. Once we start promoting importation of foreign keys - this will open can of worms about backups and will hurt wallet owners in the long run.
In case of acceptbit and similar services - I'd just pull the "last used index" and make sure wallet used that to sync all addresses up to this index.

Gleb


Title: Re: How to import bitcoin addresses generated using Master Public Key?
Post by: BkkCoins on April 09, 2013, 02:37:53 PM
I wrote a merchant script for Electrum some time ago.
it writes IDs in a database.

I think we should improve the client, so that it takes a list of IDs from a database in order to generate a sequence of addresses


maybe a new plugin could do that.
it could connect to a service like acceptbit.com, and get a list of IDs that have been used to generate addresses

I think this would violate beautiful "deterministicability" principle (what a term!) of Electrum. Deterministic wallets are very resilient to being lost. Once we start promoting importation of foreign keys - this will open can of worms about backups and will hurt wallet owners in the long run.
In case of acceptbit and similar services - I'd just pull the "last used index" and make sure wallet used that to sync all addresses up to this index.

Gleb

Regarding very high gap values - I'm not sure of performance ramifications but if you have thousands of addresses in a wallet I suspect the server end could be severely impeded by such a large subscribe cmd.

One way would be to add a new list of addresses besides just change and normal ones. We already have an imported list but we could add a "sparse" list. These ones show up and act as normal addresses in the interface but actually store the index with the address and use the index instead of ordinal position to generate keys. The import cmd line could accept a list of index values to add to this list. It could potentially also use a different hash base, eg. 2 instead of 1 so that it cannot collide with normal addresses.

Upon restoring a lost wallet you could restore sparse addresses automatically with a scan of a range (scan 0-250 or whatever), or it could be a cmd used any time to scan for sparsely used addresses beyond the last one known. This way you likely don't even need to import index values, just trigger a scan cmd (periodically much less work than subscribing always).

@ThomasV if this sounds like a good idea I'd be happy to code it and offer a pull request. It should be transparent to users with wallets missing the list. (Gee, I have to sync up to date first as I'm still using 1.6.1 right now)


Title: Re: How to import bitcoin addresses generated using Master Public Key?
Post by: Tungsten on April 09, 2013, 03:21:32 PM
...
Regarding very high gap values - I'm not sure of performance ramifications but if you have thousands of addresses in a wallet I suspect the server end could be severely impeded by such a large subscribe cmd
...

I tested gap limit = 500 with Electrum and it only takes a ~15 seconds to sync after initial set of addresses is created.
I am sure this process could be further optimized to support few K's addresses.
Beyond that person/merchant should create new wallet and aggregate all funds from old wallet into single address of the new one.
At least I would do it this way.

Gleb


Title: Re: How to import bitcoin addresses generated using Master Public Key?
Post by: BkkCoins on April 09, 2013, 03:37:56 PM
...
Regarding very high gap values - I'm not sure of performance ramifications but if you have thousands of addresses in a wallet I suspect the server end could be severely impeded by such a large subscribe cmd
...

I tested gap limit = 500 with Electrum and it only takes a ~15 seconds to sync after initial set of addresses is created.
I am sure this process could be further optimized to support few K's addresses.
Beyond that person/merchant should create new wallet and aggregate all funds from old wallet into single address of the new one.
At least I would do it this way.

Gleb
Yes, it's possible to make a merchant wallet that checks addresses in reverse. It gets each new block and instead of looking up each address in the wallet it looks up each output in the block. This would allow for millions of addresses in a database and only checking a few hundred outputs every block. I could see using either Sqlite3/MySql for addresses and payment history. I don't think Electrum server can provide block data so you'd either use blockchain.info or run bitcoind.

My coinwatch script in my misc repo (http://github/bkkcoins/misc) does this but it doesn't use MPK generation yet. I should update it to use the mpkgen script.