bitshares / bitsharesjs

JavaScript tools for BitShares Encryption and Serialization
https://bitsharesjs.bitshares.org/
MIT License
96 stars 148 forks source link

generateKeys() returns public keys with incorrect prefix if same account-password combination was already processed with it using another prefix #46

Closed femtocat closed 2 years ago

femtocat commented 5 years ago

const bts = require('bitsharesjs'); undefined bts.Login.generateKeys("randomaccount-777", "thisisafakepassword", ['active', 'owner', 'memo'], 'FAKEPREFIX').pubKeys { active: 'FAKEPREFIX6jhmykDHAfUyCLVBkjzYN2jdhdcNtXv3BrBr1u3byz2wphSBNh', owner: 'FAKEPREFIX6xKHNcqgJnEdMETPcxxAaPZwfjiqgXPn7NHsCGMxTqcqb3HwNd', memo: 'FAKEPREFIX5uUuJNu7i1F6Q9ZrFAhuVPnG5f8UcMoTdtjy3CRJxRQszkNA4U' } bts.Login.generateKeys("randomaccount-777", "thisisafakepassword", ['active', 'owner', 'memo'], 'BTS').pubKeys { active: 'FAKEPREFIX6jhmykDHAfUyCLVBkjzYN2jdhdcNtXv3BrBr1u3byz2wphSBNh', owner: 'FAKEPREFIX6xKHNcqgJnEdMETPcxxAaPZwfjiqgXPn7NHsCGMxTqcqb3HwNd', memo: 'FAKEPREFIX5uUuJNu7i1F6Q9ZrFAhuVPnG5f8UcMoTdtjy3CRJxRQszkNA4U' }

sschiessl-bcp commented 2 years ago

ChainConfig must know the chain you are trying to get keys for (see bitsharesjs-ws ChainConfig)

You need to do something like this

export function getBlockchainConfig() {
    return {
        name: "SOMENAME",
        address_prefix: "SOMEPREFIX",
        chain_id:
            "someid",
        core_asset: "SOMECORE"
    };
}
const blockchainConfig = getBlockchainConfig();
ChainConfig.networks[blockchainConfig.name] = blockchainConfig;