when you are doing
BitcoinAddress address1 = **pubKey**.Derive([some client data]).PubKey.GetAddress(Network.Main);
You are getting the bitcoin address, but not the master public key. (ExtPubKey)
A HD pub key have more information than just the pubkey.
The correct code is
string wifStr = **pubkey**.Derive([some client data]).ToString(Network.Main)
Then you can reload it
ExtPubKey key = ExtPubKey.Parse(wifStr)
In fact, the string format of an ExtPubKey have the Network to which it belong, that's why you also have the type "BitcoinExtKey" which represent in object oriented form both : the ExtPubKey AND the Network. If you need it :
BitcoinExtPubKey wif = **pubkey**.GetWif(Network.Main)
Take a look at my book, there is other code samples around HD keys.
Concerning the best practices, there is no silver bullet right now. I created an API called RapidBase which permit you to create wallet and add addresses to monitor in this wallet. (You can find it on github)
You can try it if you want, but it is very unstable for now (API wise), so expect things to change in the future. If you are using blockr, I think your best bet is to request each addresses as you are doing.
If you are using bitcoinq RPC, you can add address, but it takes time since bitcoin core will rescan the blockchain for fetching the relevant transactions each time.
I might be wrong, but for now there is no easy to use solution, exception rapidbase I developed, that is not very stable for now.
1But he's not interested in the chaincode - he doesn't need the extended child key. What he needs is a way to monitor an address. – Nick ODell – 2015-04-03T16:15:09.543
Well, this is a two part question
"How do I pass the master public key (pubKey) to this code in the online server ?"
This is a response to this one.
I'm editing the response for his second question. – Nicolas Dorier – 2015-04-03T16:18:37.337
Ah, I see. I didn't see that first question. – Nick ODell – 2015-04-03T16:19:20.310
didn't see the second one :D – Nicolas Dorier – 2015-04-03T16:24:23.400
See my answer, I wanted to save the Neuter so I can use it as the master public key from which all childs created. If I save the wifStr and publish it on the online server if some hacker find the wifStr can he create from it the master private key ? – Haddar Macdasi – 2015-04-03T21:04:22.610
1you have a wif version of both : ExtKey and ExtPubKey, if you have the ExtKey and want the ExtPubKey, just do extKey.Neuter().ToString(Network.Main) – Nicolas Dorier – 2015-04-03T22:31:52.890