@ -140,9 +140,9 @@ def get_wallet_payment(wallet_id: str, checking_id: str) -> Optional[Payment]:
with open_db ( ) as db :
row = db . fetchone (
"""
SELECT payhash as checking_id , amount , fee , pending , memo , time
FROM apipayments
WHERE wallet = ? AND payhash = ?
SELECT id as checking_id , amount , fee , pending , memo , time
FROM apipayment
WHERE wallet = ? AND id = ?
""" ,
( wallet_id , checking_id ) ,
)
@ -179,7 +179,7 @@ def get_wallet_payments(
with open_db ( ) as db :
rows = db . fetchall (
f """
SELECT payhash as checking_id , amount , fee , pending , memo , time
SELECT id as checking_id , amount , fee , pending , memo , time
FROM apipayments
WHERE wallet = ? { clause }
ORDER BY time DESC
@ -195,7 +195,7 @@ def delete_wallet_payments_expired(wallet_id: str, *, seconds: int = 86400) -> N
db . execute (
"""
DELETE
FROM apipayments WHERE wallet = ? AND pending = 1 AND time < strftime ( ' %s ' , ' now ' ) - ?
FROM apipayment WHERE wallet = ? AND pending = 1 AND time < strftime ( ' %s ' , ' now ' ) - ?
""" ,
( wallet_id , seconds ) ,
)
@ -206,15 +206,15 @@ def delete_wallet_payments_expired(wallet_id: str, *, seconds: int = 86400) -> N
def create_payment (
* , wallet_id : str , checking_id : str , amount : int , memo : str , fee : int = 0 , pending : bool = True
* , wallet_id : str , checking_id : str , payment_hash : str , amount : int , memo : str , fee : int = 0 , pending : bool = True
) - > Payment :
with open_db ( ) as db :
db . execute (
"""
INSERT INTO apipayments ( wallet , payhash , amount , pending , memo , fee )
VALUES ( ? , ? , ? , ? , ? , ? )
INSERT INTO apipayment ( wallet , id , payment_ hash , amount , pending , memo , fee )
VALUES ( ? , ? , ? , ? , ? , ? , ? )
""" ,
( wallet_id , checking_id , amount , int ( pending ) , memo , fee ) ,
( wallet_id , checking_id , payment_hash , amount , int ( pending ) , memo , fee ) ,
)
new_payment = get_wallet_payment ( wallet_id , checking_id )
@ -225,9 +225,18 @@ def create_payment(
def update_payment_status ( checking_id : str , pending : bool ) - > None :
with open_db ( ) as db :
db . execute ( " UPDATE apipayments SET pending = ? WHERE payhash = ? " , ( int ( pending ) , checking_id , ) )
db . execute ( " UPDATE apipayment SET pending = ? WHERE id = ? " , ( int ( pending ) , checking_id , ) )
def delete_payment ( checking_id : str ) - > None :
with open_db ( ) as db :
db . execute ( " DELETE FROM apipayments WHERE payhash = ? " , ( checking_id , ) )
db . execute ( " DELETE FROM apipayment WHERE id = ? " , ( checking_id , ) )
def check_internal ( payment_hash : str ) - > None :
with open_db ( ) as db :
row = db . fetchone ( " SELECT * FROM apipayment WHERE payment_hash = ? " , ( payment_hash , ) )
if not row :
return False
else :
return row [ ' id ' ]