Generating Bitcoin addresses from a xpubkey

0 votes

I want to generate bitcoin address from a known xpubkey. The key I am using is here: https://blockchain.info/xpub/xpub6CUGRUonZSQ4TWtTMmzXdrXDtypWKiKrhko4egpiMZbpiaQL2jkwSB1icqYh2cfDfVxdx4df189oLKnC5fSwqPfgyP3hooxujYzAu3fDVmz

I am using the following code but when I execute it, get a 'Invalid point encoding 103' when I try to instantiate the ExtPubKey.

The code:

var pubkey = new ExtPubKey(Encoding.ASCII.GetBytes("6CUGRUonZSQ4TWtTMmzXdrXDtypWKiKrhko4egpiMZbpiaQL2jkwSB1icqYh2cfDfVxdx4df189oLKnC5fSwqPfgyP3hooxujYzAu3fDVmz"));

        Console.Writeline(pubkey.Derive(0).Derive(0).Derive(0).PubKey.GetAddress(Network.Main));
Aug 21, 2018 in Blockchain by digger
• 27,620 points
65 views

1 answer to this question.

0 votes

Via https://bitcointalk.org/index.php?topic=1242247.0

var pubkey = ExtPubKey.Parse("xpub6CUGRUonZSQ4TWtTMmzXdrXDtypWKiKrhko4egpiMZbpiaQL2jkwSB1icqYh2cfDfVxdx4df189oLKnC5fSwqPfgyP3hooxujYzAu3fDVmz");
var newAddress = pubkey.Derive(0).Derive(0).PubKey.GetAddress(Network.Main);
Console.WriteLine(newAddress);

It works and gives expected results.

answered Aug 21, 2018 by slayer
• 29,050 points

Related Questions In Blockchain

0 votes
1 answer

Is there a way to send funds from a specific bitcoin address in a wallet?

I'll answer my own question, It was unbelievably ...READ MORE

answered Sep 3, 2018 in Blockchain by Perry
• 17,010 points
52 views
0 votes
1 answer
+1 vote
1 answer
+1 vote
2 answers

What if a bitcoin clients could create identical private keys?

If this happens, then Person B will ...READ MORE

answered Aug 28, 2018 in Blockchain by Evan
22 views
0 votes
1 answer
0 votes
1 answer

Invalid Batch or signature in Savtooth

This will solve your problem import org.apache.commons.codec.binary.Hex; Transaction txn ...READ MORE

answered Aug 1, 2018 in Blockchain by digger
• 27,620 points
55 views
+1 vote
1 answer
0 votes
1 answer