Author

Topic: How to import bitcoin addresses generated using Master Public Key? (Read 8278 times)

hero member
Activity: 784
Merit: 1009
firstbits:1MinerQ
...
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 does this but it doesn't use MPK generation yet. I should update it to use the mpkgen script.
member
Activity: 73
Merit: 10
...
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
hero member
Activity: 784
Merit: 1009
firstbits:1MinerQ
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)
member
Activity: 73
Merit: 10
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
legendary
Activity: 1896
Merit: 1353
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
legendary
Activity: 1896
Merit: 1353
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
hero member
Activity: 784
Merit: 1009
firstbits:1MinerQ
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.
member
Activity: 73
Merit: 10
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
hero member
Activity: 938
Merit: 1000
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.
member
Activity: 73
Merit: 10
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
hero member
Activity: 938
Merit: 1000
People supply their MPK. The funds end up directly in their Electrum wallet. There is no step 4.
member
Activity: 73
Merit: 10
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.
hero member
Activity: 812
Merit: 1006
...

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.
member
Activity: 73
Merit: 10
...

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???
hero member
Activity: 812
Merit: 1006
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).
member
Activity: 73
Merit: 10
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?
legendary
Activity: 1896
Merit: 1353
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
member
Activity: 73
Merit: 10
I've generated bitcoin address using mpk, using index with high value =  184926
How do i import it into my wallet?
Jump to: