bitcoin core – Generate public addresses (NBitcoin)

0
66


Query was posted & answered on the NBitcoin repo, so copying my solutions right here for the advantage of SE members:

This can be a Blockchain.com-specific UX concern… They technically might generate a Segwit tackle, however they default to P2PKH (legacy) in the meanwhile.

WIF is an outdated format that does not carry metadata in regards to the form of tackle that ought to be unwrapped from the personal key, so if you import a non-public key WIF right into a pockets, it is as much as the pockets to resolve what sort of tackle to provide you for that personal key.

ps: Some wallets are “good” and test all doable addresses (Legacy, Segwit, SegwitP2SH, …) after which choose whichever one has a stability, so that you would possibly need to put some satoshis on the Segwit tackle that you just create earlier than importing the personal key WIF to a pockets.


Personal keys may be related to public keys which might be both compressed (33 bytes) or uncompressed (65 bytes), and the WIF will likely be totally different if compressed/uncompressed. As an example, compressed public keys begin with L or Ok on Mainnet and c on Testnet, while uncompressed public keys begin with 5 on Mainnet and 9 on Testnet.

You’ll be able to modify your code pattern above to make use of uncompressed public keys (the default is compressed):

var key = new Key(fCompressedIn: false);
// ...

LEAVE A REPLY

Please enter your comment!
Please enter your name here