Merge #1025: fix wrong index in receive qrcode

615be66655f1a75e14122272ac9ec2dbc3a6a902 fix wrong index in receive qrcode (edouardparis)

Pull request description:

ACKs for top commit:
  pythcoiner:
    utACK 615be66655f1a75e14122272ac9ec2dbc3a6a902
  jp1ac4:
    ACK 615be66655. I checked that the index shown by the QR matched the index shown when verifying on hardware device.

Tree-SHA512: 89b8c40975bedd07170db30383f619d7f33752a9c27537f9bb9176038a4fc3473a6fb0ca47e48b932011de96ee315d9fc22ff7cad1f416b0be6ef0fd11e67295
This commit is contained in:
edouardparis 2024-03-22 14:44:11 +01:00
commit a5887f25dd
No known key found for this signature in database
GPG Key ID: E65F7A089C20DC8F

View File

@ -174,8 +174,11 @@ impl State for ReceivePanel {
)
}
Message::View(view::Message::ShowQrCode(i)) => {
if let Some(address) = self.addresses.list.get(i) {
if let Some(modal) = ShowQrCodeModal::new(address, i) {
if let (Some(address), Some(index)) = (
self.addresses.list.get(i),
self.addresses.derivation_indexes.get(i),
) {
if let Some(modal) = ShowQrCodeModal::new(address, *index) {
self.modal = Modal::ShowQrCode(modal);
}
}
@ -312,8 +315,8 @@ pub struct ShowQrCodeModal {
}
impl ShowQrCodeModal {
pub fn new(address: &Address, i: usize) -> Option<Self> {
qr_code::State::new(format!("bitcoin:{}?index={}", address, i))
pub fn new(address: &Address, index: ChildNumber) -> Option<Self> {
qr_code::State::new(format!("bitcoin:{}?index={}", address, index))
.ok()
.map(|qr_code| Self {
qr_code,