Author

Topic: Why does "validateaddress" return TRUE for bitcoin addys in testnet? (Read 3098 times)

lfm
full member
Activity: 196
Merit: 104
The theymos' post, 3 posts above is rather clear
It's for when we'll use a new kind of addresses, e.g. when we'll use addresses version 2, it would be useful to send coins to old addresses...

Also, testnet coins sent to bitcoin address are easily retrievable, I made a guide about that

Well sorry but it wasn't all that clear to me. A new address version would seem to need a lot more code than just <= version and it is a hypothetical future use as opposed to the implemented current use of the version byte

I understand how you can just switch wallets around to retrieve the "lost" coins but if the sent to address isn't yours it may not be as easy as you make it sound.
True they're "just" testnet coins lost, no big deal I suppose but I still found it inconvenient and it just seems like a simple fix and the objections are rather abstract/hypothetical.
administrator
Activity: 5222
Merit: 13032
I understand that, I don't understand why this behavior is useful or desirable in any way. Couldn't we just say when running i testnet mode you need to use the 111 tagged version of the address. The others will generate an error. It seems to me it would prevent some mistakes sending testnet coins to limbo when we think we are sending mainnet coins.


Yes, but this should be a special case for testnet.
legendary
Activity: 1176
Merit: 1280
May Bitcoin be touched by his Noodly Appendage
On testnet, mainnet addresses are basically "aliases" of their equivalent testnet addresses. Sending to 1KNHQ7513gVwJv5fG4ucsPgkdb5Ub9UzR6 is exactly the same as sending to mytEhA9yrhwC62ZGydszhJu5VagBZj2z7t. The only difference between these two addresses is the version and checksum: the public key hash is the same.

If you copy your wallet.dat from mainnet to testnet, your receiving addresses will all still be there: they will just have been changed to their "testnet" aliases. The associated mainnet versions will still work for transactions on testnet.

On testnet, there are actually 111 valid ways of expressing of every address. These are all the same:
1KNHQ7513gVwJv5fG4ucsPgkdb5Ub9UzR6
ihtPDNHkrxp8MDkHVEwMWxYG6LRMEvGhC
283VNKfaU3RgwnMqJuaFqeEKtbbN1Q5KFY
2XP6MRxsBDtZmDVvLKuaKmW7X6rJiSaZ9Z
2vihLYG9tQMSaee1MkEtotmu9c7FSBxg9a
3L4JKeZSbapKQ5n6PAaDJ23gn7NCD2x9V1
...

I understand that, I don't understand why this behavior is useful or desirable in any way. Couldn't we just say when running i testnet mode you need to use the 111 tagged version of the address. The others will generate an error. It seems to me it would prevent some mistakes sending testnet coins to limbo when we think we are sending mainnet coins.

The theymos' post, 3 posts above is rather clear
It's for when we'll use a new kind of addresses, e.g. when we'll use addresses version 2, it would be useful to send coins to old addresses...

Also, testnet coins sent to bitcoin address are easily retrievable, I made a guide about that
lfm
full member
Activity: 196
Merit: 104
On testnet, mainnet addresses are basically "aliases" of their equivalent testnet addresses. Sending to 1KNHQ7513gVwJv5fG4ucsPgkdb5Ub9UzR6 is exactly the same as sending to mytEhA9yrhwC62ZGydszhJu5VagBZj2z7t. The only difference between these two addresses is the version and checksum: the public key hash is the same.

If you copy your wallet.dat from mainnet to testnet, your receiving addresses will all still be there: they will just have been changed to their "testnet" aliases. The associated mainnet versions will still work for transactions on testnet.

On testnet, there are actually 111 valid ways of expressing of every address. These are all the same:
1KNHQ7513gVwJv5fG4ucsPgkdb5Ub9UzR6
ihtPDNHkrxp8MDkHVEwMWxYG6LRMEvGhC
283VNKfaU3RgwnMqJuaFqeEKtbbN1Q5KFY
2XP6MRxsBDtZmDVvLKuaKmW7X6rJiSaZ9Z
2vihLYG9tQMSaee1MkEtotmu9c7FSBxg9a
3L4JKeZSbapKQ5n6PAaDJ23gn7NCD2x9V1
...

I understand that, I don't understand why this behavior is useful or desirable in any way. Couldn't we just say when running i testnet mode you need to use the 111 tagged version of the address. The others will generate an error. It seems to me it would prevent some mistakes sending testnet coins to limbo when we think we are sending mainnet coins.
legendary
Activity: 1176
Merit: 1280
May Bitcoin be touched by his Noodly Appendage
The address checking code assumes that any version lower than the latest version is handled elsewhere in the code. Future versions could not possibly be handled.

