Skip to content

Commit 090b965

Browse files
committed
update rgb deps + related fixes
1 parent 8f9059d commit 090b965

File tree

3 files changed

+29
-24
lines changed

3 files changed

+29
-24
lines changed

lightning-invoice/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ hashbrown = { version = "0.8", optional = true }
2929
bitcoin = { version = "0.29.0", default-features = false }
3030

3131
# RGB and related
32-
rgb-std = "=0.10.3"
32+
rgb-std = "=0.10.7"
3333

3434
[dev-dependencies]
3535
lightning = { version = "0.0.115", path = "../lightning", default-features = false, features = ["_test_utils"] }

lightning/Cargo.toml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,19 @@ backtrace = { version = "0.3", optional = true }
5151
core2 = { version = "0.3.0", optional = true, default-features = false }
5252

5353
# RGB and related
54-
amplify = "=4.0.0"
54+
amplify = "=4.0.1"
5555
base64 = "0.13.0"
56-
bp-core = { version = "=0.10.5", features = ["serde"] }
57-
bp-seals = "=0.10.5"
58-
commit_verify = "=0.10.4"
56+
bp-core = { version = "=0.10.9", features = ["serde"] }
57+
bp-seals = "=0.10.9"
58+
commit_verify = "=0.10.5"
5959
futures = "0.3"
6060
hex = { version = "0.4" }
6161
reqwest = { version = "0.11", default-features = false, features = ["json", "blocking"] }
62-
rgb-contracts = { version = "=0.10.0-rc.2", features = ["all", "electrum"] }
63-
rgb_core = { package = "rgb-core", version = "=0.10.5" }
64-
rgb-schemata = "=0.10.0-rc.1"
65-
rgb-std = { version = "=0.10.3", features = ["all"] }
66-
rgb-wallet = { version = "=0.10.3", features = ["all"] }
62+
rgb-contracts = { version = "=0.10.0-rc.5", features = ["all", "electrum"] }
63+
rgb_core = { package = "rgb-core", version = "=0.10.7" }
64+
rgb-schemata = "=0.10.0-rc.3"
65+
rgb-std = { version = "=0.10.7", features = ["all"] }
66+
rgb-wallet = { version = "=0.10.7", features = ["all"] }
6767
serde = { version = "^1.0", features = ["derive"] }
6868
serde_json = { version = "^1.0" }
6969
strict_encoding = "=2.5.0"

lightning/src/rgb_utils/mod.rs

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use bp::Outpoint as RgbOutpoint;
1919
use bp::Txid as BpTxid;
2020
use bp::seals::txout::CloseMethod;
2121
use commit_verify::mpc::MerkleBlock;
22-
use rgb::Runtime;
22+
use rgb::{BlockchainResolver, Runtime};
2323
use rgb_core::validation::Validity;
2424
use rgb_core::{Operation, Assign, Anchor, TransitionBundle};
2525
use seals::txout::TxPtr;
@@ -103,10 +103,15 @@ pub struct TransferInfo {
103103
pub vout: u32,
104104
}
105105

