Bitcore is making invalid addresses

(Priestc) #1

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

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

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

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

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


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:

see how #76 are all invalid?

(Priestc) #6

I figured out a fix:

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?