Merge #743: gui: coinbase transaction output scripts may not represent valid addresses

2f2975c2790e83c592cd0ff594d3e8ce8a7c75d9 coinbase transaction outputs may not have valid scripts (edouard)

Pull request description:

  close #738
  liana-gui v2 also tried to display addresses from transaction outputs to user when clicking on transaction detail.

ACKs for top commit:
  edouardparis:
    Self-ACK 2f2975c2790e83c592cd0ff594d3e8ce8a7c75d9

Tree-SHA512: 7f5fc374baec773fef848cd104b8acbd34ce19a04f9614d0c446a93ee8b6b976acd98d7494031651a614bef38c0913217865f2086bf19a018ce17f57ef362c57
This commit is contained in:
edouard 2023-10-24 17:31:13 +02:00
commit ec2e2e5edc
No known key found for this signature in database
GPG Key ID: E65F7A089C20DC8F
3 changed files with 15 additions and 18 deletions

View File

@ -158,17 +158,14 @@ fn event_list_view(i: usize, event: &HistoryTransaction) -> Column<'_, Message>
.to_string(),
) {
Some(p1_regular(label))
} else if let Ok(addr) =
bitcoin::Address::from_script(&output.script_pubkey, event.network)
{
event.labels.get(&addr.to_string()).map(|label| {
p1_regular(format!("address label: {}", label)).style(color::GREY_3)
})
} else {
event
.labels
.get(
&bitcoin::Address::from_script(&output.script_pubkey, event.network)
.unwrap()
.to_string(),
)
.map(|label| {
p1_regular(format!("address label: {}", label)).style(color::GREY_3)
})
None
};
if event.is_external() {
if !event.change_indexes.contains(&output_index) {

View File

@ -820,8 +820,8 @@ fn payment_view<'a>(
labels_editing: &'a HashMap<String, form::Value<String>>,
) -> Element<'a, Message> {
let addr = Address::from_script(&output.script_pubkey, network)
.unwrap()
.to_string();
.ok()
.map(|a| a.to_string());
let outpoint = OutPoint {
txid,
vout: i as u32,
@ -848,7 +848,7 @@ fn payment_view<'a>(
)
.push(amount(&Amount::from_sat(output.value))),
)
.push(
.push_maybe(addr.map(|addr| {
Column::new()
.push(
Row::new()
@ -880,8 +880,8 @@ fn payment_view<'a>(
.push(p1_bold("Address label:").style(color::GREY_3))
.push(p2_regular(label).style(color::GREY_3)),
)
})),
)
}))
}))
.into()
}

View File

@ -365,9 +365,9 @@ impl Labelled for HistoryTransaction {
txid,
vout: vout as u32,
}));
items.push(LabelItem::Address(
Address::from_script(&output.script_pubkey, self.network).unwrap(),
));
if let Ok(addr) = Address::from_script(&output.script_pubkey, self.network) {
items.push(LabelItem::Address(addr));
}
}
items
}