From 34ce19a73948de3924dfe5b58030c6140f6eaf9b Mon Sep 17 00:00:00 2001 From: raph Date: Sat, 21 Sep 2024 06:25:59 +0200 Subject: [PATCH] Fix output API struct (#3957) --- src/api.rs | 8 ++++---- src/subcommand/list.rs | 4 ++-- src/subcommand/server.rs | 4 ++-- tests/json_api.rs | 11 ++++++++--- tests/wallet/send.rs | 4 ++-- 5 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/api.rs b/src/api.rs index 12587757ef..dc30628e75 100644 --- a/src/api.rs +++ b/src/api.rs @@ -156,9 +156,9 @@ pub struct Output { pub inscriptions: Vec, pub runes: BTreeMap, pub sat_ranges: Option>, - pub script_pubkey: String, + pub script_pubkey: ScriptBuf, pub spent: bool, - pub transaction: String, + pub transaction: Txid, pub value: u64, } @@ -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, } } diff --git a/src/subcommand/list.rs b/src/subcommand/list.rs index 3a522eb165..b790a621e8 100644 --- a/src/subcommand/list.rs +++ b/src/subcommand/list.rs @@ -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, }))) } diff --git a/src/subcommand/server.rs b/src/subcommand/server.rs index f9b7b46152..664e0f0830 100644 --- a/src/subcommand/server.rs +++ b/src/subcommand/server.rs @@ -3543,9 +3543,9 @@ mod tests { server.get_json::(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(), diff --git a/tests/json_api.rs b/tests/json_api.rs index ea754efb67..d5b9ff9720 100644 --- a/tests/json_api.rs +++ b/tests/json_api.rs @@ -1,6 +1,6 @@ use { super::*, - bitcoin::BlockHash, + bitcoin::{BlockHash, ScriptBuf}, ord::{Envelope, Inscription}, }; @@ -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::>() + .unwrap() + .assume_checked() + ), spent: false, - transaction: txid.to_string(), + transaction: txid, value: 3 * 50 * COIN_VALUE, } ); diff --git a/tests/wallet/send.rs b/tests/wallet/send.rs index 93eae82afb..49e1b228b9 100644 --- a/tests/wallet/send.rs +++ b/tests/wallet/send.rs @@ -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, } );