Skip to content

Commit

Permalink
introduce offchain priorities
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Jul 27, 2024
1 parent f0316a6 commit f91841b
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 13 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

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

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ descriptors = { git = "https://github.com/BP-WG/bp-std", branch = "master" }
psbt = { git = "https://github.com/BP-WG/bp-std", branch = "master" }
bp-std = { git = "https://github.com/BP-WG/bp-std", branch = "master" }
bp-wallet = { git = "https://github.com/BP-WG/bp-wallet", branch = "master" }
rgb-core = { git = "https://github.com/RGB-WG/rgb-core", branch = "master" }
rgb-invoice = { git = "https://github.com/RGB-WG/rgb-std", branch = "txid" }
rgb-std = { git = "https://github.com/RGB-WG/rgb-std", branch = "txid" }
rgb-core = { git = "https://github.com/RGB-WG/rgb-core", branch = "mining" }
rgb-invoice = { git = "https://github.com/RGB-WG/rgb-std", branch = "mining" }
rgb-std = { git = "https://github.com/RGB-WG/rgb-std", branch = "mining" }
rgb-interfaces = { git = "https://github.com/RGB-WG/rgb-interfaces.git", branch = "master" }
4 changes: 2 additions & 2 deletions src/indexers/any.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ impl AnyResolver {
consignment
.bundles
.iter()
.filter_map(|bw| bw.pub_witness.maybe_map_ref(|w| w.tx().cloned()))
.filter_map(|bw| bw.pub_witness.maybe_map_ref(|w| w.tx.clone()))
.filter_map(|tx| match tx {
XChain::Bitcoin(tx) => Some(tx),
XChain::Liquid(_) | XChain::Other(_) => None,
Expand All @@ -114,7 +114,7 @@ impl ResolveHeight for AnyResolver {

if self.terminal_txes.contains_key(&txid) {
return Ok(WitnessAnchor {
witness_ord: WitnessOrd::OffChain,
witness_ord: WitnessOrd::offchain(0),
witness_id,
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/indexers/electrum_blocking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ impl RgbResolver for Client {

fn resolve_height(&mut self, txid: Txid) -> Result<WitnessAnchor, String> {
let mut witness_anchor = WitnessAnchor {
witness_ord: WitnessOrd::OffChain,
witness_ord: WitnessOrd::offchain(1),
witness_id: XWitnessId::Bitcoin(txid),
};

Expand Down
2 changes: 1 addition & 1 deletion src/indexers/esplora_blocking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl RgbResolver for BlockingClient {
Some((h, t)) => {
WitnessOrd::OnChain(WitnessPos::new(h, t as i64).ok_or(Error::InvalidServerData)?)
}
None => WitnessOrd::OffChain,
None => WitnessOrd::offchain(1),
};
Ok(WitnessAnchor {
witness_ord: ord,
Expand Down
7 changes: 5 additions & 2 deletions src/pay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ where Self::Descr: DescriptorRgb<K>
) -> Result<(Psbt, PsbtMeta, Transfer), PayError> {
let (mut psbt, meta) = self.construct_psbt_rgb(stock, invoice, params)?;
// ... here we pass PSBT around signers, if necessary
let transfer = self.transfer(stock, invoice, &mut psbt)?;
let transfer = self.transfer(stock, invoice, &mut psbt, 2)?;
Ok((psbt, meta, transfer))
}

Expand Down Expand Up @@ -278,6 +278,7 @@ where Self::Descr: DescriptorRgb<K>
stock: &mut Stock<S, H, P>,
invoice: &RgbInvoice,
psbt: &mut Psbt,
priority: u32,
) -> Result<Transfer, CompletionError> {
let contract_id = invoice.contract.ok_or(CompletionError::NoContract)?;

Expand Down Expand Up @@ -311,7 +312,9 @@ where Self::Descr: DescriptorRgb<K>
Beneficiary::BlindedSeal(seal) => (vec![XChain::Bitcoin(seal)], vec![]),
};

stock.consume_fascia(fascia).map_err(|e| e.to_string())?;
stock
.consume_fascia(fascia, priority)
.map_err(|e| e.to_string())?;
let transfer = stock
.transfer(contract_id, beneficiary2, beneficiary1)
.map_err(|e| e.to_string())?;
Expand Down
2 changes: 1 addition & 1 deletion src/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,6 @@ where W::Descr: DescriptorRgb<K>
invoice: &RgbInvoice,
psbt: &mut Psbt,
) -> Result<Transfer, CompletionError> {
self.wallet.transfer(&mut self.stock, invoice, psbt)
self.wallet.transfer(&mut self.stock, invoice, psbt, 2)
}
}

0 comments on commit f91841b

Please sign in to comment.