Skip to content

Commit

Permalink
Project import generated by Copybara.
Browse files Browse the repository at this point in the history
GitOrigin-RevId: f442a9908067f8fb0982d26b9ac49246985f3f99
  • Loading branch information
Lightspark Eng authored and jklein24 committed Oct 10, 2023
1 parent 8361975 commit f6c809b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ Cargo.lock

# These are backup files generated by rustfmt
**/*.rs.bk

.idea/
6 changes: 6 additions & 0 deletions lightspark-remote-signing/src/invoice.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
use crate::Error;

pub trait PaymentPreimageProvider: Send + Sync {
fn release_preimage(&self, invoice_id: &str) -> Result<String, Error>;
fn get_payment_hash(&self, invoice_id: &str) -> Result<String, Error>;
}
1 change: 1 addition & 0 deletions lightspark-remote-signing/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use std::fmt;

pub extern crate lightspark;
pub mod handler;
pub mod invoice;
pub mod response;
pub mod signer;
pub mod validation;
Expand Down
16 changes: 9 additions & 7 deletions lightspark/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use crate::objects::account::Account;
use crate::objects::api_token::ApiToken;
use crate::objects::currency_amount::{self, CurrencyAmount};
use crate::objects::fee_estimate::FeeEstimate;
use crate::objects::incoming_payment::IncomingPayment;
use crate::objects::invoice;
use crate::objects::invoice::Invoice;
use crate::objects::invoice_data::InvoiceData;
Expand All @@ -25,7 +26,7 @@ use crate::objects::permission::Permission;
use crate::objects::withdrawal_mode::WithdrawalMode;
use crate::objects::withdrawal_request::WithdrawalRequest;
use crate::objects::{account, invoice_data};
use crate::objects::{api_token, outgoing_payment};
use crate::objects::{api_token, incoming_payment, outgoing_payment};
use crate::objects::{bitcoin_network, withdrawal_request};
use crate::objects::{fee_estimate, lightning_fee_estimate_output};
use crate::request::auth_provider::AuthProvider;
Expand Down Expand Up @@ -775,7 +776,7 @@ impl<K: OperationSigningKey> LightsparkClient<K> {
node_id: &str,
encoded_invoice: &str,
amount_msats: Option<i64>,
) -> Result<OutgoingPayment, Error> {
) -> Result<IncomingPayment, Error> {
let mutation = format!(
"
mutation CreateTestModePayment(
Expand All @@ -788,15 +789,15 @@ impl<K: OperationSigningKey> LightsparkClient<K> {
encoded_invoice: $encoded_invoice
amount_msats: $amount_msats
}}) {{
payment {{
...OutgoingPaymentFragment
incoming_payment {{
...IncomingPaymentFragment
}}
}}
}}
{}
",
outgoing_payment::FRAGMENT
incoming_payment::FRAGMENT
);

let mut variables: HashMap<&str, Value> = HashMap::new();
Expand All @@ -814,8 +815,9 @@ impl<K: OperationSigningKey> LightsparkClient<K> {
.execute_graphql_signing(&mutation, Some(value), Some(signing_key))
.await?;

let result = serde_json::from_value(json["create_test_mode_payment"]["payment"].clone())
.map_err(Error::JsonError)?;
let result =
serde_json::from_value(json["create_test_mode_payment"]["incoming_payment"].clone())
.map_err(Error::JsonError)?;
Ok(result)
}
}

0 comments on commit f6c809b

Please sign in to comment.