mesh
mesh copied to clipboard
use baseAddress when wallet has a stake key hash
I created a mnemonic using AppWallet.brew()
and used it to create an Eternl account. The address Eternl shows is addr_test1qpz7pv40lfljuh34rdsd654ffwvq5306rx64en4cf2sevkptgn6meh05zlmfa878ft70uqnxshqv8avgapn8s4w72utse9ec2p
I then used the AppWallet and the same mnemonic to get these different payment and used addresses: addr_test1vpz7pv40lfljuh34rdsd654ffwvq5306rx64en4cf2sevkqa5f32w
The reason for this is that internally the enterprise address is used which returns a shorter and different address.
The wallet created with Eternl includes a stake key hash. Therefore, the address should be longer and the base address which includes the stake key hash should be used. This pull request fix this issue.
With this fix, the base address is used when the wallet has a stake key hash. This is the case when the wallet is created with a mnemonic, root key, or with a paymentSkey
and stakeSkey
. When the wallet is only created with a paymentSkey
(without stakeSkey
) the enterprise address is used. The derived root key from this mnemonic (xprv17rmvncq7036uvgtaqjl4sjz34znu2aypeq9927kheay9tf38tar0nkjnu0x6ztgwrjjhvps6j3l9k84gs7erhhrhnv69m0lh2duaya9v4ds2px7h283gv922mxynnn2adymr8hd3g70kj6fv8mys5dn525d3v27d
) also returns the address Eternl shows.
NOTE: Please be aware that if you use this fix on previously generated wallets with a mnemonic, the wallet will return a different address and you might not be able to access your unspent transaction outputs (UTXOs).
The following code shows the same addresses as Eternl after the fix:
const words = 'theory deal subject wedding impose goat aunt future inside whisper govern push puppy medal sting garlic between exist swim brave live senior dune entry'.split(' ');
const wallet = new AppWallet({
networkId: networkId,
fetcher: blockchainProvider,
submitter: blockchainProvider,
key: {
type: "mnemonic",
words,
},
});
console.log("payment address:", wallet.getPaymentAddress());
console.log("used address:", wallet.getUsedAddress().to_json());
payment address: addr_test1qpz7pv40lfljuh34rdsd654ffwvq5306rx64en4cf2sevkptgn6meh05zlmfa878ft70uqnxshqv8avgapn8s4w72utse9ec2p
used address: "addr_test1qpz7pv40lfljuh34rdsd654ffwvq5306rx64en4cf2sevkptgn6meh05zlmfa878ft70uqnxshqv8avgapn8s4w72utse9ec2p"
@choas is attempting to deploy a commit to the MeshJS Team on Vercel.
A member of the Team first needs to authorize it.
This is great, @abdelkrimdev will review this.
As you mentioned this is going to break backward compatibility, people who are already using AppWallet
will start getting a different address, the other thing we need take consider is account discovery and UTxO
fetching. currently we have only one address to look into, but if we add more we have figure out how to resolve that issue first.
Probably AppWallet
needs a complete redesign to overcome those limitations 🤔
have merged this into Mesh Wallet