11/// This contains low-level parsing of PSBT into a node structure suitable for display
2- use bitcoin:: consensus:: Decodable ;
3- use bitcoin:: hashes:: Hash ;
4- use bitcoin:: psbt:: Psbt ;
5- use bitcoin:: { Network , ScriptBuf , Transaction } ;
2+ use wasm_utxo :: bitcoin:: consensus:: Decodable ;
3+ use wasm_utxo :: bitcoin:: hashes:: Hash ;
4+ use wasm_utxo :: bitcoin:: psbt:: Psbt ;
5+ use wasm_utxo :: bitcoin:: { Network , ScriptBuf , Transaction } ;
66use wasm_utxo:: fixed_script_wallet:: bitgo_psbt:: {
77 p2tr_musig2_input:: { Musig2PartialSig , Musig2Participants , Musig2PubNonce } ,
88 BitGoKeyValue , ProprietaryKeySubtype , BITGO ,
@@ -21,8 +21,11 @@ fn script_buf_to_node(label: &str, script_buf: &ScriptBuf) -> Node {
2121
2222fn bip32_derivations_to_nodes (
2323 bip32_derivation : & std:: collections:: BTreeMap <
24- bitcoin:: secp256k1:: PublicKey ,
25- ( bitcoin:: bip32:: Fingerprint , bitcoin:: bip32:: DerivationPath ) ,
24+ wasm_utxo:: bitcoin:: secp256k1:: PublicKey ,
25+ (
26+ wasm_utxo:: bitcoin:: bip32:: Fingerprint ,
27+ wasm_utxo:: bitcoin:: bip32:: DerivationPath ,
28+ ) ,
2629 > ,
2730) -> Vec < Node > {
2831 bip32_derivation
@@ -100,7 +103,10 @@ fn musig2_partial_sig_to_node(sig: &Musig2PartialSig) -> Node {
100103 node
101104}
102105
103- fn bitgo_proprietary_to_node ( prop_key : & bitcoin:: psbt:: raw:: ProprietaryKey , v : & [ u8 ] ) -> Node {
106+ fn bitgo_proprietary_to_node (
107+ prop_key : & wasm_utxo:: bitcoin:: psbt:: raw:: ProprietaryKey ,
108+ v : & [ u8 ] ,
109+ ) -> Node {
104110 // Try to parse as BitGo key-value
105111 let v_vec = v. to_vec ( ) ;
106112 let bitgo_kv_result = BitGoKeyValue :: from_key_value ( prop_key, & v_vec) ;
@@ -159,7 +165,7 @@ fn bitgo_proprietary_to_node(prop_key: &bitcoin::psbt::raw::ProprietaryKey, v: &
159165
160166fn raw_proprietary_to_node (
161167 label : & str ,
162- prop_key : & bitcoin:: psbt:: raw:: ProprietaryKey ,
168+ prop_key : & wasm_utxo :: bitcoin:: psbt:: raw:: ProprietaryKey ,
163169 v : & [ u8 ] ,
164170) -> Node {
165171 let mut prop_node = Node :: new ( label, Primitive :: None ) ;
@@ -177,7 +183,10 @@ fn raw_proprietary_to_node(
177183}
178184
179185fn proprietary_to_nodes (
180- proprietary : & std:: collections:: BTreeMap < bitcoin:: psbt:: raw:: ProprietaryKey , Vec < u8 > > ,
186+ proprietary : & std:: collections:: BTreeMap <
187+ wasm_utxo:: bitcoin:: psbt:: raw:: ProprietaryKey ,
188+ Vec < u8 > ,
189+ > ,
181190) -> Vec < Node > {
182191 proprietary
183192 . iter ( )
@@ -194,8 +203,11 @@ fn proprietary_to_nodes(
194203
195204fn xpubs_to_nodes (
196205 xpubs : & std:: collections:: BTreeMap <
197- bitcoin:: bip32:: Xpub ,
198- ( bitcoin:: bip32:: Fingerprint , bitcoin:: bip32:: DerivationPath ) ,
206+ wasm_utxo:: bitcoin:: bip32:: Xpub ,
207+ (
208+ wasm_utxo:: bitcoin:: bip32:: Fingerprint ,
209+ wasm_utxo:: bitcoin:: bip32:: DerivationPath ,
210+ ) ,
199211 > ,
200212) -> Vec < Node > {
201213 xpubs
@@ -215,8 +227,11 @@ fn xpubs_to_nodes(
215227
216228pub fn xpubs_to_node (
217229 xpubs : & std:: collections:: BTreeMap <
218- bitcoin:: bip32:: Xpub ,
219- ( bitcoin:: bip32:: Fingerprint , bitcoin:: bip32:: DerivationPath ) ,
230+ wasm_utxo:: bitcoin:: bip32:: Xpub ,
231+ (
232+ wasm_utxo:: bitcoin:: bip32:: Fingerprint ,
233+ wasm_utxo:: bitcoin:: bip32:: DerivationPath ,
234+ ) ,
220235 > ,
221236) -> Node {
222237 let mut xpubs_node = Node :: new ( "xpubs" , Primitive :: U64 ( xpubs. len ( ) as u64 ) ) ;
@@ -267,7 +282,7 @@ pub fn psbt_to_node(psbt: &Psbt, network: Network) -> Node {
267282 witness_node. add_child ( Node :: new (
268283 "address" ,
269284 Primitive :: String (
270- bitcoin:: Address :: from_script ( & witness_utxo. script_pubkey , network)
285+ wasm_utxo :: bitcoin:: Address :: from_script ( & witness_utxo. script_pubkey , network)
271286 . map ( |a| a. to_string ( ) )
272287 . unwrap_or_else ( |_| "<invalid address>" . to_string ( ) ) ,
273288 ) ,
@@ -353,7 +368,7 @@ pub fn psbt_to_node(psbt: &Psbt, network: Network) -> Node {
353368 psbt_node
354369}
355370
356- pub fn tx_to_node ( tx : & Transaction , network : bitcoin:: Network ) -> Node {
371+ pub fn tx_to_node ( tx : & Transaction , network : wasm_utxo :: bitcoin:: Network ) -> Node {
357372 let mut tx_node = Node :: new ( "tx" , Primitive :: None ) ;
358373
359374 tx_node. add_child ( Node :: new ( "version" , Primitive :: I32 ( tx. version . 0 ) ) ) ;
@@ -425,7 +440,9 @@ pub fn tx_to_node(tx: &Transaction, network: bitcoin::Network) -> Node {
425440 Primitive :: Buffer ( output. script_pubkey . as_bytes ( ) . to_vec ( ) ) ,
426441 ) ) ;
427442
428- if let Ok ( address) = bitcoin:: Address :: from_script ( & output. script_pubkey , network) {
443+ if let Ok ( address) =
444+ wasm_utxo:: bitcoin:: Address :: from_script ( & output. script_pubkey , network)
445+ {
429446 output_node. add_child ( Node :: new ( "address" , Primitive :: String ( address. to_string ( ) ) ) ) ;
430447 }
431448
0 commit comments