Skip to content

Commit

Permalink
feat(state): BOSD Descriptor instead of X-only PK
Browse files Browse the repository at this point in the history
  • Loading branch information
storopoli committed Jan 13, 2025
1 parent 9e30b91 commit 35180d0
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 24 deletions.
2 changes: 1 addition & 1 deletion crates/chaintsn/src/transition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ fn process_deposit_updates(
let intent = &ready_withdrawals[next_intent_to_assign];
let op_idx = ops_seq[next_intent_to_assign % ops_seq.len()];

let outp = WithdrawOutput::new(*intent.dest_pk(), *intent.amt());
let outp = WithdrawOutput::new(intent.destination().clone(), *intent.amt());
let cmd = DispatchCommand::new(vec![outp]);
state.assign_withdrawal_command(
deposit_idx,
Expand Down
8 changes: 4 additions & 4 deletions crates/eectl/src/messages.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use strata_primitives::prelude::*;
use strata_primitives::{bitcoin_bosd::Descriptor, prelude::*};
use strata_state::{
block::L2BlockBundle,
exec_update::{ExecUpdate, Op},
Expand Down Expand Up @@ -64,11 +64,11 @@ impl ExecPayloadData {
/// L1 withdrawal data.
#[derive(Clone, Debug)]
pub struct WithdrawData {
/// Amount in L1 native asset. For Bitcoin this is sats.
/// Amount in L1 native asset. For Bitcoin this is sats.
_amt: u64,

/// Schnorr pubkey for the taproot output we're going to generate.
_dest_addr: Buf64,
/// BOSD [`Descriptor`] as withdrawal destination.
_destination: Descriptor,
}

/// Environment state from the CL that we pass into the EL for the payload we're
Expand Down
21 changes: 9 additions & 12 deletions crates/state/src/bridge_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
use borsh::{BorshDeserialize, BorshSerialize};
use serde::{Deserialize, Serialize};
use strata_primitives::{
buf::Buf32,
l1::{BitcoinAmount, XOnlyPk},
};
use strata_primitives::{bitcoin_bosd::Descriptor, l1::BitcoinAmount};

// TODO make this not hardcoded!
pub const WITHDRAWAL_DENOMINATION: BitcoinAmount = BitcoinAmount::from_int_btc(10);
Expand All @@ -16,25 +13,25 @@ pub struct WithdrawalIntent {
/// Quantity of L1 asset, for Bitcoin this is sats.
amt: BitcoinAmount,

/// Destination public key for the withdrawal
pub dest_pk: XOnlyPk,
/// Destination [`Descriptor`] for the withdrawal
pub destination: Descriptor,
}

impl WithdrawalIntent {
pub fn new(amt: BitcoinAmount, dest_pk: XOnlyPk) -> Self {
Self { amt, dest_pk }
pub fn new(amt: BitcoinAmount, destination: Descriptor) -> Self {
Self { amt, destination }
}

pub fn as_parts(&self) -> (u64, &Buf32) {
(self.amt.to_sat(), self.dest_pk.inner())
pub fn as_parts(&self) -> (u64, &Descriptor) {
(self.amt.to_sat(), &self.destination)
}

pub fn amt(&self) -> &BitcoinAmount {
&self.amt
}

pub fn dest_pk(&self) -> &XOnlyPk {
&self.dest_pk
pub fn destination(&self) -> &Descriptor {
&self.destination
}
}

Expand Down
15 changes: 8 additions & 7 deletions crates/state/src/bridge_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
use borsh::{BorshDeserialize, BorshSerialize};
use serde::{Deserialize, Serialize};
use strata_primitives::{
bitcoin_bosd::Descriptor,
bridge::{BitcoinBlockHeight, OperatorIdx},
buf::Buf32,
l1::{self, BitcoinAmount, OutputRef, XOnlyPk},
l1::{self, BitcoinAmount, OutputRef},
operator::{OperatorKeyProvider, OperatorPubkeys},
};

Expand Down Expand Up @@ -469,19 +470,19 @@ impl DispatchCommand {
#[derive(Clone, Debug, Eq, PartialEq, BorshDeserialize, BorshSerialize, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub struct WithdrawOutput {
/// Taproot Schnorr XOnlyPubkey with the merkle root information.
dest_addr: XOnlyPk,
/// BOSD [`Descriptor`].
destination: Descriptor,

/// Amount in sats.
amt: BitcoinAmount,
}

impl WithdrawOutput {
pub fn new(dest_addr: XOnlyPk, amt: BitcoinAmount) -> Self {
Self { dest_addr, amt }
pub fn new(destination: Descriptor, amt: BitcoinAmount) -> Self {
Self { destination, amt }
}

pub fn dest_addr(&self) -> &XOnlyPk {
&self.dest_addr
pub fn destination(&self) -> &Descriptor {
&self.destination
}
}

0 comments on commit 35180d0

Please sign in to comment.