I am trying to dump and import a private key but I am having strange problems.
I must be making some really silly mistake here:
ADDR=`nud getaccountaddress ""`
WIF_KEY=`nud dumpprivkey "$ADDR"`
#Then you stop nud, delete walletB.data and walletS.dat so new ones are created (you can also use another nud instance with a diferent wallet)
nud importprivkey "$WIF_KEY" "imported1"
nud getaccountaddress "imported1" #You get a new, diferent address
echo $ADDR #Check the address for which you exported the WIF private key
#They do not match?
Do they match to you? Here they don’t.
I ran nud validateaddress $ADDR and it shows that it is valid and that is also in the “imported1” account, but nud getaccountaddress "imported1" only show the new, different address created when importing the WIF key.
So it is somewhere in the wallet but you can not see it in any account. Is this the expected behavior?
you have to use -unit=B as additional parameter when importing NBT addresses, otherwise they are considered as NSR addresses and your wallet is messed up (not broken, but it may display misleading data).
Ah ok, sorry I didn’t read that you also posted how you dumped the key.
However, note that the second parameter of importprivkey is the label of this address, not the account. getaccountaddress asks for an account and you provide the label of this address, which will return an empty account I guess.
If the NSR is not empty then it should show up when you type listreceivedbyaddress.
I am also confused by the difference in arguments with “label” and “account”, but as far as I understand you can have multiple accounts, each one with a name, and inside each account multiple address. But individual address do not have a “label” so it should be the same as the account name.
Also when I execute importprivkey with a new account name in the “label” argument, a new account with the label name is created, and inside that account the address is added.