Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
A
aisbf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexlab
aisbf
Commits
d5a3e348
Commit
d5a3e348
authored
Apr 16, 2026
by
Your Name
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(payments): implement blockchain monitoring (API mode)
parent
4b7c6729
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
418 additions
and
1 deletion
+418
-1
__init__.py
aisbf/payments/crypto/__init__.py
+2
-1
monitor.py
aisbf/payments/crypto/monitor.py
+350
-0
test_monitor.py
tests/payments/test_monitor.py
+66
-0
No files found.
aisbf/payments/crypto/__init__.py
View file @
d5a3e348
...
...
@@ -3,5 +3,6 @@ Crypto payment module
"""
from
aisbf.payments.crypto.wallet
import
CryptoWalletManager
from
aisbf.payments.crypto.pricing
import
CryptoPriceService
from
aisbf.payments.crypto.monitor
import
BlockchainMonitor
__all__
=
[
'CryptoWalletManager'
,
'CryptoPriceService'
]
__all__
=
[
'CryptoWalletManager'
,
'CryptoPriceService'
,
'BlockchainMonitor'
]
aisbf/payments/crypto/monitor.py
0 → 100644
View file @
d5a3e348
This diff is collapsed.
Click to expand it.
tests/payments/test_monitor.py
0 → 100644
View file @
d5a3e348
import
pytest
from
datetime
import
datetime
from
aisbf.database
import
DatabaseManager
from
aisbf.payments.migrations
import
PaymentMigrations
from
aisbf.payments.crypto.monitor
import
BlockchainMonitor
from
aisbf.payments.crypto.pricing
import
CryptoPriceService
@
pytest
.
fixture
def
db_manager
(
tmp_path
):
"""Create test database"""
db_path
=
tmp_path
/
"test.db"
db_config
=
{
'type'
:
'sqlite'
,
'sqlite_path'
:
str
(
db_path
)
}
db
=
DatabaseManager
(
db_config
)
migrations
=
PaymentMigrations
(
db
)
migrations
.
run_migrations
()
return
db
@
pytest
.
mark
.
anyio
async
def
test_process_transaction
(
db_manager
):
"""Test transaction processing"""
config
=
{
'currency_code'
:
'USD'
,
'btc_confirmations'
:
3
}
monitor
=
BlockchainMonitor
(
db_manager
,
config
)
# Create user and address
with
db_manager
.
_get_connection
()
as
conn
:
cursor
=
conn
.
cursor
()
cursor
.
execute
(
"""
INSERT INTO user_crypto_addresses
(user_id, crypto_type, address, derivation_path, derivation_index)
VALUES (1, 'btc', 'bc1qtest', 'm/44/0/0/0/0', 0)
"""
)
cursor
.
execute
(
"""
INSERT INTO user_crypto_wallets
(user_id, crypto_type, balance_crypto, balance_fiat)
VALUES (1, 'btc', 0, 0)
"""
)
conn
.
commit
()
# Process transaction
await
monitor
.
process_transaction
(
user_id
=
1
,
crypto_type
=
'btc'
,
tx_hash
=
'test_tx_hash'
,
from_address
=
'bc1qfrom'
,
to_address
=
'bc1qtest'
,
amount
=
0.001
,
confirmations
=
3
)
# Check transaction was recorded
with
db_manager
.
_get_connection
()
as
conn
:
cursor
=
conn
.
cursor
()
cursor
.
execute
(
"SELECT * FROM crypto_transactions WHERE tx_hash = ?"
,
(
'test_tx_hash'
,)
)
tx
=
cursor
.
fetchone
()
assert
tx
is
not
None
assert
tx
[
9
]
==
'confirmed'
# status column
assert
float
(
tx
[
5
])
==
0.001
# amount_crypto column
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment