Skip to content

Commit 6742343

Browse files
committed
[bindings] Support converting Network to rust, update variants
1 parent b5d88a5 commit 6742343

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

c-bindings-gen/src/types.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -842,6 +842,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
842842
"bitcoin::blockdata::transaction::Transaction" => Some("crate::c_types::Transaction::from_vec(local_"),
843843
"bitcoin::blockdata::transaction::OutPoint" => Some("crate::c_types::bitcoin_to_C_outpoint("),
844844
"bitcoin::blockdata::transaction::TxOut" if !is_ref => Some("crate::c_types::TxOut::from_rust("),
845+
"bitcoin::network::constants::Network" => Some("crate::bitcoin::network::Network::from_bitcoin("),
845846
"bitcoin::blockdata::block::BlockHeader" if is_ref => Some("&local_"),
846847
"bitcoin::blockdata::block::Block" if is_ref => Some("crate::c_types::u8slice::from_slice(&local_"),
847848

@@ -899,6 +900,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
899900
"bitcoin::blockdata::transaction::Transaction" => Some(")"),
900901
"bitcoin::blockdata::transaction::OutPoint" => Some(")"),
901902
"bitcoin::blockdata::transaction::TxOut" if !is_ref => Some(")"),
903+
"bitcoin::network::constants::Network" => Some(")"),
902904
"bitcoin::blockdata::block::BlockHeader" if is_ref => Some(""),
903905
"bitcoin::blockdata::block::Block" if is_ref => Some(")"),
904906

lightning-c-bindings/src/bitcoin/network.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ pub enum Network {
55
Bitcoin,
66
Testnet,
77
Regtest,
8+
Signet,
89
}
910

1011
impl Network {
@@ -13,6 +14,15 @@ impl Network {
1314
Network::Bitcoin => BitcoinNetwork::Bitcoin,
1415
Network::Testnet => BitcoinNetwork::Testnet,
1516
Network::Regtest => BitcoinNetwork::Regtest,
17+
Network::Signet => BitcoinNetwork::Signet,
18+
}
19+
}
20+
pub(crate) fn from_bitcoin(net: BitcoinNetwork) -> Self {
21+
match net {
22+
BitcoinNetwork::Bitcoin => Network::Bitcoin,
23+
BitcoinNetwork::Testnet => Network::Testnet,
24+
BitcoinNetwork::Regtest => Network::Regtest,
25+
BitcoinNetwork::Signet => Network::Signet,
1626
}
1727
}
1828
}

0 commit comments

Comments
 (0)