Hello everyone! I’m working on a Bitcoin integration, and I have a question about UTXO handling with iccdk
.
I understand that in a P2PKH (Pay-to-PubKey-Hash) script, the scriptPubKey
in a UTXO typically contains a pubkeyhash
specifying the address authorized to redeem the bitcoins. I’m fetching UTXOs for a specific address, and I expected to be able to retrieve the scriptPubKey
as part of the UTXO data. However, I’m not seeing this information in the response.
Here’s the code I’m using to fetch UTXOs:
pub async fn _get_utxos(network: BitcoinNetwork, address: String) -> GetUtxosResponse {
let filter = None;
let utxos_res = bitcoin_get_utxos(GetUtxosRequest {
address,
network,
filter,
})
.await;
utxos_res.unwrap().0
}
The UTXO structure, according to the docs, looks like this:
pub struct Utxo {
pub outpoint: Outpoint,
pub value: Satoshi,
pub height: u32,
}
As you can see, the Utxo
struct doesn’t seem to contain the scriptPubKey
. My goal is to query the UTXOs for a given address and check if any UTXO’s scriptPubKey
contains the pubkeyhash
corresponding to the address I’m watching. If it does, I’d like to emit an event.
How can I access the scriptPubKey
in this context, or is there another way to achieve this? Any advice would be appreciated!