btcsuite / btcutil

Provides bitcoin-specific convenience functions and types
479 stars 409 forks source link

Could DecodeAddress be used with other bitcoin like chains? #107

Closed andrewshvv closed 6 years ago

andrewshvv commented 6 years ago

Hey, thanks for the library!

I have a questions: Have the DecodeAddress function were designed to be used with other bitcoin-like chains also? If so, it seems like at this moment it couldn't be used like this because of:

address.go, 190: case ripemd160.Size: // P2PKH or P2SH
address.go, 191:    isP2PKH := chaincfg.IsPubKeyHashAddrID(netID)
address.go, 192:    isP2SH := chaincfg.IsScriptHashAddrID(netID)
address.go, 193:    switch hash160 := decoded; 

chaincfg.IsPubKeyHashAddrID function uses pubKeyHashAddrIDs map which is initialised with default main bitcoin net parameters, rather than defaultNet DecodeAddress field.

stevenroose commented 6 years ago

You can use the chaincfg.Register method to register your own chaincfg.Params instances. It is true that the default ones for Bitcoin are registered automatically in the init() function, though.

andrewshvv commented 6 years ago

@stevenroose ooh god, your right Register... 😛 Thanks