Skip to content

Commit

Permalink
Storage Transfers (Consig) Files (#322)
Browse files Browse the repository at this point in the history
* Adding full transfer method

* Updating FullRgbTransferRequest struct

* Adding self pay to

* Bitcoin_inputs

* Match for btc_utxo

* Remove assert

* Full Transfer (PSBT + Dustless + Transfer)  (#312)

* refactor: add full transfer operation

* refactor: improviment psbt operation

* feat: add internal tests

* fix: improvement tests

* fix: coin selection

* fix: add btc change utxo

* fix: bitcoin derivation indexes

* Fix merge conflict.

* Add debug statement. Bump version to 0.6.3-rc.1.

* fix: genesis import and reduce esplora calls

* Bump bitmask-core to 0.6.3-rc.2.

* fix: blank transition for different contract types (#317)

* fix: watcher next utxos (#319)

* Bump bitmask-core to 0.6.3-rc.4.

* Not skipping is_spent in allocationdetail

* Adding watcher_unspent_utxos to web interface

* feat: temp transfers

* fix: prefetch and resolver for utxos

* feat: add bitcoin change addrs

* feat: automatically coin selection

* Add wasm_bindgen to decode_invoice

---------

Co-authored-by: Jose D Robles <[email protected]>
Co-authored-by: Hunter Trujillo <[email protected]>
Co-authored-by: Hunter Beast <[email protected]>
  • Loading branch information
4 people authored Aug 7, 2023
1 parent 5c2e25b commit 1755df1
Show file tree
Hide file tree
Showing 18 changed files with 936 additions and 102 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ futures = { version = "0.3.28", features = [
"executor",
], default-features = true }
garde = { version = "0.11.2", features = ["derive"], default-features = false }
rand = "0.8.5"
getrandom = { version = "0.2.10", features = ["js"] }
hex = "0.4.3"
indexmap = "1.9.3"
Expand Down
53 changes: 47 additions & 6 deletions src/bin/bitmaskd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,16 @@ use bitmask_core::{
rgb::{
accept_transfer, clear_watcher as rgb_clear_watcher, create_invoice, create_psbt,
create_watcher, full_transfer_asset, import as rgb_import, issue_contract, list_contracts,
list_interfaces, list_schemas, reissue_contract, transfer_asset, watcher_address,
watcher_details as rgb_watcher_details, watcher_next_address, watcher_next_utxo,
watcher_utxo,
list_interfaces, list_schemas, list_transfers as list_rgb_transfers, reissue_contract,
remove_transfer as remove_rgb_transfer, save_transfer as save_rgb_transfer, transfer_asset,
watcher_address, watcher_details as rgb_watcher_details, watcher_next_address,
watcher_next_utxo, watcher_utxo,
},
structs::{
AcceptRequest, FileMetadata, FullRgbTransferRequest, ImportRequest, InvoiceRequest,
IssueAssetRequest, IssueRequest, MediaInfo, PsbtFeeRequest, PsbtRequest, ReIssueRequest,
RgbTransferRequest, SecretString, SelfFullRgbTransferRequest, SelfIssueRequest,
SignPsbtRequest, WatcherRequest,
RgbRemoveTransferRequest, RgbSaveTransferRequest, RgbTransferRequest, SecretString,
SelfFullRgbTransferRequest, SelfIssueRequest, SignPsbtRequest, WatcherRequest,
},
};
use carbonado::file;
Expand Down Expand Up @@ -160,8 +161,9 @@ async fn self_pay(
iface: self_pay_req.iface,
rgb_invoice: self_pay_req.rgb_invoice,
descriptor: SecretString(issuer_keys.public.rgb_udas_descriptor_xpub.clone()),
change_terminal: self_pay_req.terminal,
fee,
change_terminal: self_pay_req.terminal,
bitcoin_changes: self_pay_req.bitcoin_changes,
};

let transfer_res = full_transfer_asset(sk, request).await?;
Expand Down Expand Up @@ -327,6 +329,42 @@ async fn register_utxo(
Ok((StatusCode::OK, Json(resp)))
}

async fn list_transfers(
TypedHeader(auth): TypedHeader<Authorization<Bearer>>,
Path(contract_id): Path<String>,
) -> Result<impl IntoResponse, AppError> {
info!("GET /transfers/{contract_id:?}");

let nostr_hex_sk = auth.token();
let transfers_res = list_rgb_transfers(nostr_hex_sk, contract_id).await?;

Ok((StatusCode::OK, Json(transfers_res)))
}

async fn save_transfer(
TypedHeader(auth): TypedHeader<Authorization<Bearer>>,
Json(request): Json<RgbSaveTransferRequest>,
) -> Result<impl IntoResponse, AppError> {
info!("POST /transfers {request:?}");

let nostr_hex_sk = auth.token();
let import_res = save_rgb_transfer(nostr_hex_sk, request).await?;

Ok((StatusCode::OK, Json(import_res)))
}

async fn remove_transfer(
TypedHeader(auth): TypedHeader<Authorization<Bearer>>,
Json(request): Json<RgbRemoveTransferRequest>,
) -> Result<impl IntoResponse, AppError> {
info!("DELETE /transfers {request:?}");

let nostr_hex_sk = auth.token();
let import_res = remove_rgb_transfer(nostr_hex_sk, request).await?;

Ok((StatusCode::OK, Json(import_res)))
}

async fn co_store(
Path((pk, name)): Path<(String, String)>,
body: Bytes,
Expand Down Expand Up @@ -533,6 +571,9 @@ async fn main() -> Result<()> {
)
.route("/watcher/:name/:asset/utxo/:utxo", put(register_utxo))
.route("/watcher/:name", delete(clear_watcher))
.route("/transfers/:id", get(list_transfers))
.route("/transfers/", post(save_transfer))
.route("/transfers/", delete(remove_transfer))
.route("/key/:pk", get(key))
.route("/carbonado/status", get(status))
.route("/carbonado/:pk/:name", post(co_store))
Expand Down
1 change: 1 addition & 0 deletions src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,4 +191,5 @@ pub async fn set_env(key: &str, value: &str) {
pub mod storage_keys {
pub const ASSETS_STOCK: &str = "bitmask-fungible_assets_stock.c15";
pub const ASSETS_WALLETS: &str = "bitmask-fungible_assets_wallets.c15";
pub const ASSETS_TRANSFERS: &str = "bitmask_assets_transfers.c15";
}
Loading

0 comments on commit 1755df1

Please sign in to comment.