mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-31 01:11:35 +00:00
wallet: log when saving already paid invoice
(maybe it should not be allowed?)
This commit is contained in:
parent
34612c671e
commit
a041a0c075
1 changed files with 7 additions and 2 deletions
|
@ -614,6 +614,8 @@ class Abstract_Wallet(AddressSynchronizer, ABC):
|
||||||
if invoice_type == PR_TYPE_LN:
|
if invoice_type == PR_TYPE_LN:
|
||||||
key = invoice['rhash']
|
key = invoice['rhash']
|
||||||
elif invoice_type == PR_TYPE_ONCHAIN:
|
elif invoice_type == PR_TYPE_ONCHAIN:
|
||||||
|
if self.is_onchain_invoice_paid(invoice):
|
||||||
|
self.logger.info("saving invoice... but it is already paid!")
|
||||||
key = bh2u(sha256(repr(invoice))[0:16])
|
key = bh2u(sha256(repr(invoice))[0:16])
|
||||||
invoice['id'] = key
|
invoice['id'] = key
|
||||||
outputs = invoice['outputs'] # type: List[PartialTxOutput]
|
outputs = invoice['outputs'] # type: List[PartialTxOutput]
|
||||||
|
@ -643,7 +645,7 @@ class Abstract_Wallet(AddressSynchronizer, ABC):
|
||||||
item = copy.copy(self.invoices[key])
|
item = copy.copy(self.invoices[key])
|
||||||
request_type = item.get('type')
|
request_type = item.get('type')
|
||||||
if request_type == PR_TYPE_ONCHAIN:
|
if request_type == PR_TYPE_ONCHAIN:
|
||||||
item['status'] = PR_PAID if self._is_onchain_invoice_paid(item)[0] else PR_UNPAID
|
item['status'] = PR_PAID if self.is_onchain_invoice_paid(item) else PR_UNPAID
|
||||||
elif self.lnworker and request_type == PR_TYPE_LN:
|
elif self.lnworker and request_type == PR_TYPE_LN:
|
||||||
item['status'] = self.lnworker.get_payment_status(bfh(item['rhash']))
|
item['status'] = self.lnworker.get_payment_status(bfh(item['rhash']))
|
||||||
else:
|
else:
|
||||||
|
@ -666,7 +668,7 @@ class Abstract_Wallet(AddressSynchronizer, ABC):
|
||||||
for txout in outputs:
|
for txout in outputs:
|
||||||
self._invoices_from_scriptpubkey_map[txout.scriptpubkey].add(invoice_key)
|
self._invoices_from_scriptpubkey_map[txout.scriptpubkey].add(invoice_key)
|
||||||
|
|
||||||
def _is_onchain_invoice_paid(self, invoice) -> Tuple[bool, Sequence[str]]:
|
def _is_onchain_invoice_paid(self, invoice: dict) -> Tuple[bool, Sequence[str]]:
|
||||||
"""Returns whether on-chain invoice is satisfied, and list of relevant TXIDs."""
|
"""Returns whether on-chain invoice is satisfied, and list of relevant TXIDs."""
|
||||||
assert invoice.get('type') == PR_TYPE_ONCHAIN
|
assert invoice.get('type') == PR_TYPE_ONCHAIN
|
||||||
invoice_amounts = defaultdict(int) # type: Dict[bytes, int] # scriptpubkey -> value_sats
|
invoice_amounts = defaultdict(int) # type: Dict[bytes, int] # scriptpubkey -> value_sats
|
||||||
|
@ -687,6 +689,9 @@ class Abstract_Wallet(AddressSynchronizer, ABC):
|
||||||
return False, []
|
return False, []
|
||||||
return True, relevant_txs
|
return True, relevant_txs
|
||||||
|
|
||||||
|
def is_onchain_invoice_paid(self, invoice: dict) -> bool:
|
||||||
|
return self._is_onchain_invoice_paid(invoice)[0]
|
||||||
|
|
||||||
def _maybe_set_tx_label_based_on_invoices(self, tx: Transaction) -> bool:
|
def _maybe_set_tx_label_based_on_invoices(self, tx: Transaction) -> bool:
|
||||||
tx_hash = tx.txid()
|
tx_hash = tx.txid()
|
||||||
with self.transaction_lock:
|
with self.transaction_lock:
|
||||||
|
|
Loading…
Add table
Reference in a new issue