Skip to content

Commit a7c35d6

Browse files
committed
Update types for LDK 0.1 (and allow refs to [u8; 16]s)
1 parent c8524eb commit a7c35d6

File tree

1 file changed

+31
-29
lines changed

1 file changed

+31
-29
lines changed

c-bindings-gen/src/types.rs

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,15 +1147,15 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
11471147
if !is_ref => Some("crate::c_types::ThirtyTwoBytes"),
11481148
"bitcoin::secp256k1::Message" if !is_ref => Some("crate::c_types::ThirtyTwoBytes"),
11491149
"bitcoin::secp256k1::Message" if is_ref => Some("*const [u8; 32]"),
1150-
"lightning::ln::types::PaymentHash"|"lightning_types::payment::PaymentHash"
1151-
|"lightning::ln::types::PaymentPreimage"|"lightning_types::payment::PaymentPreimage"
1152-
|"lightning::ln::types::PaymentSecret"|"lightning_types::payment::PaymentSecret"
1150+
"lightning::types::payment::PaymentHash"|"lightning_types::payment::PaymentHash"
1151+
|"lightning::types::payment::PaymentPreimage"|"lightning_types::payment::PaymentPreimage"
1152+
|"lightning::types::payment::PaymentSecret"|"lightning_types::payment::PaymentSecret"
11531153
|"lightning::ln::channelmanager::PaymentId"|"lightning::ln::channelmanager::InterceptId"
11541154
|"lightning::sign::KeyMaterial"|"lightning::chain::ClaimId"
11551155
if is_ref => Some("*const [u8; 32]"),
1156-
"lightning::ln::types::PaymentHash"|"lightning_types::payment::PaymentHash"
1157-
|"lightning::ln::types::PaymentPreimage"|"lightning_types::payment::PaymentPreimage"
1158-
|"lightning::ln::types::PaymentSecret"|"lightning_types::payment::PaymentSecret"
1156+
"lightning::types::payment::PaymentHash"|"lightning_types::payment::PaymentHash"
1157+
|"lightning::types::payment::PaymentPreimage"|"lightning_types::payment::PaymentPreimage"
1158+
|"lightning::types::payment::PaymentSecret"|"lightning_types::payment::PaymentSecret"
11591159
|"lightning::ln::channelmanager::PaymentId"|"lightning::ln::channelmanager::InterceptId"
11601160
|"lightning::sign::KeyMaterial"|"lightning::chain::ClaimId"
11611161
if !is_ref => Some("crate::c_types::ThirtyTwoBytes"),
@@ -1270,11 +1270,11 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
12701270
"bitcoin::constants::ChainHash" => Some("::bitcoin::constants::ChainHash::from(&"),
12711271
"bitcoin::hashes::sha256::Hash" if is_ref => Some("&::bitcoin::hashes::sha256::Hash::from_slice(&unsafe { &*"),
12721272
"bitcoin::hashes::sha256::Hash" => Some("::bitcoin::hashes::sha256::Hash::from_slice(&"),
1273-
"lightning::ln::types::PaymentHash"|"lightning_types::payment::PaymentHash" if !is_ref => Some("::lightning::ln::types::PaymentHash("),
1274-
"lightning::ln::types::PaymentHash"|"lightning_types::payment::PaymentHash" if is_ref => Some("&::lightning::ln::types::PaymentHash(unsafe { *"),
1275-
"lightning::ln::types::PaymentPreimage"|"lightning_types::payment::PaymentPreimage" if !is_ref => Some("::lightning::ln::types::PaymentPreimage("),
1276-
"lightning::ln::types::PaymentPreimage"|"lightning_types::payment::PaymentPreimage" if is_ref => Some("&::lightning::ln::types::PaymentPreimage(unsafe { *"),
1277-
"lightning::ln::types::PaymentSecret"|"lightning_types::payment::PaymentSecret" if !is_ref => Some("::lightning::ln::types::PaymentSecret("),
1273+
"lightning::types::payment::PaymentHash"|"lightning_types::payment::PaymentHash" if !is_ref => Some("::lightning::types::payment::PaymentHash("),
1274+
"lightning::types::payment::PaymentHash"|"lightning_types::payment::PaymentHash" if is_ref => Some("&::lightning::types::payment::PaymentHash(unsafe { *"),
1275+
"lightning::types::payment::PaymentPreimage"|"lightning_types::payment::PaymentPreimage" if !is_ref => Some("::lightning::types::payment::PaymentPreimage("),
1276+
"lightning::types::payment::PaymentPreimage"|"lightning_types::payment::PaymentPreimage" if is_ref => Some("&::lightning::types::payment::PaymentPreimage(unsafe { *"),
1277+
"lightning::types::payment::PaymentSecret"|"lightning_types::payment::PaymentSecret" if !is_ref => Some("::lightning::types::payment::PaymentSecret("),
12781278
"lightning::ln::channelmanager::PaymentId" if !is_ref => Some("::lightning::ln::channelmanager::PaymentId("),
12791279
"lightning::ln::channelmanager::PaymentId" if is_ref=> Some("&::lightning::ln::channelmanager::PaymentId( unsafe { *"),
12801280
"lightning::ln::channelmanager::InterceptId" if !is_ref => Some("::lightning::ln::channelmanager::InterceptId("),
@@ -1381,15 +1381,15 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
13811381
"bitcoin::hash_types::BlockHash"|"bitcoin::BlockHash" if !is_ref => Some(".data[..]).unwrap()"),
13821382
"bitcoin::constants::ChainHash" if !is_ref => Some(".data)"),
13831383
"bitcoin::hashes::sha256::Hash" => Some(" }[..]).unwrap()"),
1384-
"lightning::ln::types::PaymentHash"|"lightning_types::payment::PaymentHash"
1385-
|"lightning::ln::types::PaymentPreimage"|"lightning_types::payment::PaymentPreimage"
1386-
|"lightning::ln::types::PaymentSecret"|"lightning_types::payment::PaymentSecret"
1384+
"lightning::types::payment::PaymentHash"|"lightning_types::payment::PaymentHash"
1385+
|"lightning::types::payment::PaymentPreimage"|"lightning_types::payment::PaymentPreimage"
1386+
|"lightning::types::payment::PaymentSecret"|"lightning_types::payment::PaymentSecret"
13871387
|"lightning::ln::channelmanager::PaymentId"|"lightning::ln::channelmanager::InterceptId"
13881388
|"lightning::sign::KeyMaterial"|"lightning::chain::ClaimId"
13891389
if !is_ref => Some(".data)"),
1390-
"lightning::ln::types::PaymentHash"|"lightning_types::payment::PaymentHash"
1391-
|"lightning::ln::types::PaymentPreimage"|"lightning_types::payment::PaymentPreimage"
1392-
|"lightning::ln::types::PaymentSecret"|"lightning_types::payment::PaymentSecret"
1390+
"lightning::types::payment::PaymentHash"|"lightning_types::payment::PaymentHash"
1391+
|"lightning::types::payment::PaymentPreimage"|"lightning_types::payment::PaymentPreimage"
1392+
|"lightning::types::payment::PaymentSecret"|"lightning_types::payment::PaymentSecret"
13931393
|"lightning::ln::channelmanager::PaymentId"|"lightning::ln::channelmanager::InterceptId"
13941394
|"lightning::sign::KeyMaterial"|"lightning::chain::ClaimId"
13951395
if is_ref => Some(" })"),
@@ -1429,6 +1429,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
14291429
"[u8; 32]" if is_ref => Some(""),
14301430
"[u8; 20]" if !is_ref => Some("crate::c_types::TwentyBytes { data: "),
14311431
"[u8; 16]" if !is_ref => Some("crate::c_types::SixteenBytes { data: "),
1432+
"[u8; 16]" if is_ref => Some(""),
14321433
"[u8; 12]" if !is_ref => Some("crate::c_types::TwelveBytes { data: "),
14331434
"[u8; 4]" if !is_ref => Some("crate::c_types::FourBytes { data: "),
14341435
"[u8; 3]" if !is_ref => Some("crate::c_types::ThreeBytes { data: "),
@@ -1511,15 +1512,15 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
15111512
if !is_ref => Some("crate::c_types::ThirtyTwoBytes { data: *"),
15121513
"bitcoin::secp256k1::Message" if !is_ref => Some("crate::c_types::ThirtyTwoBytes { data: "),
15131514
"bitcoin::secp256k1::Message" if is_ref => Some(""),
1514-
"lightning::ln::types::PaymentHash"|"lightning_types::payment::PaymentHash"
1515-
|"lightning::ln::types::PaymentPreimage"|"lightning_types::payment::PaymentPreimage"
1516-
|"lightning::ln::types::PaymentSecret"|"lightning_types::payment::PaymentSecret"
1515+
"lightning::types::payment::PaymentHash"|"lightning_types::payment::PaymentHash"
1516+
|"lightning::types::payment::PaymentPreimage"|"lightning_types::payment::PaymentPreimage"
1517+
|"lightning::types::payment::PaymentSecret"|"lightning_types::payment::PaymentSecret"
15171518
|"lightning::ln::channelmanager::PaymentId"|"lightning::ln::channelmanager::InterceptId"
15181519
|"lightning::sign::KeyMaterial"|"lightning::chain::ClaimId"
15191520
if is_ref => Some("&"),
1520-
"lightning::ln::types::PaymentHash"|"lightning_types::payment::PaymentHash"
1521-
|"lightning::ln::types::PaymentPreimage"|"lightning_types::payment::PaymentPreimage"
1522-
|"lightning::ln::types::PaymentSecret"|"lightning_types::payment::PaymentSecret"
1521+
"lightning::types::payment::PaymentHash"|"lightning_types::payment::PaymentHash"
1522+
|"lightning::types::payment::PaymentPreimage"|"lightning_types::payment::PaymentPreimage"
1523+
|"lightning::types::payment::PaymentSecret"|"lightning_types::payment::PaymentSecret"
15231524
|"lightning::ln::channelmanager::PaymentId"|"lightning::ln::channelmanager::InterceptId"
15241525
|"lightning::sign::KeyMaterial"|"lightning::chain::ClaimId"
15251526
if !is_ref => Some("crate::c_types::ThirtyTwoBytes { data: "),
@@ -1542,6 +1543,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
15421543
"[u8; 32]" if !is_ref => Some(" }"),
15431544
"[u8; 32]" if is_ref => Some(""),
15441545
"[u8; 20]" if !is_ref => Some(" }"),
1546+
"[u8; 16]" if is_ref => Some(""),
15451547
"[u8; 16]" if !is_ref => Some(" }"),
15461548
"[u8; 12]" if !is_ref => Some(" }"),
15471549
"[u8; 4]" if !is_ref => Some(" }"),
@@ -1620,15 +1622,15 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
16201622
if !is_ref => Some(".as_ref() }"),
16211623
"bitcoin::secp256k1::Message" if !is_ref => Some(".as_ref().clone() }"),
16221624
"bitcoin::secp256k1::Message" if is_ref => Some(".as_ref()"),
1623-
"lightning::ln::types::PaymentHash"|"lightning_types::payment::PaymentHash"
1624-
|"lightning::ln::types::PaymentPreimage"|"lightning_types::payment::PaymentPreimage"
1625-
|"lightning::ln::types::PaymentSecret"|"lightning_types::payment::PaymentSecret"
1625+
"lightning::types::payment::PaymentHash"|"lightning_types::payment::PaymentHash"
1626+
|"lightning::types::payment::PaymentPreimage"|"lightning_types::payment::PaymentPreimage"
1627+
|"lightning::types::payment::PaymentSecret"|"lightning_types::payment::PaymentSecret"
16261628
|"lightning::ln::channelmanager::PaymentId"|"lightning::ln::channelmanager::InterceptId"
16271629
|"lightning::sign::KeyMaterial"|"lightning::chain::ClaimId"
16281630
if is_ref => Some(".0"),
1629-
"lightning::ln::types::PaymentHash"|"lightning_types::payment::PaymentHash"
1630-
|"lightning::ln::types::PaymentPreimage"|"lightning_types::payment::PaymentPreimage"
1631-
|"lightning::ln::types::PaymentSecret"|"lightning_types::payment::PaymentSecret"
1631+
"lightning::types::payment::PaymentHash"|"lightning_types::payment::PaymentHash"
1632+
|"lightning::types::payment::PaymentPreimage"|"lightning_types::payment::PaymentPreimage"
1633+
|"lightning::types::payment::PaymentSecret"|"lightning_types::payment::PaymentSecret"
16321634
|"lightning::ln::channelmanager::PaymentId"|"lightning::ln::channelmanager::InterceptId"
16331635
|"lightning::sign::KeyMaterial"|"lightning::chain::ClaimId"
16341636
if !is_ref => Some(".0 }"),

0 commit comments

Comments
 (0)