[TEST] proper credit_wallet function from services (#1862)

This commit is contained in:
dni ⚡
2023-08-07 21:49:37 +02:00
committed by GitHub
parent 03acf5e5ec
commit f096b51f70
2 changed files with 4 additions and 27 deletions

View File

@ -2,32 +2,13 @@ import hashlib
import json
import os
import random
import secrets
import string
from subprocess import PIPE, Popen, run
from typing import Tuple
from lnbits.core.crud import create_payment
from lnbits.wallets import get_wallet_class, set_wallet_class
async def credit_wallet(wallet_id: str, amount: int):
preimage = secrets.token_hex(32)
m = hashlib.sha256()
m.update(f"{preimage}".encode())
payment_hash = m.hexdigest()
await create_payment(
wallet_id=wallet_id,
payment_request="",
payment_hash=payment_hash,
checking_id=payment_hash,
preimage=preimage,
memo=f"funding_test_{get_random_string(5)}",
amount=amount, # msat
pending=False, # not pending, so it will increase the wallet's balance
)
def get_random_string(N: int = 10):
return "".join(
random.SystemRandom().choice(string.ascii_uppercase + string.digits)