diff --git a/rgb-cln/src/plugin.rs b/rgb-cln/src/plugin.rs index c1fd6c1..d588c8a 100644 --- a/rgb-cln/src/plugin.rs +++ b/rgb-cln/src/plugin.rs @@ -82,6 +82,7 @@ pub fn build_plugin() -> anyhow::Result> { notification: [ ], methods: [ rgb_balance, + rgb_fundchannel, ], hooks: [], }; @@ -96,6 +97,11 @@ pub fn rgb_balance(plugin: &mut Plugin, requet: Value) -> Result, request: Value) -> Result { + walletrpc::fund_rgb_channel(plugin, request) +} + fn read_secret(file: fs::File, network: &str) -> anyhow::Result { let buffer = io::BufReader::new(file); let network = vlsbtc::Network::from_str(network)?; @@ -190,3 +196,5 @@ impl RPCCommand for OnFundingChannelTx { Ok(json::json!({ "result": json::to_value(&result)? })) } } + +// FIXME: add an hook that will add rgb onchain address to the wallet. diff --git a/rgb-cln/src/plugin/walletrpc.rs b/rgb-cln/src/plugin/walletrpc.rs index 6dd21df..d36abef 100644 --- a/rgb-cln/src/plugin/walletrpc.rs +++ b/rgb-cln/src/plugin/walletrpc.rs @@ -12,7 +12,6 @@ use clightningrpc_plugin::error; use clightningrpc_plugin::errors::PluginError; use clightningrpc_plugin::plugin::Plugin; -use rgb_common::lib::wallet::Balance; // TODO this should be hidden inside the common crate use rgb_common::types::RgbInfo; @@ -25,6 +24,7 @@ pub struct RGBBalanceRequest { /// Return the balance of an RGB assert pub fn rgb_balance(plugin: &mut Plugin, request: Value) -> Result { + log::info!("rgbbalances call with body `{request}`"); let request: RGBBalanceRequest = json::from_value(request).map_err(|err| error!("{err}"))?; let balance = plugin .state @@ -37,7 +37,7 @@ pub fn rgb_balance(plugin: &mut Plugin, request: Value) -> Result, request: Value) -> Result() + let balance = request.amount_msat; + let assert_balance = plugin + .state + .manager() + .assert_balance(contract_id.to_string()) .map_err(|err| error!("{err}"))?; + log::info!("rgbalance {:?}", balance); if balance < assert_balance.spendable { return Err(error!( @@ -75,7 +83,13 @@ pub fn fund_rgb_channel(plugin: &mut Plugin, request: Value) -> Result