Skip to content

Commit 313fceb

Browse files
committed
Support new rust-bitcoin type mappings for various hashes
1 parent 420d87e commit 313fceb

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

c-bindings-gen/src/types.rs

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,7 +1010,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
10101010
"bitcoin::blockdata::transaction::OutPoint" => Some("crate::lightning::chain::transaction::OutPoint"),
10111011
"bitcoin::blockdata::transaction::Transaction"|"bitcoin::Transaction" => Some("crate::c_types::Transaction"),
10121012
"bitcoin::Witness" => Some("crate::c_types::Witness"),
1013-
"bitcoin::blockdata::transaction::TxOut" if !is_ref => Some("crate::c_types::TxOut"),
1013+
"bitcoin::TxOut"|"bitcoin::blockdata::transaction::TxOut" if !is_ref => Some("crate::c_types::TxOut"),
10141014
"bitcoin::network::constants::Network" => Some("crate::bitcoin::network::Network"),
10151015
"bitcoin::util::address::WitnessVersion" => Some("crate::c_types::WitnessVersion"),
10161016
"bitcoin::blockdata::block::BlockHeader" if is_ref => Some("*const [u8; 80]"),
@@ -1022,9 +1022,9 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
10221022
if is_ref => Some("*const [u8; 32]"),
10231023

10241024
// Newtypes that we just expose in their original form.
1025-
"bitcoin::hash_types::Txid"|"bitcoin::hash_types::BlockHash"|"bitcoin_hashes::sha256::Hash"
1025+
"bitcoin::hash_types::Txid"|"bitcoin::BlockHash"|"bitcoin::hash_types::BlockHash"|"bitcoin_hashes::sha256::Hash"|"bitcoin::blockdata::constants::ChainHash"
10261026
if is_ref => Some("*const [u8; 32]"),
1027-
"bitcoin::hash_types::Txid"|"bitcoin::hash_types::BlockHash"|"bitcoin_hashes::sha256::Hash"
1027+
"bitcoin::hash_types::Txid"|"bitcoin::BlockHash"|"bitcoin::hash_types::BlockHash"|"bitcoin_hashes::sha256::Hash"|"bitcoin::blockdata::constants::ChainHash"
10281028
if !is_ref => Some("crate::c_types::ThirtyTwoBytes"),
10291029
"bitcoin::secp256k1::Message" if !is_ref => Some("crate::c_types::ThirtyTwoBytes"),
10301030
"lightning::ln::PaymentHash"|"lightning::ln::PaymentPreimage"|"lightning::ln::PaymentSecret"
@@ -1105,7 +1105,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
11051105
"bitcoin::Witness" if is_ref => Some("&"),
11061106
"bitcoin::Witness" => Some(""),
11071107
"bitcoin::blockdata::transaction::OutPoint" => Some("crate::c_types::C_to_bitcoin_outpoint("),
1108-
"bitcoin::blockdata::transaction::TxOut" if !is_ref => Some(""),
1108+
"bitcoin::TxOut"|"bitcoin::blockdata::transaction::TxOut" if !is_ref => Some(""),
11091109
"bitcoin::network::constants::Network" => Some(""),
11101110
"bitcoin::util::address::WitnessVersion" => Some(""),
11111111
"bitcoin::blockdata::block::BlockHeader" => Some("&::bitcoin::consensus::encode::deserialize(unsafe { &*"),
@@ -1123,7 +1123,8 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
11231123
// Newtypes that we just expose in their original form.
11241124
"bitcoin::hash_types::Txid" if is_ref => Some("&::bitcoin::hash_types::Txid::from_slice(&unsafe { &*"),
11251125
"bitcoin::hash_types::Txid" if !is_ref => Some("::bitcoin::hash_types::Txid::from_slice(&"),
1126-
"bitcoin::hash_types::BlockHash" => Some("::bitcoin::hash_types::BlockHash::from_slice(&"),
1126+
"bitcoin::hash_types::BlockHash"|"bitcoin::BlockHash" => Some("::bitcoin::hash_types::BlockHash::from_slice(&"),
1127+
"bitcoin::blockdata::constants::ChainHash" => Some("::bitcoin::blockdata::constants::ChainHash::from_slice(&"),
11271128
"lightning::ln::PaymentHash" if !is_ref => Some("::lightning::ln::PaymentHash("),
11281129
"lightning::ln::PaymentHash" if is_ref => Some("&::lightning::ln::PaymentHash(unsafe { *"),
11291130
"lightning::ln::PaymentPreimage" if !is_ref => Some("::lightning::ln::PaymentPreimage("),
@@ -1196,7 +1197,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
11961197
"bitcoin::blockdata::transaction::Transaction"|"bitcoin::Transaction" => Some(".into_bitcoin()"),
11971198
"bitcoin::Witness" => Some(".into_bitcoin()"),
11981199
"bitcoin::blockdata::transaction::OutPoint" => Some(")"),
1199-
"bitcoin::blockdata::transaction::TxOut" if !is_ref => Some(".into_rust()"),
1200+
"bitcoin::TxOut"|"bitcoin::blockdata::transaction::TxOut" if !is_ref => Some(".into_rust()"),
12001201
"bitcoin::network::constants::Network" => Some(".into_bitcoin()"),
12011202
"bitcoin::util::address::WitnessVersion" => Some(".into()"),
12021203
"bitcoin::blockdata::block::BlockHeader" => Some(" }).unwrap()"),
@@ -1209,7 +1210,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
12091210
// Newtypes that we just expose in their original form.
12101211
"bitcoin::hash_types::Txid" if is_ref => Some(" }[..]).unwrap()"),
12111212
"bitcoin::hash_types::Txid" => Some(".data[..]).unwrap()"),
1212-
"bitcoin::hash_types::BlockHash" if !is_ref => Some(".data[..]).unwrap()"),
1213+
"bitcoin::hash_types::BlockHash"|"bitcoin::BlockHash"|"bitcoin::blockdata::constants::ChainHash" if !is_ref => Some(".data[..]).unwrap()"),
12131214
"lightning::ln::PaymentHash"|"lightning::ln::PaymentPreimage"|"lightning::ln::PaymentSecret"
12141215
|"lightning::ln::channelmanager::PaymentId"|"lightning::ln::channelmanager::InterceptId"
12151216
|"lightning::chain::keysinterface::KeyMaterial"
@@ -1299,7 +1300,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
12991300
"bitcoin::Witness" if is_ref => Some("crate::c_types::Witness::from_bitcoin("),
13001301
"bitcoin::Witness" if !is_ref => Some("crate::c_types::Witness::from_bitcoin(&"),
13011302
"bitcoin::blockdata::transaction::OutPoint" => Some("crate::c_types::bitcoin_to_C_outpoint("),
1302-
"bitcoin::blockdata::transaction::TxOut" if !is_ref => Some("crate::c_types::TxOut::from_rust("),
1303+
"bitcoin::TxOut"|"bitcoin::blockdata::transaction::TxOut" if !is_ref => Some("crate::c_types::TxOut::from_rust("),
13031304
"bitcoin::network::constants::Network" => Some("crate::bitcoin::network::Network::from_bitcoin("),
13041305
"bitcoin::util::address::WitnessVersion" => Some(""),
13051306
"bitcoin::blockdata::block::BlockHeader" if is_ref => Some("&local_"),
@@ -1308,9 +1309,9 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
13081309
"bitcoin::hash_types::Txid" if !is_ref => Some("crate::c_types::ThirtyTwoBytes { data: "),
13091310

