Skip to content

Commit b4de29e

Browse files
f321xSomberNight
andcommitted
Add invoice_amount_sat to check_hold_invoice response
Adds an additional value to the `check_hold_invoice` cli command: `invoice_amount_sat` which returns the requested amount value of the hold invoice. Co-authored-by: ghost43 <[email protected]>
1 parent 8f9951e commit b4de29e

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

electrum/commands.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1489,8 +1489,10 @@ async def check_hold_invoice(self, payment_hash: str, wallet: Abstract_Wallet =
14891489
amount_sat = amount_msat // 1000
14901490
result = {
14911491
"status": status,
1492-
"amount_sat_received": amount_sat
1492+
"received_amount_sat": amount_sat,
14931493
}
1494+
if info is not None:
1495+
result["invoice_amount_sat"] = (info.amount_msat or 0) // 1000
14941496
return result
14951497

14961498
@command('w')

tests/test_commands.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ async def test_hold_invoice_commands(self, mock_save_db):
495495
mock.patch.object(wallet.lnworker, 'get_payment_mpp_amount_msat', return_value=10_000 * 1000):
496496
status: dict = await cmds.check_hold_invoice(payment_hash=payment_hash, wallet=wallet)
497497
assert status['status'] == 'paid'
498-
assert status['amount_sat_received'] == 10000
498+
assert status['received_amount_sat'] == 10000
499499

500500
settle_result = await cmds.settle_hold_invoice(
501501
preimage=preimage.hex(),
@@ -511,7 +511,8 @@ async def test_hold_invoice_commands(self, mock_save_db):
511511
)):
512512
settled_status: dict = await cmds.check_hold_invoice(payment_hash=payment_hash, wallet=wallet)
513513
assert settled_status['status'] == 'settled'
514-
assert settled_status['amount_sat_received'] == 10000
514+
assert settled_status['received_amount_sat'] == 10000
515+
assert settled_status['invoice_amount_sat'] == 10000
515516

516517
with self.assertRaises(AssertionError):
517518
# cancelling a settled invoice should raise

0 commit comments

Comments
 (0)