Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 14 additions & 28 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,18 @@ serde = ["serde_crate", "serde_with", "serde_yaml", "bp-std/serde", "bp-wallet/s

[package.metadata.docs.rs]
features = ["all"]

[patch.crates-io]
strict_types = { git = "https://github.com/strict-types/strict-types", branch = "master" }
bp-consensus = { git = "https://github.com/BP-WG/bp-core", branch = "v0.11" }
bp-dbc = { git = "https://github.com/BP-WG/bp-core", branch = "v0.11" }
bp-seals = { git = "https://github.com/BP-WG/bp-core", branch = "v0.11" }
bp-core = { git = "https://github.com/BP-WG/bp-core", branch = "v0.11" }
bp-invoice = { git = "https://github.com/BP-WG/bp-std", branch = "v0.11" }
bp-std = { git = "https://github.com/BP-WG/bp-std", branch = "v0.11" }
psbt = { git = "https://github.com/BP-WG/bp-std", branch = "v0.11" }
descriptors = { git = "https://github.com/BP-WG/bp-std", branch = "v0.11" }
bp-wallet = { git = "https://github.com/BP-WG/bp-wallet", branch = "v0.11" }
rgb-core = { git = "https://github.com/RGB-WG/rgb-core", branch = "v0.11" }
rgb-std = { git = "https://github.com/RGB-WG/rgb-std", branch = "v0.11" }
rgb-invoice = { git = "https://github.com/RGB-WG/rgb-std", branch = "v0.11" }
17 changes: 13 additions & 4 deletions cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,7 @@ impl Exec for RgbArgs {
fs::create_dir_all(format!("{root_dir}/stash/ifaces"))?;
fs::create_dir_all(format!("{root_dir}/stash/geneses"))?;
fs::create_dir_all(format!("{root_dir}/stash/bundles"))?;
fs::create_dir_all(format!("{root_dir}/stash/witnesses"))?;
fs::create_dir_all(format!("{root_dir}/stash/anchors"))?;
fs::create_dir_all(format!("{root_dir}/stash/extensions"))?;
fs::create_dir_all(format!("{root_dir}/state"))?;
Expand Down Expand Up @@ -935,11 +936,15 @@ impl Exec for RgbArgs {
format!("{root_dir}/stash/bundles/{id}.yaml"),
serde_yaml::to_string(runtime.bundle(id)?)?,
)?;
fs::write(
format!("{root_dir}/stash/witnesses/{id}.yaml"),
serde_yaml::to_string(&runtime.bundled_witness(id)?.pub_witness)?,
)?;
}
for id in runtime.witness_ids()? {
fs::write(
format!("{root_dir}/stash/anchors/{id}.yaml"),
serde_yaml::to_string(runtime.anchor(id)?)?,
serde_yaml::to_string(&runtime.anchor(id)?)?,
)?;
}
for id in runtime.extension_ids()? {
Expand All @@ -961,11 +966,15 @@ impl Exec for RgbArgs {
// Index
fs::write(
format!("{root_dir}/index/op-to-bundle.yaml"),
serde_yaml::to_string(runtime.debug_bundle_op_index())?,
serde_yaml::to_string(runtime.debug_op_bundle_index())?,
)?;
fs::write(
format!("{root_dir}/index/bundle-to-contract.yaml"),
serde_yaml::to_string(runtime.debug_bundle_contract_index())?,
)?;
fs::write(
format!("{root_dir}/index/bundle-to-anchor.yaml"),
serde_yaml::to_string(runtime.debug_anchor_bundle_index())?,
format!("{root_dir}/index/bundle-to-witness.yaml"),
serde_yaml::to_string(runtime.debug_bundle_witness_index())?,
)?;
fs::write(
format!("{root_dir}/index/contracts.yaml"),
Expand Down
5 changes: 3 additions & 2 deletions psbt/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use bp::dbc::tapret::TapretProof;
pub use psbt::*;
pub use rgb::*;
use rgbstd::containers::{Batch, Fascia};
use rgbstd::{AnchorSet, XAnchor, XChain};
use rgbstd::{AnchorSet, XChain, XWitnessId};

pub use self::rgb::{
ProprietaryKeyRgb, RgbExt, RgbInExt, RgbOutExt, RgbPsbtError, PSBT_GLOBAL_RGB_TRANSITION,
Expand Down Expand Up @@ -106,7 +106,8 @@ impl RgbPsbt for Psbt {
let anchor = AnchorSet::from_split(tapret_anchor, opret_anchor)
.expect("at least one of DBC are present due to CloseMethodSet type guarantees");
Ok(Fascia {
anchor: XAnchor::Bitcoin(anchor),
witness_id: XWitnessId::Bitcoin(self.txid()),
anchor,
bundles,
})
}
Expand Down
16 changes: 2 additions & 14 deletions src/pay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
use std::collections::{BTreeMap, BTreeSet};
use std::convert::Infallible;

use amplify::confinement::Confined;
use bp::dbc::tapret::TapretProof;
use bp::seals::txout::{CloseMethod, ExplicitSeal};
use bp::{Outpoint, Sats, ScriptPubkey, Vout};
Expand All @@ -35,7 +34,7 @@ use rgbstd::invoice::{Amount, Beneficiary, InvoiceState, RgbInvoice};
use rgbstd::persistence::{
ComposeError, ConsignerError, Inventory, InventoryError, Stash, StashError,
};
use rgbstd::{WitnessId, XChain};
use rgbstd::XChain;

use crate::{
ContractOutpointsFilter, DescriptorRgb, RgbKeychain, Runtime, TapTweakAlreadyAssigned,
Expand Down Expand Up @@ -342,20 +341,9 @@ impl Runtime {
};

self.stock_mut().consume(fascia)?;
let mut transfer = self
let transfer = self
.stock()
.transfer(contract_id, beneficiary2, beneficiary1)?;
let mut terminals = transfer.terminals.to_inner();
for (bundle_id, terminal) in terminals.iter_mut() {
let Some(ab) = transfer.anchored_bundle(*bundle_id) else {
continue;
};
if ab.anchor.witness_id_unchecked() == WitnessId::Bitcoin(witness_txid) {
// TODO: Use unsigned tx
terminal.witness_tx = Some(XChain::Bitcoin(psbt.to_unsigned_tx().into()));
}
}
transfer.terminals = Confined::from_collection_unsafe(terminals);

Ok(transfer)
}
Expand Down
16 changes: 8 additions & 8 deletions src/resolvers/any.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
use rgbstd::containers::Consignment;
use rgbstd::resolvers::ResolveHeight;
use rgbstd::validation::{ResolveWitness, WitnessResolverError};
use rgbstd::{WitnessAnchor, WitnessId, XAnchor, XPubWitness};
use rgbstd::{WitnessAnchor, XWitnessId, XWitnessTx};

#[cfg(feature = "electrum")]
use crate::electrum;
Expand Down Expand Up @@ -73,31 +73,31 @@ impl AnyResolver {
pub fn add_terminals<const TYPE: bool>(&mut self, consignment: &Consignment<TYPE>) {
match self {
#[cfg(feature = "electrum")]
AnyResolver::Electrum(inner) => inner.add_terminals(consignment),
AnyResolver::Electrum(inner) => inner.add_witnesses(consignment),
#[cfg(feature = "esplora_blocking")]
AnyResolver::Esplora(inner) => inner.add_terminals(consignment),
AnyResolver::Esplora(inner) => inner.add_witnesses(consignment),
}
}
}

impl ResolveHeight for AnyResolver {
type Error = AnyAnchorResolverError;

fn resolve_anchor(&mut self, anchor: &XAnchor) -> Result<WitnessAnchor, Self::Error> {
fn resolve_height(&mut self, witness_id: XWitnessId) -> Result<WitnessAnchor, Self::Error> {
match self {
#[cfg(feature = "electrum")]
AnyResolver::Electrum(inner) => inner.resolve_anchor(anchor).map_err(|e| e.into()),
AnyResolver::Electrum(inner) => inner.resolve_height(witness_id).map_err(|e| e.into()),
#[cfg(feature = "esplora_blocking")]
AnyResolver::Esplora(inner) => inner.resolve_anchor(anchor).map_err(|e| e.into()),
AnyResolver::Esplora(inner) => inner.resolve_height(witness_id).map_err(|e| e.into()),
}
}
}

impl ResolveWitness for AnyResolver {
fn resolve_pub_witness(
&self,
witness_id: WitnessId,
) -> Result<XPubWitness, WitnessResolverError> {
witness_id: XWitnessId,
) -> Result<XWitnessTx, WitnessResolverError> {
match self {
#[cfg(feature = "electrum")]
AnyResolver::Electrum(inner) => inner.resolve_pub_witness(witness_id),
Expand Down
Loading