fix wrong index in receive qrcode

This commit is contained in:
edouardparis 2024-03-22 13:57:08 +01:00
parent 5527e635a6
commit 615be66655

View File

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