Skip to content

Commit

Permalink
offline wallet mnemonics
Browse files Browse the repository at this point in the history
  • Loading branch information
bokkypoobah committed Apr 16, 2024
1 parent f3dad0a commit 2634a4f
Showing 1 changed file with 26 additions and 7 deletions.
33 changes: 26 additions & 7 deletions docs/offline.html
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,11 @@
<b-form-group v-if="wallet.type == 'privatekey'" label="Private Key:" label-for="wallet-privatekey" label-size="sm" label-cols-sm="2" label-align-sm="right" class="mx-0 my-1 p-0">
<b-form-input type="text" size="sm" id="wallet-privatekey" v-model="wallet.privateKey" @change="recomputeWallet();" class="w-75"></b-form-input>
</b-form-group>

<b-form-group v-if="wallet.type == 'mnemonics'" label="Mnemonics:" label-for="wallet-mnemonics" label-size="sm" label-cols-sm="2" label-align-sm="right" class="mx-0 my-1 p-0">
<b-form-textarea size="sm" id="wallet-mnemonics" v-model="wallet.mnemonics" @change="recomputeWallet();" rows="3" class="w-75"></b-form-textarea>
</b-form-group>

</b-form-group>

<b-form-group label-cols-lg="1" label="Output" label-size="md" label-class="font-weight-bold pt-0" class="mt-3 mb-0">
Expand Down Expand Up @@ -498,7 +503,7 @@ <h5 class="mt-3">Troubleshooting</h5>
// --- DATA ---
data: {
wallet: {
type: 'privatekey',
type: 'mnemonics', // 'privatekey', 'keystorefile'
mnemonics: null,
keystore: null,
privateKey: null,
Expand Down Expand Up @@ -949,14 +954,28 @@ <h5 class="mt-3">Troubleshooting</h5>
async recomputeWallet() {
console.log(moment().format("HH:mm:ss") + " recomputeWallet: " + JSON.stringify(this.wallet));
if (this.wallet.type == 'privatekey') {
const wallet = new ethers.Wallet(this.wallet.privateKey);
this.wallet.address = wallet.address;
this.wallet.publicKey = wallet.publicKey;
// TODO: ethers.js returns an error
// this.wallet.compressedPublicKey = wallet.compressedPublicKey || 'ethers.js returning an error';
console.table(wallet);
try {
const wallet = new ethers.Wallet(this.wallet.privateKey);
this.wallet.address = wallet.address;
this.wallet.publicKey = wallet.publicKey;
// TODO: ethers.js returns an error
// this.wallet.compressedPublicKey = wallet.compressedPublicKey || 'ethers.js returning an error';
console.table(wallet);
} catch (e) {
console.log(moment().format("HH:mm:ss") + " recomputeWallet ERROR: " + e.message);
}
} else if (this.wallet.type == 'mnemonics') {
console.log(moment().format("HH:mm:ss") + " recomputeWallet - mnemonics: " + JSON.stringify(this.wallet));
try {
const wallet = new ethers.Wallet.fromMnemonic(this.wallet.mnemonics);
this.wallet.address = wallet.address;
this.wallet.publicKey = wallet.publicKey;
// TODO: ethers.js returns an error
// this.wallet.compressedPublicKey = wallet.compressedPublicKey || 'ethers.js returning an error';
console.table(wallet);
} catch (e) {
console.log(moment().format("HH:mm:ss") + " recomputeWallet ERROR: " + e.message);
}
} else if (this.wallet.type == 'keystorefile'){
console.log(moment().format("HH:mm:ss") + " recomputeWallet - keystorefile: " + JSON.stringify(this.wallet));
}
Expand Down

0 comments on commit 2634a4f

Please sign in to comment.