Skip to content

Commit

Permalink
fix: handle case when transaction has no outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
Charon-Fan committed Oct 18, 2024
1 parent 2b8c27c commit 72426fa
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions rust/apps/cardano/src/structs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,10 +317,16 @@ impl ParsedCardanoTx {

fn judge_network_id(tx: &Transaction) -> u8 {
match tx.body().network_id() {
None => match tx.body().outputs().get(0).address().network_id() {
Ok(id) => id,
Err(_) => 1,
},
None => {
let outputs = tx.body().outputs();
if (outputs.len() == 0) {
return 1;
}
match outputs.get(0).address().network_id() {
Ok(id) => id,
Err(_) => 1,
}
}
Some(id) => match id.kind() {
NetworkIdKind::Mainnet => 1,
NetworkIdKind::Testnet => 0,
Expand Down

0 comments on commit 72426fa

Please sign in to comment.