use super::inscriptions::Outpoint;
use crate::common::hash::Hash256;
use bellscoin::{hashes::Hash, Txid};

impl From<Outpoint> for bellscoin::OutPoint {
    fn from(v: Outpoint) -> Self {
        let txid = Txid::from_slice(&v.txid).unwrap();
        Self { txid, vout: v.vout }
    }
}

impl From<bellscoin::OutPoint> for Outpoint {
    fn from(v: bellscoin::OutPoint) -> Self {
        Self {
            txid: v.txid.to_byte_array(),
            vout: v.vout,
        }
    }
}

impl From<bellscoin::BlockHash> for Hash256 {
    fn from(value: bellscoin::BlockHash) -> Self {
        Hash256(*value.to_raw_hash().as_byte_array())
    }
}

impl From<Hash256> for bellscoin::BlockHash {
    fn from(value: Hash256) -> Self {
        bellscoin::BlockHash::from_byte_array(value.0)
    }
}
