Skip to content

Commit

Permalink
Merge pull request #2473 from get10101/feat/wrap-rust-dlc-messages-wi…
Browse files Browse the repository at this point in the history
…th-10101-messages

feat: Wrap dlc messages with 10101 messages
  • Loading branch information
holzeis authored Apr 28, 2024
2 parents 6d0ddc7 + 1ff6dcb commit 5306066
Show file tree
Hide file tree
Showing 15 changed files with 1,290 additions and 743 deletions.
8 changes: 4 additions & 4 deletions coordinator/src/dlc_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ use diesel::r2d2::Pool;
use diesel::PgConnection;
use dlc_manager::channel::signed_channel::SignedChannel;
use dlc_manager::channel::signed_channel::SignedChannelState;
use dlc_messages::Message;
use futures::future::RemoteHandle;
use futures::FutureExt;
use ln_dlc_node::bitcoin_conversion::to_secp_pk_29;
use ln_dlc_node::dlc_message::DlcMessage;
use ln_dlc_node::dlc_message::SerializedDlcMessage;
use ln_dlc_node::message_handler::TenTenOneMessage;
use ln_dlc_node::node::dlc_channel::send_dlc_message;
use ln_dlc_node::node::event::NodeEvent;
use ln_dlc_node::node::Node;
Expand Down Expand Up @@ -103,7 +103,7 @@ pub fn spawn_handling_outbound_dlc_messages(
}

impl DlcHandler {
pub fn send_dlc_message(&self, peer: PublicKey, msg: Message) -> Result<()> {
pub fn send_dlc_message(&self, peer: PublicKey, msg: TenTenOneMessage) -> Result<()> {
self.store_dlc_message(peer, msg.clone())?;

send_dlc_message(
Expand All @@ -116,7 +116,7 @@ impl DlcHandler {
Ok(())
}

pub fn store_dlc_message(&self, peer: PublicKey, msg: Message) -> Result<()> {
pub fn store_dlc_message(&self, peer: PublicKey, msg: TenTenOneMessage) -> Result<()> {
let mut conn = self.pool.get()?;

let serialized_outbound_message = SerializedDlcMessage::try_from(&msg)?;
Expand All @@ -132,7 +132,7 @@ impl DlcHandler {
let last_serialized_message = db::last_outbound_dlc_message::get(&mut conn, &peer)?;

if let Some(last_serialized_message) = last_serialized_message {
let message = Message::try_from(&last_serialized_message)?;
let message = TenTenOneMessage::try_from(&last_serialized_message)?;
send_dlc_message(
&self.node.dlc_message_handler,
&self.node.peer_manager,
Expand Down
16 changes: 9 additions & 7 deletions coordinator/src/emergency_kit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ use bitcoin::secp256k1::PublicKey;
use bitcoin_old::secp256k1::SecretKey;
use dlc_manager::Signer;
use dlc_messages::channel::RenewRevoke;
use dlc_messages::ChannelMessage;
use dlc_messages::Message;
use lightning::ln::chan_utils::build_commitment_secret;
use ln_dlc_node::message_handler::TenTenOneMessage;
use ln_dlc_node::message_handler::TenTenOneRenewRevoke;
use ln_dlc_node::node::event::NodeEvent;

impl Node {
Expand All @@ -25,11 +25,13 @@ impl Node {
signed_channel.update_idx + 1,
))?;

let msg = Message::Channel(ChannelMessage::RenewRevoke(RenewRevoke {
channel_id: signed_channel.channel_id,
per_update_secret: prev_per_update_secret,
reference_id: signed_channel.reference_id,
}));
let msg = TenTenOneMessage::RenewRevoke(TenTenOneRenewRevoke {
renew_revoke: RenewRevoke {
channel_id: signed_channel.channel_id,
per_update_secret: prev_per_update_secret,
reference_id: signed_channel.reference_id,
},
});

self.inner.event_handler.publish(NodeEvent::SendDlcMessage {
peer: trader,
Expand Down
Loading

0 comments on commit 5306066

Please sign in to comment.