Example: If we move to SHA-256 hashes instead of RIPEMD-160 hashes, the address version will change to 1. Addresses with version 0 will still be valid, though: they will just be handled with the old code instead of the new code, or maybe trying to use them will trigger an informative error.

Testnet doesn't include the cases for old versions that the checking code expected.
Everything is clear now, thanks
administrator
Activity: 5222
Merit: 13032
I HAVE to ask for any explanation about that
I mean, either devs want any address version is ok for any network (and address versions become useless) or they want exactly one address version par network
Why accepting all lower ones but not higher ones?

The address checking code assumes that any version lower than the latest version is handled elsewhere in the code. Future versions could not possibly be handled.

Example: If we move to SHA-256 hashes instead of RIPEMD-160 hashes, the address version will change to 1. Addresses with version 0 will still be valid, though: they will just be handled with the old code instead of the new code, or maybe trying to use them will trigger an informative error.

Testnet doesn't include the cases for old versions that the checking code expected.
legendary
Activity: 1176
Merit: 1280
May Bitcoin be touched by his Noodly Appendage
The address version of testnet is 111 instead of 0. Bitcoin sees all address versions lower than its current version as valid. So testnet sees mainnet addresses as valid.
I HAVE to ask for any explanation about that
I mean, either devs want any address version is ok for any network (and address versions become useless) or they want exactly one address version par network
Why accepting all lower ones but not higher ones?
administrator
Activity: 5222
Merit: 13032
On testnet, mainnet addresses are basically "aliases" of their equivalent testnet addresses. Sending to 1KNHQ7513gVwJv5fG4ucsPgkdb5Ub9UzR6 is exactly the same as sending to mytEhA9yrhwC62ZGydszhJu5VagBZj2z7t. The only difference between these two addresses is the version and checksum: the public key hash is the same.

If you copy your wallet.dat from mainnet to testnet, your receiving addresses will all still be there: they will just have been changed to their "testnet" aliases. The associated mainnet versions will still work for transactions on testnet.

On testnet, there are actually 111 valid ways of expressing of every address. These are all the same:
1KNHQ7513gVwJv5fG4ucsPgkdb5Ub9UzR6
ihtPDNHkrxp8MDkHVEwMWxYG6LRMEvGhC
283VNKfaU3RgwnMqJuaFqeEKtbbN1Q5KFY
2XP6MRxsBDtZmDVvLKuaKmW7X6rJiSaZ9Z
2vihLYG9tQMSaee1MkEtotmu9c7FSBxg9a
3L4JKeZSbapKQ5n6PAaDJ23gn7NCD2x9V1
...
hero member
Activity: 737
Merit: 500
So you can send testnet coins then to a bitcoin address?

I think you're getting confused by the difference between addresses and networks.

Maybe you exported your address and private key from your normal client wallet.dat and imported it into your testnet client. Now you have a normal looking bitcoin address on a testnet client.   If you have a normal style address on the testnet, you can send testnet coins to it.  That doesn't mean that the coins are going to magically show up at that address on the normal network.  They will only be at that address on the test network.  Why do this?  I can't think of a reason why you would want to do this, but the reality is that you can.

You can't send coins between networks.  They have different block chains.


newbie
Activity: 42
Merit: 0
bitcoin addresses are valid destinations on testnet (you can send test coins to a bitcoin address)

testnet addresses are not valid destinations on non-testnet (you can not send normal coins to a testnet address).

validateaddress essentially is validating that an address is a valid destination address.

So you can send testnet coins then to a bitcoin address?

How would you send them from the bitcoin address back to a testnet address?

So technically the client could generate a bitcoin address key pair for testnet accounts, it simply does not by default?

Any external reading on this?

Questions, questions, questions..!!
administrator
Activity: 5222
Merit: 13032
The address version of testnet is 111 instead of 0. Bitcoin sees all address versions lower than its current version as valid. So testnet sees mainnet addresses as valid.
hero member
Activity: 737
Merit: 500
bitcoin addresses are valid destinations on testnet (you can send test coins to a bitcoin address)

testnet addresses are not valid destinations on non-testnet (you can not send normal coins to a testnet address).

validateaddress essentially is validating that an address is a valid destination address.
newbie
Activity: 42
Merit: 0
I mean... when I attempt to validate an address and bitcoind is running testnet... both testnet and bitcoin addresses are valid addresses.

That is not true however, or rather it cannot be true, can it?

You cannot send bitcoins to a testnet address, can you?
Jump to: