-
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
2,487 additions
and
929 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
[package] | ||
name = "rgb-contracts" | ||
version = { workspace = true } | ||
description = "Command-line wallet for RGB smart contracts on Bitcoin" | ||
keywords = { workspace = true } | ||
categories = { workspace = true } | ||
readme = "../README.md" | ||
authors = { workspace = true } | ||
repository = { workspace = true } | ||
homepage = { workspace = true } | ||
rust-version = { workspace = true } | ||
edition = { workspace = true } | ||
license = { workspace = true } | ||
|
||
[[bin]] | ||
name = "rgb" | ||
path = "src/main.rs" | ||
|
||
[dependencies] | ||
amplify = { workspace = true } | ||
baid58 = { workspace = true } | ||
strict_types = { workspace = true, features = ["serde"] } | ||
commit_verify = "0.10.6" | ||
bp-seals = "0.10.11" | ||
bp-std = { workspace = true, features = ["serde"] } | ||
bp-wallet = { workspace = true } | ||
bp-esplora = { workspace = true } | ||
bp-util = "0.10.0-beta.1" | ||
rgb-std = { workspace = true, features = ["serde"] } | ||
rgb-invoice = { workspace = true } | ||
rgb-runtime = { version = "0.11.0-alpha", path = "..", features = ["log", "serde"] } | ||
log = { workspace = true } | ||
env_logger = "0.10.0" | ||
clap = { version = "4.4.6", features = ["derive", "env"] } | ||
shellexpand = "3.1.0" | ||
serde_crate = { workspace = true } | ||
serde_yaml = { workspace = true } | ||
serde_json = "1.0.108" | ||
toml = "0.8.2" | ||
|
||
[features] | ||
default = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// RGB smart contracts for Bitcoin & Lightning | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
// Written in 2019-2023 by | ||
// Dr Maxim Orlovsky <orlovsky@lnp-bp.org> | ||
// | ||
// Copyright (C) 2019-2023 LNP/BP Standards Association. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
use bp_util::DescriptorOpts; | ||
use bpstd::XpubDerivable; | ||
use rgb_rt::{DescriptorRgb, Runtime, RuntimeError, TapretKey}; | ||
|
||
use crate::Command; | ||
|
||
#[derive(Args, Clone, PartialEq, Eq, Debug)] | ||
pub struct DescrRgbOpts { | ||
/// Use tapret(KEY) descriptor as wallet. | ||
#[arg(long, global = true)] | ||
pub tapret_key_only: Option<XpubDerivable>, | ||
} | ||
|
||
impl DescriptorOpts for DescrRgbOpts { | ||
type Descr = DescriptorRgb; | ||
|
||
fn is_some(&self) -> bool { self.tapret_key_only.is_some() } | ||
|
||
fn descriptor(&self) -> Option<Self::Descr> { | ||
self.tapret_key_only | ||
.clone() | ||
.map(TapretKey::from) | ||
.map(TapretKey::into) | ||
} | ||
} | ||
|
||
/// Command-line arguments | ||
#[derive(Parser)] | ||
#[derive(Wrapper, WrapperMut, Clone, Eq, PartialEq, Debug, From)] | ||
#[wrapper(Deref)] | ||
#[wrapper_mut(DerefMut)] | ||
#[command(author, version, about)] | ||
pub struct RgbArgs { | ||
#[clap(flatten)] | ||
#[from] | ||
#[wrap] | ||
pub inner: bp_util::Args<Command, DescrRgbOpts>, | ||
} | ||
|
||
impl Default for RgbArgs { | ||
fn default() -> Self { unreachable!() } | ||
} | ||
|
||
impl RgbArgs { | ||
pub fn rgb_runtime(&self) -> Result<Runtime, RuntimeError> { | ||
eprint!("Loading stock ... "); | ||
let runtime = Runtime::<DescriptorRgb>::load_pure_rgb( | ||
self.general.data_dir.clone(), | ||
self.general.chain, | ||
)?; | ||
eprintln!("success"); | ||
|
||
Ok(runtime) | ||
} | ||
} |
Oops, something went wrong.