106+
/// Get a blockchain resolver
107+
pub fn get_resolver(ldk_data_dir: &Path) -> BlockchainResolver {
108+
let electrum_url = fs::read_to_string(ldk_data_dir.join("electrum_url")).expect("able to read");
109+
BlockchainResolver::with(&electrum_url).expect("able to get resolver")
110+
}
111+
106112
/// Get an instance of the RGB runtime
107113
pub fn get_rgb_runtime(ldk_data_dir: &Path) -> Runtime {
108114
let rgb_network_str = fs::read_to_string(ldk_data_dir.join("rgb_network")).expect("able to read");
109-
let electrum_url = fs::read_to_string(ldk_data_dir.join("electrum_url")).expect("able to read");
110115
let lock_file_path = ldk_data_dir.join(RGB_RUNTIME_LOCK_FILE);
111116
loop {
112117
match OpenOptions::new().write(true).create_new(true).open(lock_file_path.clone()) {
@@ -116,8 +121,7 @@ pub fn get_rgb_runtime(ldk_data_dir: &Path) -> Runtime {
116121
}
117122
Runtime::load(
118123
ldk_data_dir.to_path_buf(),
119-
Chain::from_str(&rgb_network_str).unwrap(),
120-
&electrum_url).expect("RGB runtime should be available")
124+
Chain::from_str(&rgb_network_str).unwrap()).expect("RGB runtime should be available")
121125
}
122126

123127
/// Drop the lock file for write access to the RGB runtime
@@ -164,9 +168,9 @@ pub(crate) fn color_commitment(channel_id: &[u8; 32], funding_outpoint: &OutPoin
164168

165169
let htlc_payment_hash = hex::encode(htlc.payment_hash.0);
166170
let htlc_proxy_id = format!("{chan_id}{htlc_payment_hash}");
167-
let rgb_payment_info_path = ldk_data_dir.clone().join(htlc_proxy_id);
171+
let rgb_payment_info_path = ldk_data_dir.join(htlc_proxy_id);
168172

169-
let rgb_payment_info_hash_path = ldk_data_dir.clone().join(htlc_payment_hash);
173+
let rgb_payment_info_hash_path = ldk_data_dir.join(htlc_payment_hash);
170174
if rgb_payment_info_hash_path.exists() {
171175
let mut rgb_payment_info = parse_rgb_payment_info(&rgb_payment_info_hash_path);
172176
rgb_payment_info.local_rgb_amount = rgb_info.local_rgb_amount;
@@ -277,7 +281,7 @@ pub(crate) fn color_commitment(channel_id: &[u8; 32], funding_outpoint: &OutPoin
277281
let modified_tx = psbt.extract_tx();
278282
let txid = modified_tx.txid();
279283
commitment_tx.built = BuiltCommitmentTransaction {
280-
transaction: modified_tx.clone(),
284+
transaction: modified_tx,
281285
txid,
282286
};
283287

@@ -460,7 +464,7 @@ pub(crate) fn color_closing(channel_id: &[u8; 32], funding_outpoint: &OutPoint,
460464
let psbt = PartiallySignedTransaction::from_str(&psbt.to_string()).unwrap();
461465
let modified_tx = psbt.extract_tx();
462466
let txid = modified_tx.txid();
463-
closing_tx.built = modified_tx.clone();
467+
closing_tx.built = modified_tx;
464468

465469
// save RGB transfer data to disk
466470
let transfer_info = TransferInfo {
@@ -548,18 +552,19 @@ pub(crate) fn handle_funding(temporary_channel_id: &[u8; 32], funding_txid: Stri
548552
let consignment = consignment_res.expect("successful get_consignment proxy call").result.expect("result");
549553
let consignment_bytes = base64::decode(consignment).expect("valid consignment");
550554
let consignment_path = ldk_data_dir.join(format!("consignment_{}", funding_txid));
551-
fs::write(consignment_path.clone(), consignment_bytes.clone()).expect("unable to write file");
555+
fs::write(consignment_path, consignment_bytes.clone()).expect("unable to write file");
552556
let consignment_path = ldk_data_dir.join(format!("consignment_{}", hex::encode(temporary_channel_id)));
553557
fs::write(consignment_path.clone(), consignment_bytes).expect("unable to write file");
554558
let consignment = Bindle::<RgbTransfer>::load(consignment_path).expect("successful consignment load");
555559
let transfer: RgbTransfer = consignment.clone().unbindle();
556560

557561
let mut runtime = get_rgb_runtime(ldk_data_dir);
562+
let mut resolver = get_resolver(ldk_data_dir);
558563

559564
let funding_seal = BlindSeal::with_blinding(CloseMethod::OpretFirst, TxPtr::WitnessTx, 0, STATIC_BLINDING);
560565
runtime.store_seal_secret(funding_seal).expect("valid seal");
561566

562-
let validated_transfer = match transfer.clone().validate(runtime.resolver()) {
567+
let validated_transfer = match transfer.clone().validate(&mut resolver) {
563568
Ok(consignment) => consignment,
564569
Err(consignment) => consignment,
565570
};
@@ -569,15 +574,15 @@ pub(crate) fn handle_funding(temporary_channel_id: &[u8; 32], funding_txid: Stri
569574
return Err(MsgHandleErrInternal::send_err_msg_no_close("Invalid RGB consignment for funding".to_owned(), *temporary_channel_id));
570575
}
571576

572-
let mut minimal_contract = transfer.clone().into_contract();
577+
let mut minimal_contract = transfer.into_contract();
573578
minimal_contract.bundles = none!();
574579
minimal_contract.terminals = none!();
575-
let minimal_contract_validated = match minimal_contract.clone().validate(runtime.resolver()) {
580+
let minimal_contract_validated = match minimal_contract.validate(&mut resolver) {
576581
Ok(consignment) => consignment,
577582
Err(consignment) => consignment,
578583
};
579584
runtime
580-
.import_contract(minimal_contract_validated)
585+
.import_contract(minimal_contract_validated, &mut resolver)
581586
.expect("failure importing issued contract");
582587

583588
let contract_id = consignment.contract_id();
@@ -602,7 +607,7 @@ pub(crate) fn handle_funding(temporary_channel_id: &[u8; 32], funding_txid: Stri
602607
}
603608
}
604609
};
605-
let _status = runtime.accept_transfer(validated_transfer.clone(), true).expect("valid transfer");
610+
let _status = runtime.accept_transfer(validated_transfer, &mut resolver, true).expect("valid transfer");
606611

607612
drop(runtime);
608613
drop_rgb_runtime(ldk_data_dir);

0 commit comments

Comments
 (0)