11/// This contains low-level parsing of PSBT into a node structure suitable for display
22use crate :: address:: from_output_script_with_network;
33use crate :: bitcoin:: consensus:: Decodable ;
4- use crate :: bitcoin:: hashes:: Hash ;
54use crate :: bitcoin:: psbt:: Psbt ;
65use crate :: bitcoin:: { ScriptBuf , Transaction } ;
76use crate :: fixed_script_wallet:: bitgo_psbt:: {
@@ -13,6 +12,7 @@ use crate::zcash::transaction::{decode_zcash_transaction_parts, ZcashTransaction
1312
1413pub use super :: node:: { Node , Primitive } ;
1514
15+
1616fn 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