Skip to content

Commit 4914fea

Browse files
authored
Merge pull request #93 from utxostack/ln-activity-msat
Add amount_msat to LN activity
2 parents 44206f6 + 8fc9cb1 commit 4914fea

File tree

4 files changed

+23
-1
lines changed

4 files changed

+23
-1
lines changed

mutiny-core/src/lib.rs

+6
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,7 @@ pub struct MutinyInvoice {
340340
pub preimage: Option<String>,
341341
pub payee_pubkey: Option<PublicKey>,
342342
pub amount_sats: Option<u64>,
343+
pub amount_msat: Option<u64>,
343344
pub expire: u64,
344345
pub status: HTLCStatus,
345346
#[serde(default)]
@@ -361,6 +362,7 @@ impl Default for MutinyInvoice {
361362
preimage: None,
362363
payee_pubkey: None,
363364
amount_sats: None,
365+
amount_msat: None,
364366
expire: 0,
365367
status: HTLCStatus::Pending,
366368
privacy_level: PrivacyLevel::NotAvailable,
@@ -398,6 +400,7 @@ impl From<Bolt11Invoice> for MutinyInvoice {
398400

399401
let payment_hash = value.payment_hash().to_owned();
400402
let payee_pubkey = value.payee_pub_key().map(|p| p.to_owned());
403+
let amount_msat = value.amount_milli_satoshis();
401404
let amount_sats = value.amount_milli_satoshis().map(|m| m / 1000);
402405

403406
MutinyInvoice {
@@ -407,6 +410,7 @@ impl From<Bolt11Invoice> for MutinyInvoice {
407410
preimage: None,
408411
payee_pubkey,
409412
amount_sats,
413+
amount_msat,
410414
expire: expiry,
411415
status: HTLCStatus::Pending,
412416
privacy_level: PrivacyLevel::NotAvailable,
@@ -483,6 +487,7 @@ impl MutinyInvoice {
483487
})
484488
}
485489
None => {
490+
let amount_msat: Option<u64> = i.amt_msat.0;
486491
let amount_sats: Option<u64> = i.amt_msat.0.map(|s| s / 1_000);
487492
let fees_paid = i.fee_paid_msat.map(|f| f / 1_000);
488493
let preimage = i.preimage.map(|p| p.to_lower_hex_string());
@@ -494,6 +499,7 @@ impl MutinyInvoice {
494499
preimage,
495500
payee_pubkey: i.payee_pubkey,
496501
amount_sats,
502+
amount_msat,
497503
expire: i.last_update,
498504
status: i.status,
499505
privacy_level: i.privacy_level,

mutiny-core/src/nodemanager.rs

+7
Original file line numberDiff line numberDiff line change
@@ -2317,6 +2317,7 @@ mod tests {
23172317
preimage: Some(preimage.to_lower_hex_string()),
23182318
payee_pubkey: None,
23192319
amount_sats: Some(100_000),
2320+
amount_msat: Some(100_000_000),
23202321
expire: 1681781649 + 86400,
23212322
status: HTLCStatus::Succeeded,
23222323
privacy_level: PrivacyLevel::Anonymous,
@@ -2373,6 +2374,7 @@ mod tests {
23732374
preimage: Some(preimage.to_lower_hex_string()),
23742375
payee_pubkey: Some(pubkey),
23752376
amount_sats: Some(100),
2377+
amount_msat: Some(100_000),
23762378
expire: 1681781585,
23772379
status: HTLCStatus::Succeeded,
23782380
privacy_level: PrivacyLevel::Anonymous,
@@ -2477,6 +2479,7 @@ mod tests {
24772479
preimage: Some(preimage.to_lower_hex_string()),
24782480
payee_pubkey: Some(pubkey),
24792481
amount_sats: Some(100),
2482+
amount_msat: Some(100_000),
24802483
expire: 1681781585,
24812484
status: HTLCStatus::Succeeded,
24822485
privacy_level: PrivacyLevel::NotAvailable,
@@ -2494,6 +2497,7 @@ mod tests {
24942497
preimage: Some(preimage.to_lower_hex_string()),
24952498
payee_pubkey: Some(pubkey),
24962499
amount_sats: Some(100),
2500+
amount_msat: Some(100_000),
24972501
expire: 1681781585,
24982502
status: HTLCStatus::Succeeded,
24992503
privacy_level: PrivacyLevel::NotAvailable,
@@ -2511,6 +2515,7 @@ mod tests {
25112515
preimage: None,
25122516
payee_pubkey: Some(pubkey),
25132517
amount_sats: Some(101),
2518+
amount_msat: Some(101_000),
25142519
expire: 1581781585,
25152520
status: HTLCStatus::InFlight,
25162521
privacy_level: PrivacyLevel::NotAvailable,
@@ -2528,6 +2533,7 @@ mod tests {
25282533
preimage: None,
25292534
payee_pubkey: Some(pubkey),
25302535
amount_sats: Some(102),
2536+
amount_msat: Some(102_000),
25312537
expire: 1581781585,
25322538
status: HTLCStatus::InFlight,
25332539
privacy_level: PrivacyLevel::NotAvailable,
@@ -2545,6 +2551,7 @@ mod tests {
25452551
preimage: Some(preimage.to_lower_hex_string()),
25462552
payee_pubkey: Some(pubkey),
25472553
amount_sats: Some(100),
2554+
amount_msat: Some(100_000),
25482555
expire: 1681781585,
25492556
status: HTLCStatus::Succeeded,
25502557
privacy_level: PrivacyLevel::NotAvailable,

mutiny-wasm/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ cargo-features = ["per-package-target"]
22

33
[package]
44
name = "mutiny-wasm"
5-
version = "1.12.1"
5+
version = "1.12.2"
66
edition = "2021"
77
authors = ["utxostack"]
88
forced-target = "wasm32-unknown-unknown"

mutiny-wasm/src/models.rs

+9
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ pub struct ActivityItem {
2929
pub kind: ActivityType,
3030
id: String,
3131
pub amount_sats: Option<u64>,
32+
pub amount_msat: Option<u64>,
3233
pub inbound: bool,
3334
pub(crate) labels: Vec<String>,
3435
pub last_updated: Option<u64>,
@@ -98,6 +99,11 @@ impl From<mutiny_core::ActivityItem> for ActivityItem {
9899
mutiny_core::ActivityItem::ChannelClosed(_) => (false, None),
99100
};
100101

102+
let amount_msat = match a {
103+
mutiny_core::ActivityItem::Lightning(ref ln) => ln.amount_msat,
104+
_ => None,
105+
};
106+
101107
let fee_paid_msat = match a {
102108
mutiny_core::ActivityItem::Lightning(ref ln) => ln.fee_paid_msat,
103109
_ => None,
@@ -131,6 +137,7 @@ impl From<mutiny_core::ActivityItem> for ActivityItem {
131137
kind,
132138
id,
133139
amount_sats,
140+
amount_msat,
134141
inbound,
135142
fee_paid_msat,
136143
labels: a.labels(),
@@ -150,6 +157,7 @@ pub struct MutinyInvoice {
150157
preimage: Option<String>,
151158
payee_pubkey: Option<String>,
152159
pub amount_sats: Option<u64>,
160+
pub amount_msat: Option<u64>,
153161
pub expire: u64,
154162
pub expired: bool,
155163
status: String,
@@ -228,6 +236,7 @@ impl From<mutiny_core::MutinyInvoice> for MutinyInvoice {
228236
preimage: m.preimage,
229237
payee_pubkey: m.payee_pubkey.map(|p| p.serialize().to_lower_hex_string()),
230238
amount_sats: m.amount_sats,
239+
amount_msat: m.amount_msat,
231240
expire: m.expire,
232241
expired: m.expire < now,
233242
status: m.status.to_string(),

0 commit comments

Comments
 (0)