Skip to content

Commit b22610a

Browse files
committed
feat: support external layer 1s
1 parent 2e01d87 commit b22610a

File tree

3 files changed

+210
-39
lines changed

3 files changed

+210
-39
lines changed

src/contract/anchor.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ impl XAnchor<mpc::MerkleBlock> {
7171
pub fn known_bundle_ids(&self) -> impl Iterator<Item = (BundleId, ContractId)> + '_ {
7272
match self {
7373
XAnchor::Bitcoin(anchor) | XAnchor::Liquid(anchor) => anchor.known_bundle_ids(),
74+
_ => unreachable!(),
7475
}
7576
}
7677

src/contract/seal.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ use commit_verify::{mpc, Conceal};
3535
use single_use_seals::SealWitness;
3636
use strict_encoding::{StrictDecode, StrictDumb, StrictEncode, StrictType};
3737

38+
use crate::contract::xchain::Impossible;
3839
use crate::{XChain, XOutpoint, LIB_NAME_RGB};
3940

4041
pub type GenesisSeal = SingleBlindSeal<Method>;
@@ -70,36 +71,42 @@ impl<Seal: TxoSeal> TxoSeal for XChain<Seal> {
7071
fn method(&self) -> CloseMethod {
7172
match self {
7273
XChain::Bitcoin(seal) | XChain::Liquid(seal) => seal.method(),
74+
XChain::Other(_) => unreachable!(),
7375
}
7476
}
7577

7678
fn txid(&self) -> Option<Txid> {
7779
match self {
7880
XChain::Bitcoin(seal) | XChain::Liquid(seal) => seal.txid(),
81+
XChain::Other(_) => unreachable!(),
7982
}
8083
}
8184

8285
fn vout(&self) -> Vout {
8386
match self {
8487
XChain::Bitcoin(seal) | XChain::Liquid(seal) => seal.vout(),
88+
XChain::Other(_) => unreachable!(),
8589
}
8690
}
8791

8892
fn outpoint(&self) -> Option<Outpoint> {
8993
match self {
9094
XChain::Bitcoin(seal) | XChain::Liquid(seal) => seal.outpoint(),
95+
XChain::Other(_) => unreachable!(),
9196
}
9297
}
9398

9499
fn txid_or(&self, default_txid: Txid) -> Txid {
95100
match self {
96101
XChain::Bitcoin(seal) | XChain::Liquid(seal) => seal.txid_or(default_txid),
102+
XChain::Other(_) => unreachable!(),
97103
}
98104
}
99105

100106
fn outpoint_or(&self, default_txid: Txid) -> Outpoint {
101107
match self {
102108
XChain::Bitcoin(seal) | XChain::Liquid(seal) => seal.outpoint_or(default_txid),
109+
XChain::Other(_) => unreachable!(),
103110
}
104111
}
105112
}
@@ -135,6 +142,7 @@ impl<U: ExposedSeal> XChain<U> {
135142
match self {
136143
XChain::Bitcoin(seal) => seal.method(),
137144
XChain::Liquid(seal) => seal.method(),
145+
XChain::Other(_) => unreachable!(),
138146
}
139147
}
140148

@@ -150,6 +158,7 @@ impl<U: ExposedSeal> XChain<U> {
150158
let outpoint = seal.outpoint()?;
151159
XChain::Liquid(ExplicitSeal::new(seal.method(), outpoint))
152160
}
161+
XChain::Other(_) => unreachable!(),
153162
})
154163
}
155164

@@ -228,7 +237,7 @@ impl WitnessOrd {
228237
}
229238
}
230239

231-
pub type XPubWitness = XChain<Tx>;
240+
pub type XPubWitness<X = Impossible> = XChain<Tx, X>;
232241

233242
pub type XWitness<Dbc> = XChain<Witness<Dbc>>;
234243

@@ -237,6 +246,7 @@ impl XPubWitness {
237246
match self {
238247
Self::Bitcoin(tx) => WitnessId::Bitcoin(tx.txid()),
239248
Self::Liquid(tx) => WitnessId::Liquid(tx.txid()),
249+
Self::Other(_) => unreachable!(),
240250
}
241251
}
242252
}
@@ -246,6 +256,7 @@ impl<Dbc: dbc::Proof> XWitness<Dbc> {
246256
match self {
247257
Self::Bitcoin(w) => WitnessId::Bitcoin(w.txid),
248258
Self::Liquid(w) => WitnessId::Liquid(w.txid),
259+
Self::Other(_) => unreachable!(),
249260
}
250261
}
251262
}
@@ -257,6 +268,7 @@ impl<Dbc: dbc::Proof, Seal: TxoSeal> SealWitness<Seal> for XWitness<Dbc> {
257268
fn verify_seal(&self, seal: &Seal, msg: &Self::Message) -> Result<(), Self::Error> {
258269
match self {
259270
Self::Bitcoin(witness) | Self::Liquid(witness) => witness.verify_seal(seal, msg),
271+
Self::Other(_) => unreachable!(),
260272
}
261273
}
262274

@@ -270,6 +282,7 @@ impl<Dbc: dbc::Proof, Seal: TxoSeal> SealWitness<Seal> for XWitness<Dbc> {
270282
{
271283
match self {
272284
Self::Bitcoin(witness) | Self::Liquid(witness) => witness.verify_many_seals(seals, msg),
285+
Self::Other(_) => unreachable!(),
273286
}
274287
}
275288
}

0 commit comments

Comments
 (0)