bitcoin core - Generate public addresses (NBitcoin)

bitcoin core – Generate public addresses (NBitcoin)

 

Question was posted & answered on the NBitcoin repo, so copying my answers here for the benefit of SE members:

This is a Blockchain.com-specific UX issue… They technically could generate a Segwit address, but they default to P2PKH (legacy) at the moment.

WIF is an old format that doesn’t carry metadata about the kind of address that should be unwrapped from the private key, so when you import a private key WIF into a wallet, it’s up to the wallet to decide what kind of address to give you for that private key.

ps: Some wallets are “smart” and check all possible addresses (Legacy, Segwit, SegwitP2SH, …) and then pick whichever one has a balance, so you might want to put some satoshis on the Segwit address that you create before importing the private key WIF to a wallet.


Private keys can be associated with public keys that are either compressed (33 bytes) or uncompressed (65 bytes), and the WIF will be different if compressed/uncompressed. For instance, compressed public keys start with L or K on Mainnet and c on Testnet, whilst uncompressed public keys start with 5 on Mainnet and 9 on Testnet.

You can modify your code sample above to use uncompressed public keys (the default is compressed):

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



Source link

Leave a Comment

Your email address will not be published.