Skip to content

Commit

Permalink
Fixed Wallet.js to convert xrb_ to nano_ on wallet loading.
Browse files Browse the repository at this point in the history
  • Loading branch information
gokr committed Aug 23, 2019
1 parent 98e35eb commit 659f6ed
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion Wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -1282,6 +1282,16 @@ module.exports = function (password) {
return new TextEncoder('utf-8').encode(myString)
}

/**
* Convert an xrb_account to a nano_account, replacing prefix.
*/
function xrb2nano (acc) {
if (acc.startsWith('xrb_')) {
return 'nano' + acc.slice(3)
}
return acc
}

/**
* Constructs the wallet from an encrypted base64 encoded wallet
*/
Expand Down Expand Up @@ -1338,7 +1348,7 @@ module.exports = function (password) {

aux.priv = hex_uint8(walletData.keys[i].priv)
aux.pub = hex_uint8(walletData.keys[i].pub)
aux.account = walletData.keys[i].account
aux.account = xrb2nano(walletData.keys[i].account)
aux.balance = bigInt(walletData.keys[i].balance ? walletData.keys[i].balance : 0)
aux.lastBlock = aux.chain.length > 0 ? aux.chain[aux.chain.length - 1].getHash(true) : ''
aux.lastPendingBlock = aux.lastBlock
Expand Down

0 comments on commit 659f6ed

Please sign in to comment.