Validate coin config critical fields (e.g. derivation_path purpose field)
MM2 coin config has a 'derivation_path' parameter which defines how hierarchically derived addresses are created. The purpose field in the derivation_path should be validated for coins with configured segwit or non-segwit address usage according to the BIP44 and BIP84 standards. There is a param in coin configuration that determines that for this coin segwit addresses are used. This param is 'format' field in the 'address_format' set to "segwit" or set to other value if non-segwit addresses are used. Sample coin config for segwit addresses:
{
"coin": "BTC-segwit",
...
"bech32_hrp": "bc",
"address_format": {
"format": "segwit"
},
...
"derivation_path": "m/84'/0'",
...
},
In addition, what happens if incorrect purpose is set for a segwit coin (44 instead of 84): if the hd wallet API or trezor wallet is used with a segwit coin then create_new_account() will create different pubkeys than pubkeys created by other apps that follow the BIP84 standard (like trezor firmware). For this time the hd wallet api is not used in the GUI and trezor is not enabled for segwit coins yet so this change won't create any problems with user funds.