Skip to content

Commit

Permalink
add duration_seconds param to /rgbinvoice
Browse files Browse the repository at this point in the history
  • Loading branch information
zoedberg committed Aug 27, 2024
1 parent ca992de commit f196bd8
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
3 changes: 3 additions & 0 deletions openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1593,6 +1593,9 @@ components:
asset_id:
type: string
example: rgb:2dkSTbr-jFhznbPmo-TQafzswCN-av4gTsJjX-ttx6CNou5-M98k8Zd
duration_seconds:
type: integer
example: 86400
RgbInvoiceResponse:
type: object
properties:
Expand Down
12 changes: 9 additions & 3 deletions src/rgb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,16 @@ impl UnlockedAppState {
pub(crate) fn rgb_blind_receive(
&self,
asset_id: Option<String>,
duration_seconds: Option<u32>,
transport_endpoints: Vec<String>,
min_confirmations: u8,
) -> Result<ReceiveData, RgbLibError> {
self.rgb_wallet_wrapper
.blind_receive(asset_id, transport_endpoints, min_confirmations)
self.rgb_wallet_wrapper.blind_receive(
asset_id,
duration_seconds,
transport_endpoints,
min_confirmations,
)
}

pub(crate) fn rgb_create_utxos(
Expand Down Expand Up @@ -245,13 +250,14 @@ impl RgbLibWalletWrapper {
pub(crate) fn blind_receive(
&self,
asset_id: Option<String>,
duration_seconds: Option<u32>,
transport_endpoints: Vec<String>,
min_confirmations: u8,
) -> Result<ReceiveData, RgbLibError> {
self.get_rgb_wallet().blind_receive(
asset_id,
None,
None,
duration_seconds,
transport_endpoints,
min_confirmations,
)
Expand Down
4 changes: 3 additions & 1 deletion src/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -699,8 +699,9 @@ pub(crate) struct RgbAllocation {

#[derive(Deserialize, Serialize)]
pub(crate) struct RgbInvoiceRequest {
pub(crate) min_confirmations: u8,
pub(crate) asset_id: Option<String>,
pub(crate) duration_seconds: Option<u32>,
pub(crate) min_confirmations: u8,
}

#[derive(Deserialize, Serialize)]
Expand Down Expand Up @@ -2585,6 +2586,7 @@ pub(crate) async fn rgb_invoice(

let receive_data = unlocked_state.rgb_blind_receive(
payload.asset_id,
payload.duration_seconds,
vec![state.static_state.proxy_endpoint.clone()],
payload.min_confirmations,
)?;
Expand Down
1 change: 1 addition & 0 deletions src/test/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1125,6 +1125,7 @@ async fn rgb_invoice(node_address: SocketAddr, asset_id: Option<String>) -> RgbI
let payload = RgbInvoiceRequest {
min_confirmations: 1,
asset_id,
duration_seconds: None,
};
let res = reqwest::Client::new()
.post(format!("http://{}/rgbinvoice", node_address))
Expand Down

0 comments on commit f196bd8

Please sign in to comment.