-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor: consistent use of displayName vs walletFileName * refactor: Settings component from jsx to tsx * refactor: Wallets component from jsx to tsx * refactor: Onboarding component from jsx to tsx * refactor: ScheduleProgress component from jsx to tsx * chore(i18n): consistent use of global.errors.reason_unknown * refactor: CreateWallet component from jsx to tsx * refactor: BitcoinQR from jsx to tsx * refactor: Receive component from jsx to tsx * refactor: Earn component from jsx to tsx * dev(regtest): switch to python:3.11-slim-bookworm as base image see JoinMarket-Org/joinmarket-clientserver#1484 (comment) * chore(dev): do not log error when fetch was aborted
- Loading branch information
1 parent
4c76d6a
commit 11ee5b4
Showing
41 changed files
with
976 additions
and
750 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { useEffect, useState } from 'react' | ||
import QRCode from 'qrcode' | ||
|
||
import { satsToBtc } from '../utils' | ||
import { AmountSats, BitcoinAddress } from '../libs/JmWalletApi' | ||
|
||
interface BitcoinQRProps { | ||
address: BitcoinAddress | ||
amount?: AmountSats | ||
errorCorrectionLevel?: QRCode.QRCodeErrorCorrectionLevel | ||
width?: number | ||
} | ||
|
||
export const BitcoinQR = ({ address, amount, errorCorrectionLevel = 'H', width = 260 }: BitcoinQRProps) => { | ||
const [data, setData] = useState<string>() | ||
const [image, setImage] = useState<string>() | ||
|
||
useEffect(() => { | ||
const btc = amount ? satsToBtc(String(amount)) || 0 : 0 | ||
const uri = `bitcoin:${address}${btc > 0 ? `?amount=${btc.toFixed(8)}` : ''}` | ||
|
||
QRCode.toDataURL(uri, { | ||
errorCorrectionLevel, | ||
width, | ||
}) | ||
.then((val) => { | ||
setImage(val) | ||
setData(uri) | ||
}) | ||
.catch(() => { | ||
setImage(undefined) | ||
setData(uri) | ||
}) | ||
}, [address, amount, errorCorrectionLevel, width]) | ||
|
||
return ( | ||
<div> | ||
<img src={image} alt={data} title={data} /> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.