Skip to content

Commit db89117

Browse files
committed
Don't panic when missing payment metadata
1 parent 293adc1 commit db89117

1 file changed

Lines changed: 21 additions & 6 deletions

File tree

orange-sdk/src/lib.rs

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -722,24 +722,39 @@ impl Wallet {
722722
},
723723
}
724724
} else {
725-
debug_assert!(
726-
!payment.outbound,
727-
"Missing outbound trusted payment metadata entry on {:?}",
728-
payment.id
729-
);
725+
if payment.outbound {
726+
log_warn!(
727+
self.inner.logger,
728+
"Missing outbound trusted payment metadata entry on {:?}",
729+
payment.id
730+
);
731+
#[cfg(feature = "_test-utils")]
732+
debug_assert!(
733+
false,
734+
"Missing outbound trusted payment metadata entry on {:?}",
735+
payment.id
736+
);
737+
}
730738

731739
if payment.status != TxStatus::Completed {
732740
// We don't bother to surface pending inbound transactions (i.e. issued but
733741
// unpaid invoices) in our transaction list.
734742
continue;
735743
}
744+
745+
let payment_type = if payment.outbound {
746+
PaymentType::OutgoingLightningBolt11 { payment_preimage: None }
747+
} else {
748+
PaymentType::IncomingLightning {}
749+
};
750+
736751
res.push(Transaction {
737752
id: PaymentId::Trusted(payment.id),
738753
status: payment.status,
739754
outbound: payment.outbound,
740755
amount: Some(payment.amount),
741756
fee: Some(payment.fee),
742-
payment_type: PaymentType::IncomingLightning {},
757+
payment_type,
743758
time_since_epoch: payment.time_since_epoch,
744759
});
745760
}

0 commit comments

Comments
 (0)