"[u8]" if is_ref => Some(("crate::c_types::u8slice::from_slice(", ")")),
"[usize]" if is_ref => Some(("crate::c_types::usizeslice::from_slice(", ")")),
- "bitcoin::blockdata::transaction::Transaction" if is_ref => Some(("::bitcoin::consensus::encode::serialize(", ")")),
- "bitcoin::blockdata::transaction::Transaction" if !is_ref => Some(("::bitcoin::consensus::encode::serialize(&", ")")),
"bitcoin::blockdata::block::BlockHeader" if is_ref => Some(("{ let mut s = [0u8; 80]; s[..].copy_from_slice(&::bitcoin::consensus::encode::serialize(", ")); s }")),
"bitcoin::blockdata::block::Block" if is_ref => Some(("::bitcoin::consensus::encode::serialize(", ")")),
"bitcoin::hash_types::Txid" => None,
"bitcoin::secp256k1::Error" if !is_ref => Some("crate::c_types::Secp256k1Error::from_rust("),
"bitcoin::blockdata::script::Script" if is_ref => Some("crate::c_types::u8slice::from_slice(&"),
"bitcoin::blockdata::script::Script" if !is_ref => Some(""),
- "bitcoin::blockdata::transaction::Transaction" => Some("crate::c_types::Transaction::from_vec(local_"),
+ "bitcoin::blockdata::transaction::Transaction" if is_ref => Some("crate::c_types::Transaction::from_bitcoin("),
+ "bitcoin::blockdata::transaction::Transaction" => Some("crate::c_types::Transaction::from_bitcoin(&"),
"bitcoin::blockdata::transaction::OutPoint" => Some("crate::c_types::bitcoin_to_C_outpoint("),
"bitcoin::blockdata::transaction::TxOut" if !is_ref => Some("crate::c_types::TxOut::from_rust("),
"bitcoin::network::constants::Network" => Some("crate::bitcoin::network::Network::from_bitcoin("),
if self.datalen == 0 { panic!("0-length buffer can never represent a valid Transaction"); }
::bitcoin::consensus::encode::deserialize(unsafe { std::slice::from_raw_parts(self.data, self.datalen) }).unwrap()
}
- pub(crate) fn from_vec(v: Vec<u8>) -> Self {
- let datalen = v.len();
- let data = Box::into_raw(v.into_boxed_slice());
+ pub(crate) fn from_bitcoin(btc: &BitcoinTransaction) -> Self {
+ let vec = ::bitcoin::consensus::encode::serialize(btc);
+ let datalen = vec.len();
+ let data = Box::into_raw(vec.into_boxed_slice());
Self {
data: unsafe { (*data).as_mut_ptr() },
datalen,