Bitcore is making invalid addresses


(Priestc) #1

(new bitcore.PrivateKey()).toAddress(bitcore.Networks.get(‘mrs’)).toString()
“MMhdMVPgfURmEgPQbekKY5NJJayhPXNN1C”

bitcore.Address.isValid(“MMhdMVPgfURmEgPQbekKY5NJJayhPXNN1C”, bitcore.Networks.get(‘mrs’))
false

(new bitcore.PrivateKey()).toAddress(bitcore.Networks.get(‘mrs’)).toString()
“M7wL9sP1yekuYKNDxxQqUZWQUxG4JjZj8K”

bitcore.Address.isValid(“M7wL9sP1yekuYKNDxxQqUZWQUxG4JjZj8K”, bitcore.Networks.get(‘mrs’))
false

The ‘mrs’ network is defined as having privatekey=178 and pubkeyhash=50


(Priestc) #2

By the way, the addresses generated appear to be valid, it’s just the isValid method that is incorrectly reporting that the address in invalid.


(Priestc) #3

Furthermore,

bitcore.Address.getValidationError(“M7wL9sP1yekuYKNDxxQqUZWQUxG4JjZj8K”, bitcore.Networks.get(‘mrs’))
TypeError: Address has mismatched network type.


(Jeshan Babooa) #4

then update the post title accordingly


(Priestc) #5

I figured out the problem. The reason why MRS wasn’t working is because I have another network registered (XMY) which uses the same address byte (50). I guess you can’t use networks with the same address byte simultaneously… Is there a workaround?

Here is a demonstration of the error:

https://jsfiddle.net/c6ko3btm/

see how #76 are all invalid?


(Priestc) #6

I figured out a fix:

https://github.com/priestc/bitcore-lib/commit/c79d60dfb16e43d495732ccbc50f632c4b9edecb

This solves the issue I’m having, but a shitload of tests now fail. Does anybody who knows a lot about bitcore’s internals want to help me get all tests passing?