Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,11 @@ The node currently exposes the following APIs:
- `/getchannelid` (POST)
- `/getpayment` (POST)
- `/getswap` (POST)
- `/inflate` (POST)
- `/init` (POST)
- `/invoicestatus` (POST)
- `/issueassetcfa` (POST)
- `/issueassetifa` (POST)
- `/issueassetnia` (POST)
- `/issueassetuda` (POST)
- `/keysend` (POST)
Expand Down
179 changes: 178 additions & 1 deletion openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,24 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/GetSwapResponse'
/inflate:
post:
tags:
- RGB
summary: Inflate RGB assets
description: Inflate RGB assets on-chain
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/InflateRequest'
responses:
'200':
description: Successful operation
content:
application/json:
schema:
$ref: '#/components/schemas/InflateResponse'
/init:
post:
tags:
Expand Down Expand Up @@ -442,6 +460,24 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/IssueAssetCFAResponse'
/issueassetifa:
post:
tags:
- RGB
summary: Issue an RGB IFA asset
description: Issue an RGB IFA asset
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/IssueAssetIFARequest'
responses:
'200':
description: Successful operation
content:
application/json:
schema:
$ref: '#/components/schemas/IssueAssetIFAResponse'
/issueassetnia:
post:
tags:
Expand Down Expand Up @@ -1056,6 +1092,63 @@ components:
oneOf:
- $ref: '#/components/schemas/Media'
- type: 'null'
AssetIFA:
type: object
required:
- asset_id
- ticker
- name
- precision
- initial_supply
- max_supply
- known_circulating_supply
- timestamp
- added_at
- balance
properties:
asset_id:
type: string
example: rgb:CJkb4YZw-jRiz2sk-~PARPio-wtVYI1c-XAEYCqO-wTfvRZ8
ticker:
type: string
example: USDT
name:
type: string
example: Tether
details:
type:
- string
- 'null'
example: asset details
precision:
type: integer
example: 0
initial_supply:
type: integer
example: 777
max_supply:
type: integer
example: 999
known_circulating_supply:
type: integer
example: 888
timestamp:
type: integer
example: 1691160565
added_at:
type: integer
example: 1691161979
balance:
$ref: '#/components/schemas/AssetBalanceResponse'
media:
oneOf:
- $ref: '#/components/schemas/Media'
- type: 'null'
reject_list_url:
type:
- string
- 'null'
example: https://some.domain/someasset/rejectlist
AssetMetadataRequest:
type: object
required:
Expand Down Expand Up @@ -1159,6 +1252,7 @@ components:
- Nia
- Uda
- Cfa
- Ifa
AssetUDA:
type: object
required:
Expand Down Expand Up @@ -1742,6 +1836,37 @@ components:
enum:
- Electrum
- Esplora
InflateRequest:
type: object
required:
- asset_id
- inflation_amounts
- fee_rate
- min_confirmations
properties:
asset_id:
type: string
example: rgb:CJkb4YZw-jRiz2sk-~PARPio-wtVYI1c-XAEYCqO-wTfvRZ8
inflation_amounts:
type: array
items:
type: integer
minItems: 1
example: [ 100, 50 ]
fee_rate:
type: integer
example: 5
min_confirmations:
type: integer
example: 1
InflateResponse:
type: object
required:
- txid
properties:
txid:
type: string
example: 7c2c95b9c2aa0a7d140495b664de7973b76561de833f0dd84def3efa08941664
InitRequest:
type: object
required:
Expand Down Expand Up @@ -1820,6 +1945,51 @@ components:
properties:
asset:
$ref: '#/components/schemas/AssetCFA'
IssueAssetIFARequest:
type: object
required:
- amounts
- inflation_amounts
- ticker
- name
- precision
- replace_rights_num
properties:
amounts:
type: array
items:
type: integer
minItems: 1
example: [ 1000, 600 ]
inflation_amounts:
type: array
items:
type: integer
example: [ 100, 50 ]
ticker:
type: string
example: USDT
name:
type: string
example: Tether
precision:
type: integer
example: 0
replace_rights_num:
type: integer
example: 0
reject_list_url:
type:
- string
- 'null'
example: https://some.domain/someasset/rejectlist
IssueAssetIFAResponse:
type: object
required:
- asset
properties:
asset:
$ref: '#/components/schemas/AssetIFA'
IssueAssetNIARequest:
type: object
required:
Expand Down Expand Up @@ -1934,13 +2104,14 @@ components:
type: array
items:
$ref: '#/components/schemas/AssetSchema'
example: [ Nia, Uda, Cfa ]
example: [ Nia, Uda, Cfa, Ifa ]
ListAssetsResponse:
type: object
required:
- nia
- uda
- cfa
- ifa
properties:
nia:
type:
Expand All @@ -1960,6 +2131,12 @@ components:
- 'null'
items:
$ref: '#/components/schemas/AssetCFA'
ifa:
type:
- array
- 'null'
items:
$ref: '#/components/schemas/AssetIFA'
ListChannelsResponse:
type: object
required:
Expand Down
2 changes: 1 addition & 1 deletion rust-lightning
13 changes: 13 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,9 @@ pub enum APIError {
#[error("The provided backup has an unsupported version: {version}")]
UnsupportedBackupVersion { version: String },

#[error("Inflation is not supported by schema {0}")]
UnsupportedInflation(String),

#[error("Layer 1 {0} is not supported")]
UnsupportedLayer1(String),

Expand Down Expand Up @@ -386,16 +389,25 @@ impl From<RgbLibError> for APIError {
RgbLibError::MaxFeeExceeded { txid } => APIError::MaxFeeExceeded(txid),
RgbLibError::MinFeeNotMet { txid } => APIError::MinFeeNotMet(txid),
RgbLibError::Network { details } => APIError::Network(details),
RgbLibError::NoInflationAmounts => {
APIError::InvalidAmount(s!("inflation request with no amounts or zero amounts"))
}
RgbLibError::NoIssuanceAmounts => {
APIError::InvalidAmount(s!("issuance request with no provided amounts"))
}
RgbLibError::NoValidTransportEndpoint => APIError::NoValidTransportEndpoint,
RgbLibError::OutputBelowDustLimit => APIError::OutputBelowDustLimit,
RgbLibError::Proxy { details } => APIError::Network(format!("proxy err: {details}")),
RgbLibError::RecipientIDAlreadyUsed => APIError::RecipientIDAlreadyUsed,
RgbLibError::TooHighInflationAmounts => {
APIError::InvalidAmount(s!("inflation amount exceeds the max possible supply"))
}
RgbLibError::TooHighIssuanceAmounts => {
APIError::InvalidAmount(s!("trying to issue too many assets"))
}
RgbLibError::UnsupportedInflation { asset_schema } => {
APIError::UnsupportedInflation(format!("{asset_schema}"))
}
RgbLibError::UnsupportedLayer1 { layer_1 } => APIError::UnsupportedLayer1(layer_1),
RgbLibError::UnsupportedTransportType => APIError::UnsupportedTransportType,
_ => {
Expand Down Expand Up @@ -506,6 +518,7 @@ impl IntoResponse for APIError {
| APIError::UnknownLNInvoice
| APIError::UnknownTemporaryChannelId
| APIError::UnlockedNode
| APIError::UnsupportedInflation(_)
| APIError::UnsupportedLayer1(_)
| APIError::UnsupportedTransportType => {
(StatusCode::FORBIDDEN, self.to_string(), self.name())
Expand Down
12 changes: 9 additions & 3 deletions src/ldk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -593,9 +593,10 @@ async fn handle_ldk_events(
let channel_rgb_amount = rgb_info.local_rgb_amount + rgb_info.remote_rgb_amount;
let asset_id = rgb_info.contract_id.to_string();
let assignment = match rgb_info.schema {
AssetSchema::Nia | AssetSchema::Cfa => Assignment::Fungible(channel_rgb_amount),
AssetSchema::Nia | AssetSchema::Cfa | AssetSchema::Ifa => {
Assignment::Fungible(channel_rgb_amount)
}
AssetSchema::Uda => Assignment::NonFungible,
AssetSchema::Ifa => todo!(),
};

let recipient_id = recipient_id_from_script_buf(script_buf, static_state.network);
Expand Down Expand Up @@ -1788,7 +1789,12 @@ pub(crate) async fn start_ldk(
master_fingerprint: master_fingerprint.to_string(),
mnemonic: Some(mnemonic.to_string()),
vanilla_keychain: None,
supported_schemas: vec![AssetSchema::Nia, AssetSchema::Cfa, AssetSchema::Uda],
supported_schemas: vec![
AssetSchema::Nia,
AssetSchema::Cfa,
AssetSchema::Uda,
AssetSchema::Ifa,
],
})
.expect("valid rgb-lib wallet")
})
Expand Down
15 changes: 9 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,13 @@ use crate::routes::{
address, asset_balance, asset_metadata, backup, btc_balance, change_password,
check_indexer_url, check_proxy_endpoint, close_channel, connect_peer, create_utxos,
decode_ln_invoice, decode_rgb_invoice, disconnect_peer, estimate_fee, fail_transfers,
get_asset_media, get_channel_id, get_payment, get_swap, init, invoice_status, issue_asset_cfa,
issue_asset_nia, issue_asset_uda, keysend, list_assets, list_channels, list_payments,
list_peers, list_swaps, list_transactions, list_transfers, list_unspents, ln_invoice, lock,
maker_execute, maker_init, network_info, node_info, open_channel, post_asset_media,
refresh_transfers, restore, revoke_token, rgb_invoice, send_btc, send_onion_message,
send_payment, send_rgb, shutdown, sign_message, sync, taker, unlock,
get_asset_media, get_channel_id, get_payment, get_swap, inflate, init, invoice_status,
issue_asset_cfa, issue_asset_ifa, issue_asset_nia, issue_asset_uda, keysend, list_assets,
list_channels, list_payments, list_peers, list_swaps, list_transactions, list_transfers,
list_unspents, ln_invoice, lock, maker_execute, maker_init, network_info, node_info,
open_channel, post_asset_media, refresh_transfers, restore, revoke_token, rgb_invoice,
send_btc, send_onion_message, send_payment, send_rgb, shutdown, sign_message, sync, taker,
unlock,
};
use crate::utils::{start_daemon, AppState, LOGS_DIR};

Expand Down Expand Up @@ -124,9 +125,11 @@ pub(crate) async fn app(args: UserArgs) -> Result<(Router, Arc<AppState>), AppEr
.route("/getchannelid", post(get_channel_id))
.route("/getpayment", post(get_payment))
.route("/getswap", post(get_swap))
.route("/inflate", post(inflate))
.route("/init", post(init))
.route("/invoicestatus", post(invoice_status))
.route("/issueassetcfa", post(issue_asset_cfa))
.route("/issueassetifa", post(issue_asset_ifa))
.route("/issueassetnia", post(issue_asset_nia))
.route("/issueassetuda", post(issue_asset_uda))
.route("/keysend", post(keysend))
Expand Down
Loading
Loading