From b2ecd7a3af56c7959808752b1661b13123ffb10b Mon Sep 17 00:00:00 2001 From: CalDescent <> Date: Fri, 6 May 2022 16:04:09 +0100 Subject: [PATCH] Send a base58 encoded, ARRR-specific seed derived from the master seed, to use as the entropy for the ARRR wallet seed in the core. This will need a lot of sanity checking before going live, as it may not be the best approach. --- .../api/bitcoin/AltcoinHDWallet.js | 3 ++ .../plugins/core/wallet/wallet-app.src.js | 42 +++++++++++++++++-- 2 files changed, 42 insertions(+), 3 deletions(-) diff --git a/qortal-ui-crypto/api/bitcoin/AltcoinHDWallet.js b/qortal-ui-crypto/api/bitcoin/AltcoinHDWallet.js index 0c7c70f8..0d416d54 100644 --- a/qortal-ui-crypto/api/bitcoin/AltcoinHDWallet.js +++ b/qortal-ui-crypto/api/bitcoin/AltcoinHDWallet.js @@ -276,6 +276,8 @@ export default class AltcoinHDWallet { const privateKeyHash = seedHash.slice(0, 32); + this.seed58 = Base58.encode(privateKeyHash); + const _privateKeyHash = [...privateKeyHash] let privateKeyBigInt = BigInteger.fromByteArrayUnsigned(_privateKeyHash); @@ -865,6 +867,7 @@ export default class AltcoinHDWallet { derivedMasterPublicKey: this.masterPublicKey, _tDerivedMasterPrivateKey: this._tMasterPrivateKey, _tDerivedmasterPublicKey: this._tmasterPublicKey, + seed58: this.seed58, // derivedPrivateChildKey: this.xPrivateChildKey, // derivedPublicChildKey: this.xPublicChildKey, // derivedPrivateGrandChildKey: this.xPrivateGrandChildKey, diff --git a/qortal-ui-plugins/plugins/core/wallet/wallet-app.src.js b/qortal-ui-plugins/plugins/core/wallet/wallet-app.src.js index 5d968e62..3ad60f5f 100644 --- a/qortal-ui-plugins/plugins/core/wallet/wallet-app.src.js +++ b/qortal-ui-plugins/plugins/core/wallet/wallet-app.src.js @@ -2430,14 +2430,14 @@ class MultiWallet extends LitElement { async sendArrr() { const arrrAmount = this.shadowRoot.getElementById('arrrAmountInput').value let arrrRecipient = this.shadowRoot.getElementById('arrrRecipient').value - const xprv58 = this.wallets.get(this._selectedWallet).wallet.derivedMasterPrivateKey + const seed58 = this.wallets.get(this._selectedWallet).wallet.seed58 this.sendMoneyLoading = true this.btnDisable = true const makeRequest = async () => { const opts = { - xprv58: xprv58, + xprv58: seed58, receivingAddress: arrrRecipient, ravencoinAmount: arrrAmount, feePerByte: (this.arrrFeePerByte / 1e8).toFixed(8), @@ -2525,7 +2525,6 @@ class MultiWallet extends LitElement { case 'doge': case 'dgb': case 'rvn': - case 'arrr': const walletName = `${coin}Wallet` parentEpml.request('apiCall', { url: `/crosschain/${coin}/walletbalance?apiKey=${this.getApiKey()}`, @@ -2562,6 +2561,43 @@ class MultiWallet extends LitElement { this.wallets.get(this._selectedWallet).transactions = sortedTransactions } break + case 'arrr': + const arrrWalletName = `${coin}Wallet` + parentEpml.request('apiCall', { + url: `/crosschain/${coin}/walletbalance?apiKey=${this.getApiKey()}`, + method: 'POST', + body: `${window.parent.reduxStore.getState().app.selectedAddress[arrrWalletName].seed58}`, + }) + .then((res) => { + if (isNaN(Number(res))) { + let snack5string = get("walletpage.wchange33") + let snack6string = get("walletpage.wchange34") + parentEpml.request('showSnackBar', `${snack5string} ${coin.toLocaleUpperCase()} ${snack6string}!`) + } else { + if (this._selectedWallet == coin) { + this.wallets.get(this._selectedWallet).balance = (Number(res) / 1e8).toFixed(8) + this.balanceString = this.wallets.get(this._selectedWallet).balance + " " + this._selectedWallet.toLocaleUpperCase() + this.balance = this.wallets.get(this._selectedWallet).balance + } + } + }) + + const arrrTxs = await parentEpml.request('apiCall', { + url: `/crosschain/${coin}/wallettransactions?apiKey=${this.getApiKey()}`, + method: 'POST', + body: `${window.parent.reduxStore.getState().app.selectedAddress[arrrWalletName].seed58}`, + }) + + const arrrCompareFn = (a, b) => { + return b.timestamp - a.timestamp + } + + const arrrSortedTransactions = arrrTxs.sort(arrrCompareFn) + console.log(arrrSortedTransactions) + if (this._selectedWallet == coin) { + this.wallets.get(this._selectedWallet).transactions = arrrSortedTransactions + } + break default: break }