From e60f6d62a5a0d3aa14cd5031422d8b63836c4e19 Mon Sep 17 00:00:00 2001 From: Sam Holmes Date: Mon, 19 Aug 2024 11:32:10 -0700 Subject: [PATCH] Fix bity message signing for BTC --- CHANGELOG.md | 1 + src/plugins/gui/providers/bityProvider.ts | 30 ++++++++++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7cd8730bd37..163dde58f01 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ - changed: Enable Bitpay payments for FIO names and domains - fixed: Disable max spend for zkSync - fixed: Do not show duplicate password-recovery modals when launching a freshly-installed app for the first time. +- fixed: Fix broken Bity message signing - fixed: If handling a deep link requires a signed-in account, correctly save it for later. ## 4.10.0 (2024-08-07) diff --git a/src/plugins/gui/providers/bityProvider.ts b/src/plugins/gui/providers/bityProvider.ts index efd5b3309c0..67051a608dc 100644 --- a/src/plugins/gui/providers/bityProvider.ts +++ b/src/plugins/gui/providers/bityProvider.ts @@ -293,7 +293,9 @@ const approveBityQuote = async ( if (orderData.message_to_sign != null) { const { body } = orderData.message_to_sign const { publicAddress } = await wallet.getReceiveAddress({ tokenId: null }) - const signedMessage = await wallet.signBytes(utf8.parse(body), { otherParams: { publicAddress } }) + const signedMessage = isUtxoWallet(wallet) + ? await wallet.signMessage(body, { otherParams: { publicAddress } }) + : await wallet.signBytes(utf8.parse(body), { otherParams: { publicAddress } }) const signUrl = baseUrl + orderData.message_to_sign.signature_submission_url const request = { method: 'POST', @@ -768,3 +770,29 @@ const executeBuyOrderFetch = async ( clientId ) } + +function isUtxoWallet(wallet: EdgeCurrencyWallet) { + return [ + 'wallet:badcoin', + 'wallet:bitcoin', + 'wallet:bitcoincash', + 'wallet:bitcoincashtestnet', + 'wallet:bitcoingold', + 'wallet:bitcoingoldtestnet', + 'wallet:bitcoinsv', + 'wallet:bitcointestnet', + 'wallet:dash', + 'wallet:digibyte', + 'wallet:dogecoin', + 'wallet:eboost', + 'wallet:feathercoin', + 'wallet:groestlcoin', + 'wallet:litecoin', + 'wallet:qtum', + 'wallet:ravencoin', + 'wallet:smartcash', + 'wallet:ufo', + 'wallet:vertcoin', + 'wallet:zcoin' + ].includes(wallet.currencyInfo.walletType) +}