13101311
// Newtypes that we just expose in their original form.
1311-
"bitcoin::hash_types::Txid"|"bitcoin::hash_types::BlockHash"|"bitcoin_hashes::sha256::Hash"
1312+
"bitcoin::hash_types::Txid"|"bitcoin::BlockHash"|"bitcoin::hash_types::BlockHash"|"bitcoin_hashes::sha256::Hash"|"bitcoin::blockdata::constants::ChainHash"
13121313
if is_ref => Some(""),
1313-
"bitcoin::hash_types::Txid"|"bitcoin::hash_types::BlockHash"|"bitcoin_hashes::sha256::Hash"
1314+
"bitcoin::hash_types::Txid"|"bitcoin::BlockHash"|"bitcoin::hash_types::BlockHash"|"bitcoin_hashes::sha256::Hash"|"bitcoin::blockdata::constants::ChainHash"
13141315
if !is_ref => Some("crate::c_types::ThirtyTwoBytes { data: "),
13151316
"bitcoin::secp256k1::Message" if !is_ref => Some("crate::c_types::ThirtyTwoBytes { data: "),
13161317
"lightning::ln::PaymentHash"|"lightning::ln::PaymentPreimage"|"lightning::ln::PaymentSecret"
@@ -1383,7 +1384,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
13831384
"bitcoin::blockdata::transaction::Transaction"|"bitcoin::Transaction" => Some(")"),
13841385
"bitcoin::Witness" => Some(")"),
13851386
"bitcoin::blockdata::transaction::OutPoint" => Some(")"),
1386-
"bitcoin::blockdata::transaction::TxOut" if !is_ref => Some(")"),
1387+
"bitcoin::TxOut"|"bitcoin::blockdata::transaction::TxOut" if !is_ref => Some(")"),
13871388
"bitcoin::network::constants::Network" => Some(")"),
13881389
"bitcoin::util::address::WitnessVersion" => Some(".into()"),
13891390
"bitcoin::blockdata::block::BlockHeader" if is_ref => Some(""),
@@ -1392,9 +1393,9 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
13921393
"bitcoin::hash_types::Txid" if !is_ref => Some(".into_inner() }"),
13931394

13941395
// Newtypes that we just expose in their original form.
1395-
"bitcoin::hash_types::Txid"|"bitcoin::hash_types::BlockHash"|"bitcoin_hashes::sha256::Hash"
1396+
"bitcoin::hash_types::Txid"|"bitcoin::BlockHash"|"bitcoin::hash_types::BlockHash"|"bitcoin_hashes::sha256::Hash"|"bitcoin::blockdata::constants::ChainHash"
13961397
if is_ref => Some(".as_inner()"),
1397-
"bitcoin::hash_types::Txid"|"bitcoin::hash_types::BlockHash"|"bitcoin_hashes::sha256::Hash"
1398+
"bitcoin::hash_types::Txid"|"bitcoin::BlockHash"|"bitcoin::hash_types::BlockHash"|"bitcoin_hashes::sha256::Hash"|"bitcoin::blockdata::constants::ChainHash"
13981399
if !is_ref => Some(".into_inner() }"),
13991400
"bitcoin::secp256k1::Message" if !is_ref => Some(".as_ref().clone() }"),
14001401
"lightning::ln::PaymentHash"|"lightning::ln::PaymentPreimage"|"lightning::ln::PaymentSecret"
@@ -1498,7 +1499,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
14981499
"lightning::ln::PaymentHash" => true,
14991500
"lightning::ln::PaymentPreimage" => true,
15001501
"lightning::ln::channelmanager::PaymentId" => true,
1501-
"bitcoin::hash_types::BlockHash" => true,
1502+
"bitcoin::hash_types::BlockHash"|"bitcoin::BlockHash" => true,
15021503
"secp256k1::PublicKey"|"bitcoin::secp256k1::PublicKey" => true,
15031504
_ => false,
15041505
}

0 commit comments

Comments
 (0)