SatSale

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit a0bf4dc24d501277e08adc62d6626402ab3e0b48
parent 51a1d1ede2c34571f1bd4eccc1a920f18ba87aa7
Author: Kristaps Kaupe <kristaps@blogiem.lv>
Date:   Thu, 23 Dec 2021 10:05:42 +0200

Filter bitcoind listtransactions by label (#28)


Diffstat:
Mnode/bitcoind.py | 11+++++------
Msatsale.py | 6++----
2 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/node/bitcoind.py b/node/bitcoind.py @@ -81,17 +81,16 @@ class btcd: img.save("static/qr_codes/{}.png".format(uuid)) return - def check_payment(self, address): + def check_payment(self, uuid): if not self.tor: - transactions = self.rpc.listtransactions() + transactions = self.rpc.listtransactions(uuid) else: - transactions = call_tor_bitcoin_rpc("listtransactions", None)["result"] - - relevant_txs = [tx for tx in transactions if tx["address"] == address] + transactions = call_tor_bitcoin_rpc("listtransactions", + [uuid])["result"] conf_paid = 0 unconf_paid = 0 - for tx in relevant_txs: + for tx in transactions: if tx["confirmations"] >= config.required_confirmations: conf_paid += tx["amount"] else: diff --git a/satsale.py b/satsale.py @@ -253,11 +253,9 @@ def check_payment_status(uuid): node = get_node(invoice["method"]) if invoice["method"] == "lnd": conf_paid, unconf_paid = node.check_payment(invoice["rhash"]) - elif invoice["method"] == "clightning": - # Lookup clightning invoice based on label (uuid) - conf_paid, unconf_paid = node.check_payment(invoice["uuid"]) else: - conf_paid, unconf_paid = node.check_payment(invoice["address"]) + # Lookup bitcoind / clightning invoice based on label (uuid) + conf_paid, unconf_paid = node.check_payment(invoice["uuid"]) # Remove any Decimal types conf_paid, unconf_paid = float(conf_paid), float(unconf_paid)