Hi Legends_Never_Die -- Thx for the reply!
You are trying to generate a master private key > ExtKey.
Ah, I see. I'm afraid I've never heard of a "master private key" before...
Do you know how would I generate a... well, now I don't know what to call it... but a "regular" private key from a hex? I just need to give NBitcoin that hex and then get the expected address from it, and I was using
this StackOverflow as an example, which is using `ExtPubKey` to generate a public key from some kind of hash, so I "extrapolated" (aka assumed) that `ExtKey` would be the private key version of that... But I guess that was wrong
Although one of the overrides for `new ExtKey()`
does take a `hex` param, so I really thought I was on the right track...
And I checked out that link to csharp.hotexamples.com you posted (thank you for that) but I can't seem to navigate that site very well to get to any other pages that might be helpful (I tried the search, but almost everything I tried gave me a 404)...
I do see this on that page:
var walletKey = new NBitcoin.Key();
...and I'm guessing that could be mean I just need to use a `Key()` instead of a `ExtKey()`...? but `Key()` doesn't seem to take a hex value at all... and `Key.Parse()` takes a WIF, but I'm not sure how to generate a WIF from a private key hex either, so, yeah, I'm still stumped...
why are you trying to build from scratch when there are ready to use open source tools, with great performance?
If you mean use an existing puzzle solver, well A) to learn all this stuff, but also B) I really don't know where to find existing ones...? And the code I've seen posted here all looks like C or C++ that I'm not very familiar with, so I wouldn't know how to modify any of it to do what I want...
Thanks again for the response, and let me know if you can help me get from a private key (in either decimal or hexadecimal form) to the funded address using C# ... doesn't even have to be with NBitcoin, that just seems to be the most popular Bitcoin lib for .NET
Did it! Thanks to this SO post I finally found:
https://stackoverflow.com/questions/74753526/get-private-key-from-a-biginteger-in-nbitcoinSo I can use the decimal version of that hex, 2683, and do this:
var bytes = new BigInteger(2683).ToByteArray();
Array.Resize(ref bytes, 32);
Array.Reverse(bytes);
new Key(bytes)
.GetAddress(ScriptPubKeyType.Legacy, Network.Main)
.ToString();
...which returns the expected (previously funded) address of "1DBaumZxUkM4qMQRt2LVWyFJq5kDtSZQot", and the added bonus is that I don't have to convert the BigInteger numbers I already had into HEX strings after all
[moderator's note: consecutive posts merged]