-
Notifications
You must be signed in to change notification settings - Fork 5
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
6 changed files
with
83 additions
and
6 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,5 +1,8 @@ | ||
# Changelog | ||
|
||
# v0.9.2 | ||
- RSA signing should be PSS signatures. | ||
|
||
# v0.9.1 | ||
- Fix a signing issue with RSA keys. | ||
|
||
|
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 |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
name = "lightspark" | ||
description = "Lightspark Rust SDK" | ||
authors = ["Lightspark Group, Inc. <[email protected]>"] | ||
version = "0.9.1" | ||
version = "0.9.2" | ||
edition = "2021" | ||
documentation = "https://docs.lightspark.com/lightspark-sdk/getting-started?language=Rust" | ||
homepage = "https://www.lightspark.com/" | ||
|
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,73 @@ | ||
use lightspark::{ | ||
client::LightsparkClient, key::RSASigningKey, request::auth_provider::AccountAuthProvider, | ||
}; | ||
|
||
async fn create_invoice() { | ||
let api_id = std::env::var("LIGHTSPARK_API_CLIENT_ID").unwrap(); | ||
let api_token = std::env::var("LIGHTSPARK_API_CLIENT_SECRET").unwrap(); | ||
let endpoint = std::env::var("LIGHTSPARK_API_ENDPOINT").unwrap(); | ||
|
||
let auth = AccountAuthProvider::new(api_id.to_string(), api_token.to_string()); | ||
let mut client = LightsparkClient::<RSASigningKey>::new(auth).unwrap(); | ||
client.requester.set_base_url(Some(endpoint)); | ||
|
||
let node_id = std::env::var("LIGHTSPARK_NODE_ID").unwrap(); | ||
|
||
let password = std::env::var("LIGHTSPARK_NODE_PASSWORD").unwrap(); | ||
let _ = client.recover_node_signing_key(&node_id, &password).await; | ||
|
||
println!("API ID: {:?}", api_id); | ||
println!("API Token: {:?}", api_token); | ||
println!("Node ID: {:?}", node_id); | ||
|
||
let account = client.get_current_account().await.unwrap(); | ||
println!("Account: {:?}", account.name); | ||
|
||
let invoice = client.create_invoice(&node_id, 10000, None, None).await; | ||
let payment_request = invoice.unwrap().data.encoded_payment_request; | ||
println!("Invoice created: {:?}", payment_request); | ||
|
||
let response = client | ||
.create_test_mode_payment(&node_id, &payment_request, None) | ||
.await; | ||
println!("Payment response: {:?}", response.unwrap().id); | ||
} | ||
|
||
async fn test_payment() { | ||
let api_id = std::env::var("LIGHTSPARK_API_CLIENT_ID").unwrap(); | ||
let api_token = std::env::var("LIGHTSPARK_API_CLIENT_SECRET").unwrap(); | ||
let endpoint = std::env::var("LIGHTSPARK_API_ENDPOINT").unwrap(); | ||
|
||
let auth = AccountAuthProvider::new(api_id.to_string(), api_token.to_string()); | ||
let mut client = LightsparkClient::<RSASigningKey>::new(auth).unwrap(); | ||
client.requester.set_base_url(Some(endpoint)); | ||
|
||
let node_id = std::env::var("LIGHTSPARK_NODE_ID").unwrap(); | ||
|
||
let password = std::env::var("LIGHTSPARK_NODE_PASSWORD").unwrap(); | ||
let _ = client.recover_node_signing_key(&node_id, &password).await; | ||
|
||
println!("API ID: {:?}", api_id); | ||
println!("API Token: {:?}", api_token); | ||
println!("Node ID: {:?}", node_id); | ||
|
||
let account = client.get_current_account().await.unwrap(); | ||
println!("Account: {:?}", account.name); | ||
|
||
let invoice = client | ||
.create_test_mode_invoice(&node_id, 10000, Some("test"), None) | ||
.await; | ||
let payment_request = invoice.unwrap().replace('\"', ""); | ||
println!("Invoice created: {:?}", payment_request); | ||
|
||
let response = client | ||
.pay_invoice(&node_id, &payment_request, 100, None, 1000) | ||
.await; | ||
println!("Payment response: {:?}", response.unwrap().id); | ||
} | ||
|
||
#[tokio::main] | ||
async fn main() { | ||
create_invoice().await; | ||
test_payment().await; | ||
} |
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