Skip to content

Commit 654ae89

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 654ae89

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

  • packages/wasm-utxo/src/inspect

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

Lines changed: 8 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::{
@@ -250,7 +249,7 @@ fn tx_input_to_node(input: &crate::bitcoin::TxIn, index: usize) -> Node {
250249

251250
input_node.add_child(Node::new(
252251
"prev_txid",
253-
Primitive::Buffer(input.previous_output.txid.to_byte_array().to_vec()),
252+
Primitive::String(input.previous_output.txid.to_string()),
254253
));
255254
input_node.add_child(Node::new(
256255
"prev_vout",
@@ -325,7 +324,7 @@ fn psbt_input_to_node(input: &crate::bitcoin::psbt::Input, index: usize, network
325324
if let Some(utxo) = &input.non_witness_utxo {
326325
input_node.add_child(Node::new(
327326
"non_witness_utxo",
328-
Primitive::Buffer(utxo.compute_txid().to_byte_array().to_vec()),
327+
Primitive::String(utxo.compute_txid().to_string()),
329328
));
330329
}
331330

@@ -483,15 +482,15 @@ pub fn tx_to_node(tx: &Transaction, network: Network) -> Node {
483482
));
484483
tx_node.add_child(Node::new(
485484
"txid",
486-
Primitive::Buffer(tx.compute_txid().to_byte_array().to_vec()),
485+
Primitive::String(tx.compute_txid().to_string()),
487486
));
488487
tx_node.add_child(Node::new(
489488
"ntxid",
490-
Primitive::Buffer(tx.compute_ntxid().to_byte_array().to_vec()),
489+
Primitive::String(tx.compute_ntxid().to_string()),
491490
));
492491
tx_node.add_child(Node::new(
493492
"wtxid",
494-
Primitive::Buffer(tx.compute_wtxid().to_byte_array().to_vec()),
493+
Primitive::String(tx.compute_wtxid().to_string()),
495494
));
496495
tx_node.add_child(tx_inputs_to_node(&tx.input));
497496
tx_node.add_child(tx_outputs_to_node(&tx.output, network));
@@ -529,15 +528,15 @@ pub fn zcash_tx_to_node(parts: &ZcashTransactionParts, network: Network) -> Node
529528
));
530529
tx_node.add_child(Node::new(
531530
"txid",
532-
Primitive::Buffer(tx.compute_txid().to_byte_array().to_vec()),
531+
Primitive::String(tx.compute_txid().to_string()),
533532
));
534533
tx_node.add_child(Node::new(
535534
"ntxid",
536-
Primitive::Buffer(tx.compute_ntxid().to_byte_array().to_vec()),
535+
Primitive::String(tx.compute_ntxid().to_string()),
537536
));
538537
tx_node.add_child(Node::new(
539538
"wtxid",
540-
Primitive::Buffer(tx.compute_wtxid().to_byte_array().to_vec()),
539+
Primitive::String(tx.compute_wtxid().to_string()),
541540
));
542541
tx_node.add_child(tx_inputs_to_node(&tx.input));
543542
tx_node.add_child(tx_outputs_to_node(&tx.output, network));

0 commit comments

Comments
 (0)