Skip to content

Commit

Permalink
Fix output API struct (#3957)
Browse files Browse the repository at this point in the history
  • Loading branch information
raphjaph authored Sep 21, 2024
1 parent 51d84da commit 34ce19a
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 13 deletions.
8 changes: 4 additions & 4 deletions src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ pub struct Output {
pub inscriptions: Vec<InscriptionId>,
pub runes: BTreeMap<SpacedRune, Pile>,
pub sat_ranges: Option<Vec<(u64, u64)>>,
pub script_pubkey: String,
pub script_pubkey: ScriptBuf,
pub spent: bool,
pub transaction: String,
pub transaction: Txid,
pub value: u64,
}

Expand All @@ -182,9 +182,9 @@ impl Output {
inscriptions,
runes,
sat_ranges,
script_pubkey: tx_out.script_pubkey.to_asm_string(),
script_pubkey: tx_out.script_pubkey,
spent,
transaction: outpoint.txid.to_string(),
transaction: outpoint.txid,
value: tx_out.value,
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/subcommand/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ impl List {
inscriptions: list.inscriptions,
runes: list.runes,
sat_ranges: list.sat_ranges.map(output_ranges),
script_pubkey: list.script_pubkey,
script_pubkey: list.script_pubkey.to_asm_string(),
spent: list.spent,
transaction: list.transaction,
transaction: list.transaction.to_string(),
value: list.value,
})))
}
Expand Down
4 changes: 2 additions & 2 deletions src/subcommand/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3543,9 +3543,9 @@ mod tests {
server.get_json::<api::Output>(format!("/output/{output}")),
api::Output {
value: 5000000000,
script_pubkey: address.script_pubkey().to_asm_string(),
script_pubkey: address.script_pubkey(),
address: Some(uncheck(&address)),
transaction: txid.to_string(),
transaction: txid,
sat_ranges: None,
indexed: true,
inscriptions: Vec::new(),
Expand Down
11 changes: 8 additions & 3 deletions tests/json_api.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use {
super::*,
bitcoin::BlockHash,
bitcoin::{BlockHash, ScriptBuf},
ord::{Envelope, Inscription},
};

Expand Down Expand Up @@ -349,9 +349,14 @@ fn get_output() {
(10000000000, 15000000000,),
(15000000000, 20000000000,),
],),
script_pubkey: "OP_0 OP_PUSHBYTES_20 0000000000000000000000000000000000000000".into(),
script_pubkey: ScriptBuf::from(
"bc1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq9e75rs"
.parse::<Address<NetworkUnchecked>>()
.unwrap()
.assume_checked()
),
spent: false,
transaction: txid.to_string(),
transaction: txid,
value: 3 * 50 * COIN_VALUE,
}
);
Expand Down
4 changes: 2 additions & 2 deletions tests/wallet/send.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,9 +362,9 @@ inscriptions:
indexed: true,
runes: BTreeMap::new(),
sat_ranges: Some(vec![(5_000_000_000, 5_000_030_000)]),
script_pubkey: destination.payload.script_pubkey().to_asm_string(),
script_pubkey: destination.payload.script_pubkey(),
spent: false,
transaction: reveal_txid.to_string(),
transaction: reveal_txid,
value: 30_000,
}
);
Expand Down

0 comments on commit 34ce19a

Please sign in to comment.