Skip to content

Commit cdacf4f

Browse files
OttoAllmendingerllm-git
andcommitted
fix(wasm-utxo): display txid as string instead of reversed bytes
Change txid representation from buffer to string format in PSBT inspection. Previously, txids were displayed as byte arrays in reverse order. Affects txid, ntxid, wtxid, prev_txid, and non_witness_utxo fields. Issue: BTC-0 Co-authored-by: llm-git <llm-git@ttll.de>
1 parent 397599a commit cdacf4f

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

  • packages/wasm-utxo/src/inspect

packages/wasm-utxo/src/inspect/psbt.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/// This contains low-level parsing of PSBT into a node structure suitable for display
22
use crate::address::from_output_script_with_network;
33
use crate::bitcoin::consensus::Decodable;
4-
use crate::bitcoin::hashes::Hash;
54
use crate::bitcoin::psbt::Psbt;
65
use crate::bitcoin::{ScriptBuf, Transaction};
76
use crate::fixed_script_wallet::bitgo_psbt::{
@@ -13,6 +12,7 @@ use crate::zcash::transaction::{decode_zcash_transaction_parts, ZcashTransaction
1312

1413
pub use super::node::{Node, Primitive};
1514

15+
1616
fn script_buf_to_node(label: &str, script_buf: &ScriptBuf) -> Node {
1717
let mut node = Node::new(label, Primitive::Buffer(script_buf.to_bytes()));
1818
node.add_child(Node::new(
@@ -250,7 +250,7 @@ fn tx_input_to_node(input: &crate::bitcoin::TxIn, index: usize) -> Node {
250250

251251
input_node.add_child(Node::new(
252252
"prev_txid",
253-
Primitive::Buffer(input.previous_output.txid.to_byte_array().to_vec()),
253+
Primitive::String(input.previous_output.txid.to_string()),
254254
));
255255
input_node.add_child(Node::new(
256256
"prev_vout",
@@ -325,7 +325,7 @@ fn psbt_input_to_node(input: &crate::bitcoin::psbt::Input, index: usize, network
325325
if let Some(utxo) = &input.non_witness_utxo {
326326
input_node.add_child(Node::new(
327327
"non_witness_utxo",
328-
Primitive::Buffer(utxo.compute_txid().to_byte_array().to_vec()),
328+
Primitive::String(utxo.compute_txid().to_string()),
329329
));
330330
}
331331

@@ -483,15 +483,15 @@ pub fn tx_to_node(tx: &Transaction, network: Network) -> Node {
483483
));
484484
tx_node.add_child(Node::new(
485485
"txid",
486-
Primitive::Buffer(tx.compute_txid().to_byte_array().to_vec()),
486+
Primitive::String(tx.compute_txid().to_string()),
487487
));
488488
tx_node.add_child(Node::new(
489489
"ntxid",
490-
Primitive::Buffer(tx.compute_ntxid().to_byte_array().to_vec()),
490+
Primitive::String(tx.compute_ntxid().to_string()),
491491
));
492492
tx_node.add_child(Node::new(
493493
"wtxid",
494-
Primitive::Buffer(tx.compute_wtxid().to_byte_array().to_vec()),
494+
Primitive::String(tx.compute_wtxid().to_string()),
495495
));
496496
tx_node.add_child(tx_inputs_to_node(&tx.input));
497497
tx_node.add_child(tx_outputs_to_node(&tx.output, network));
@@ -529,15 +529,15 @@ pub fn zcash_tx_to_node(parts: &ZcashTransactionParts, network: Network) -> Node
529529
));
530530
tx_node.add_child(Node::new(
531531
"txid",
532-
Primitive::Buffer(tx.compute_txid().to_byte_array().to_vec()),
532+
Primitive::String(tx.compute_txid().to_string()),
533533
));
534534
tx_node.add_child(Node::new(
535535
"ntxid",
536-
Primitive::Buffer(tx.compute_ntxid().to_byte_array().to_vec()),
536+
Primitive::String(tx.compute_ntxid().to_string()),
537537
));
538538
tx_node.add_child(Node::new(
539539
"wtxid",
540-
Primitive::Buffer(tx.compute_wtxid().to_byte_array().to_vec()),
540+
Primitive::String(tx.compute_wtxid().to_string()),
541541
));
542542
tx_node.add_child(tx_inputs_to_node(&tx.input));
543543
tx_node.add_child(tx_outputs_to_node(&tx.output, network));

0 commit comments

Comments
 (0)