@@ -256,21 +256,21 @@ impl ChainWatchInterface for FFIChainWatchInterface {
256256 ( self . watch_all_txn_ptr ) ( )
257257 }
258258 fn get_chain_utxo ( & self , genesis_hash : BlockHash , unspent_tx_output_identifier : u64 ) -> Result < ( Script , u64 ) , ChainError > {
259- let err = std:: ptr:: null_mut ( ) ;
259+ println ! ( "Querying chain utxo by shortChannelId {}. " , unspent_tx_output_identifier) ;
260+ let mut err = & mut FFIChainError :: UnInitialized ;
260261 // the length can be anything as long as it is enough to put the scriptPubKey.
261262 // probably this is a bit overkill but who cares.
262263 let mut script = [ 0u8 ; 128 ] ;
263- let script_len = std :: ptr :: null_mut ( ) ;
264- let amount_satoshis = std :: ptr :: null_mut ( ) ;
265- ( self . get_chain_utxo_ptr ) ( & genesis_hash. into ( ) , unspent_tx_output_identifier, err, script. as_mut_ptr ( ) , script_len, amount_satoshis) ;
266- if err. is_null ( ) {
264+ let mut script_len = & mut usize :: MAX ;
265+ let mut amount_satoshis = & mut u64 :: MAX ;
266+ ( self . get_chain_utxo_ptr ) ( & genesis_hash. into ( ) , unspent_tx_output_identifier, err as * mut FFIChainError , script. as_mut_ptr ( ) , script_len as * mut _ , amount_satoshis as * mut _ ) ;
267+ if * err == FFIChainError :: UnInitialized {
267268 let script_bytes: & [ u8 ] = unsafe_block ! ( "We know the caller has set the value into the script_ptr, script_len" => & script[ ..( * script_len) ] ) ;
268269 let amount: u64 = unsafe_block ! ( "We know the caller has set the value into the amount_satoshis" => * amount_satoshis) ;
269270 let s = bitcoin:: consensus:: deserialize ( script_bytes) . expect ( "Failed to parse scriptpubkey" ) ;
270271 Ok ( ( s, amount) )
271272 } else {
272- let e = unsafe_block ! ( "we know the error is not a null pointer" => ( * err) . clone( ) ) ;
273- Err ( e. into ( ) )
273+ Err ( err. clone ( ) . into ( ) )
274274 }
275275 }
276276
0 commit comments