Skip to content

Error responses codes#2127

Merged
KoalaSat merged 13 commits intoRoboSats:mainfrom
aftermath2:error_responses_codes
Aug 13, 2025
Merged

Error responses codes#2127
KoalaSat merged 13 commits intoRoboSats:mainfrom
aftermath2:error_responses_codes

Conversation

@aftermath2
Copy link
Contributor

@aftermath2 aftermath2 commented Jul 30, 2025

What does this PR do?

Fixes #1383

This PR introduces error codes into the API and chat to simplify error handling and the debugging of the code.

There should be no functional changes apart from the new error_code field in 400 status code responses.

Note

There are many more enhancements to apply (i.e. add more details/context, return always the same error fields instead of different ones, etc.), but I prioritized maintaining compatibility with previous versions

Tests

Errors tests
$ docker exec test-coordinator coverage run manage.py test ./api
Creating test database for alias 'default'...
Found 20 test(s).
System check identified no issues (0 silenced).
....................
----------------------------------------------------------------------
Ran 20 tests in 0.265s

OK
Destroying test database for alias 'default'...
Trade pipeline tests
$ docker exec -it test-coordinator coverage run manage.py test
Found 70 test(s).
Creating test database for alias 'default'...
System check identified no issues (0 silenced).
.......................Could not fetch BTC prices from https://criptoya.com/api/btc: Expecting value: line 1 column 1 (char 0)
...Regtest network was already ready. Skipping initalization.
Updating order with new Locked bond from maker
2025-07-30 07:19:41.060094+00:00
{'num_active_invoices': 1, 'invoices': [{0: {'payment_hash': '964d189d74490fc56ff8392635061037859a978b04300ab38b937e8a07164bd4', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.15462398529052734}
..Updating order with new Locked bond from maker
2025-07-30 07:19:41.679300+00:00
{'num_active_invoices': 1, 'invoices': [{0: {'payment_hash': '7c241e499e7443b4a292f1b6c83219f44dbaa9a39190ff7cedde36fe3a4ec838', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.04590868949890137}
.Updating order with new Locked bond from maker
2025-07-30 07:19:42.276196+00:00
{'num_active_invoices': 1, 'invoices': [{0: {'payment_hash': '0ef8ddebf9bb5de9e28c38dd9281cd549711b585a8d11cb260abb0cee71f4685', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.05913424491882324}
.Updating order with new Locked bond from maker
2025-07-30 07:19:42.961207+00:00
{'num_active_invoices': 1, 'invoices': [{0: {'payment_hash': '6370132aa93b90f51a380c6eeb57131a8948742cfe8c53f29a78b51fcbbc7eb6', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.06721091270446777}
.Updating order with new Locked bond from maker
2025-07-30 07:19:43.926368+00:00
{'num_active_invoices': 1, 'invoices': [{0: {'payment_hash': 'c09a3c7649b47e8f329cac233cc0b9e80536485193d9fb2d9c8f0f7d43194da4', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.05881810188293457}
.Updating order with new Locked bond from maker
2025-07-30 07:19:44.571805+00:00
{'num_active_invoices': 1, 'invoices': [{0: {'payment_hash': '4c11b24e61bbea81239f80fa80dfcb7acf4e6a7e9be3ffb58b8801623e1cc398', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.06692171096801758}
.Updating order with new Locked bond from maker
2025-07-30 07:19:45.329932+00:00
{'num_active_invoices': 1, 'invoices': [{0: {'payment_hash': '613e91bbfb6147542991897bb56054ca91ca4cc7900b7b53e1cd658b0be43540', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.06500053405761719}
.Updating order with new Locked bond from maker
2025-07-30 07:19:46.277431+00:00
{'num_active_invoices': 1, 'invoices': [{0: {'payment_hash': '384383a583376cbc4b8ce1ed9a25accaa4c2e80ea6786880f3a0316a7be559a4', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.05920600891113281}
Updating order with new Locked bond from taker
2025-07-30 07:19:46.869093+00:00
{'num_active_invoices': 2, 'invoices': [{0: {'payment_hash': '756bc9fb5ed48d6cd959ce32c874a9fc994f2b44d9c36981e85aef6128786e12', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.06690311431884766}
Updating order with new Locked escrow
2025-07-30 07:19:47.244262+00:00
{'num_active_invoices': 2, 'invoices': [{1: {'payment_hash': '2292189266252658dd61651cad5ba8a92b0fadfec254beb7d3044003d66d3dfd', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.03919577598571777}
.Updating order with new Locked bond from maker
2025-07-30 07:19:49.220930+00:00
{'num_active_invoices': 1, 'invoices': [{0: {'payment_hash': 'bdaa4399d3cbec030806244261fe84e4ae3f9c3e2bc88f47c4f20180e16093a6', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.029011964797973633}
Updating order with new Locked bond from taker
2025-07-30 07:19:49.802834+00:00
{'num_active_invoices': 2, 'invoices': [{0: {'payment_hash': 'f80a4ef69d7f465881d8f51509831201574523d230eba0405ca0492463ee6605', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.10246706008911133}
Updating order with new Locked escrow
2025-07-30 07:19:50.148254+00:00
{'num_active_invoices': 2, 'invoices': [{1: {'payment_hash': '99877a22c403d8d0aca10f27e37d23358c39fdb27c5f31611c3094eff2a251b6', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.030922412872314453}
../usr/local/lib/python3.13/site-packages/django/db/models/fields/__init__.py:1665: RuntimeWarning: DateTimeField Order.expires_at received a naive datetime (2025-07-30 07:19:51.341183) while time zone support is active.
  warnings.warn(
2025-07-30 07:19:51.361564+00:00
{'num_expired_orders': 1, 'expired_orders': [{0: 'Order 11: BUY BTC for 84.0-201.7 USD was Waiting for maker bond'}], 'failed_order_expiry': [], 'reason_failure': []}
.Updating order with new Locked bond from maker
2025-07-30 07:19:51.895984+00:00
{'num_active_invoices': 1, 'invoices': [{0: {'payment_hash': '4eae778bdff711bdaa549b459963aa8134ee71aec3a824cb173db51687cb4613', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.061560869216918945}
Updating order with new Locked bond from taker
2025-07-30 07:19:52.481306+00:00
{'num_active_invoices': 2, 'invoices': [{0: {'payment_hash': '6c90e766e22e0afcca11f987325a1d1cde594c2bc3ce94c4be28fb051a430940', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.0718088150024414}
Updating order with new Locked escrow
2025-07-30 07:19:52.831470+00:00
{'num_active_invoices': 2, 'invoices': [{1: {'payment_hash': '838e79fd29b4d19ca096e6bc06f3b47bc2c54bcd67df6894d2264e192c3cc65a', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.021480083465576172}
Order: 12 IN_FLIGHT. Hash df327ce62ff4b1fc536f89df407269bc4663d5144d8164b06d48f1f1190bb013
Order: 12 IN_FLIGHT. Hash df327ce62ff4b1fc536f89df407269bc4663d5144d8164b06d48f1f1190bb013
Order: 12 SUCCEEDED. Hash: df327ce62ff4b1fc536f89df407269bc4663d5144d8164b06d48f1f1190bb013
/usr/local/lib/python3.13/site-packages/django/db/models/fields/__init__.py:1606: RuntimeWarning: DateTimeField LNPayment.created_at received a naive datetime (2025-07-30 00:00:00) while time zone support is active.
  warnings.warn(
/usr/local/lib/python3.13/site-packages/django/db/models/fields/__init__.py:1606: RuntimeWarning: DateTimeField LNPayment.created_at received a naive datetime (2025-07-31 00:00:00) while time zone support is active.
  warnings.warn(
/usr/local/lib/python3.13/site-packages/django/db/models/fields/__init__.py:1606: RuntimeWarning: DateTimeField OnchainPayment.created_at received a naive datetime (2025-07-30 00:00:00) while time zone support is active.
  warnings.warn(
/usr/local/lib/python3.13/site-packages/django/db/models/fields/__init__.py:1606: RuntimeWarning: DateTimeField OnchainPayment.created_at received a naive datetime (2025-07-31 00:00:00) while time zone support is active.
  warnings.warn(
/usr/local/lib/python3.13/site-packages/django/db/models/fields/__init__.py:1606: RuntimeWarning: DateTimeField MarketTick.timestamp received a naive datetime (2025-07-30 00:00:00) while time zone support is active.
  warnings.warn(
/usr/local/lib/python3.13/site-packages/django/db/models/fields/__init__.py:1606: RuntimeWarning: DateTimeField MarketTick.timestamp received a naive datetime (2025-07-31 00:00:00) while time zone support is active.
  warnings.warn(
/usr/local/lib/python3.13/site-packages/django/db/models/fields/__init__.py:1606: RuntimeWarning: DateTimeField AccountingDay.day received a naive datetime (2025-07-30 00:00:00) while time zone support is active.
  warnings.warn(
.Updating order with new Locked bond from maker
2025-07-30 07:19:54.292394+00:00
{'num_active_invoices': 1, 'invoices': [{0: {'payment_hash': 'a5ad25f1dffbc0ebbe37ed2ac8b2528e61027241b87b0356f27ee99eb3997986', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.055483102798461914}
Updating order with new Locked bond from taker
2025-07-30 07:19:54.912361+00:00
{'num_active_invoices': 2, 'invoices': [{0: {'payment_hash': '442149f7dc1850367fdb5c401f2d01a66de82ee360059a599986f18b9f5f27a2', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.08308839797973633}
Updating order with new Locked escrow
2025-07-30 07:19:55.255404+00:00
{'num_active_invoices': 2, 'invoices': [{1: {'payment_hash': 'fbcf4a44bdd6a8f5b79a886fa534fc3f86abdb2a3f9c941c75b2bdc9a98120f6', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.03847336769104004}
/usr/local/lib/python3.13/site-packages/django/db/models/fields/__init__.py:1665: RuntimeWarning: DateTimeField Order.expires_at received a naive datetime (2025-07-30 07:19:55.315263) while time zone support is active.
  warnings.warn(
2025-07-30 07:19:55.483501+00:00
{'num_expired_orders': 1, 'expired_orders': [{0: 'Order 13: BUY BTC for 100.0 USD was Waiting only for buyer invoice'}], 'failed_order_expiry': [], 'reason_failure': []}
2025-07-30 07:19:55.524439+00:00
{'num_expired_orders': 1, 'expired_orders': [{0: 'Order 13: BUY BTC for 100.0 USD was Waiting only for buyer invoice'}], 'failed_order_expiry': [], 'reason_failure': [], 'num_expired_take_orders': 1, 'expired_take_orders': [{0: 'Order 13 taken by Robot(30,UniformTownsman766) for 100.00000000 fiat units was expired'}], 'failed_take_order_expiry': [], 'reason_take_failure': []}
...Updating order with new Locked bond from maker
2025-07-30 07:19:56.344618+00:00
{'num_active_invoices': 1, 'invoices': [{0: {'payment_hash': '06839f7c31c8fcbcd524faddff0410411ff77e56879575ac35800da25db141a5', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.0578312873840332}
Updating order with new Locked bond from taker
2025-07-30 07:19:56.973967+00:00
{'num_active_invoices': 2, 'invoices': [{0: {'payment_hash': 'eeff7ae10d63252642fe7dc6beeeb53ea7729e9a0876e2dd16f90e6b9ae67e45', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.1266951560974121}
Updating order with new Locked escrow
2025-07-30 07:19:57.319169+00:00
{'num_active_invoices': 2, 'invoices': [{1: {'payment_hash': '50b725ac059e3b86fd49998fba4c1a15cd158cc428de6ef66cbf6fdf061faf7c', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.016948699951171875}
..Updating order with new Locked bond from maker
2025-07-30 07:19:58.633843+00:00
{'num_active_invoices': 1, 'invoices': [{0: {'payment_hash': '44d94d68be012eaca836906ed209b447a9015b7fdef5fc2333593bbd4cfca0d4', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.08616065979003906}
Updating order with new Locked bond from taker
2025-07-30 07:19:59.175745+00:00
{'num_active_invoices': 1, 'invoices': [{0: {'payment_hash': 'efcb586dbcce04697b55fd33fd77d93729b528325fa8266f70b66c7cf5608138', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.10148382186889648}
.Updating order with new Locked bond from maker
2025-07-30 07:19:59.957782+00:00
{'num_active_invoices': 1, 'invoices': [{0: {'payment_hash': '3a32dbd2ad8fa89d36c5dc914139e4255e52be3b33c429d28641379addefd414', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.07953977584838867}
Updating order with new Locked bond from taker
Expiring take_order because order was already taken
2025-07-30 07:20:00.893804+00:00
{'num_active_invoices': 2, 'invoices': [{0: {'payment_hash': '706a18b671965f415ef81233bab8cd2c3a0079800719016906079b68172fe270', 'old_status': 'Generated', 'new_status': 'Locked'}}, {1: {'payment_hash': 'a1844c72f43fec835ed8364e1a926be0618fe85b173d2e0f46b0de748742e6f2', 'old_status': 'Generated', 'new_status': 'Cancelled'}}], 'time': 0.13567495346069336}
.Updating order with new Locked bond from maker
2025-07-30 07:20:01.701746+00:00
{'num_active_invoices': 1, 'invoices': [{0: {'payment_hash': '06aa950a90007317671b41b017015975288cf4383fb31520a07e184c93aea8ec', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.07663464546203613}
.Updating order with new Locked bond from maker
2025-07-30 07:20:02.536164+00:00
{'num_active_invoices': 1, 'invoices': [{0: {'payment_hash': '1bd8f6f0597d800289ed1166ecd5819d22a43128e6018f86ab8112ca72552216', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.09809255599975586}
.Updating order with new Locked bond from maker
2025-07-30 07:20:03.481312+00:00
{'num_active_invoices': 1, 'invoices': [{0: {'payment_hash': 'b276a500ceb3f87b66ae4158200174bd4193bce647ee5b12ec507dde4b4752db', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.07957911491394043}
.Updating order with new Locked bond from maker
2025-07-30 07:20:04.239152+00:00
{'num_active_invoices': 1, 'invoices': [{0: {'payment_hash': 'a4858d41fbb5f9383a5049f7217fb238e8631428a61fd7c366335ca8a7d40143', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.03745126724243164}
...Updating order with new Locked bond from maker
2025-07-30 07:20:05.325431+00:00
{'num_active_invoices': 1, 'invoices': [{0: {'payment_hash': 'a602b5a9c50e7d91918146eb1d524e2dbfdd3f06b1a977afec2d7e13249c5fc0', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.06223440170288086}
Updating order with new Locked bond from taker
2025-07-30 07:20:05.968443+00:00
{'num_active_invoices': 2, 'invoices': [{0: {'payment_hash': '9f57debc866066316e28500ead1af601f2cbfdf7c631c79a59e2681058c9e35b', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.08230733871459961}
Updating order with new Locked escrow
2025-07-30 07:20:06.302451+00:00
{'num_active_invoices': 2, 'invoices': [{1: {'payment_hash': 'd62e6dc6f64aa00cc0e7739db5f4990f38c43b3d317588585b1c0cba37898525', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.0253751277923584}
/usr/local/lib/python3.13/site-packages/django/db/models/fields/__init__.py:1665: RuntimeWarning: DateTimeField Order.expires_at received a naive datetime (2025-07-30 07:20:08.058314) while time zone support is active.
  warnings.warn(
2025-07-30 07:20:08.987275+00:00
{'num_expired_orders': 1, 'expired_orders': [{0: 'Order 23: BUY BTC for 100.0 USD was Fiat sent - In chatroom'}], 'failed_order_expiry': [], 'reason_failure': []}
2025-07-30 07:20:09.006874+00:00
{'num_expired_orders': 1, 'expired_orders': [{0: 'Order 23: BUY BTC for 100.0 USD was Fiat sent - In chatroom'}], 'failed_order_expiry': [], 'reason_failure': [], 'num_expired_take_orders': 1, 'expired_take_orders': [{0: 'Order 23 taken by Robot(53,UniformTownsman766) for 100.00000000 fiat units was expired'}], 'failed_take_order_expiry': [], 'reason_take_failure': []}
.Updating order with new Locked bond from maker
2025-07-30 07:20:09.612295+00:00
{'num_active_invoices': 1, 'invoices': [{0: {'payment_hash': 'b9b37f332d4567450cd3fcdd117ce4d509a02318c5be748f299164628ae50c1b', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.06477522850036621}
Updating order with new Locked bond from taker
2025-07-30 07:20:10.291184+00:00
{'num_active_invoices': 2, 'invoices': [{0: {'payment_hash': 'e0238d0f291a6009237223b2568647d0b84c339276319d7392263441dbb6bf1b', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.13313961029052734}
Updating order with new Locked escrow
2025-07-30 07:20:10.647865+00:00
{'num_active_invoices': 2, 'invoices': [{1: {'payment_hash': 'b8abe8a428cc23b4be9c3308665d3678d2484c9e5829b4431a292e68b036edda', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.02039027214050293}
/usr/local/lib/python3.13/site-packages/django/db/models/fields/__init__.py:1665: RuntimeWarning: DateTimeField Order.expires_at received a naive datetime (2025-07-30 07:20:11.189951) while time zone support is active.
  warnings.warn(
2025-07-30 07:20:11.491011+00:00
{'num_expired_orders': 1, 'expired_orders': [{0: 'Order 24: BUY BTC for 100.0 USD was Sending fiat - In chatroom'}], 'failed_order_expiry': [], 'reason_failure': []}
2025-07-30 07:20:11.531409+00:00
{'num_expired_orders': 1, 'expired_orders': [{0: 'Order 24: BUY BTC for 100.0 USD was Sending fiat - In chatroom'}], 'failed_order_expiry': [], 'reason_failure': [], 'num_expired_take_orders': 1, 'expired_take_orders': [{0: 'Order 24 taken by Robot(56,UniformTownsman766) for 100.00000000 fiat units was expired'}], 'failed_take_order_expiry': [], 'reason_take_failure': []}
.Updating order with new Locked bond from maker
2025-07-30 07:20:12.179161+00:00
{'num_active_invoices': 1, 'invoices': [{0: {'payment_hash': '771ba0914355ac2b56e502e6b5d2a963ef1c7a01329800400b8ab323599f4319', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.07614588737487793}
Updating order with new Locked bond from taker
2025-07-30 07:20:12.822316+00:00
{'num_active_invoices': 2, 'invoices': [{0: {'payment_hash': '534d13cfe081023775c58dc59b3b62b063a5e4903017927a28692cab6879df9f', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.09399056434631348}
Updating order with new Locked escrow
2025-07-30 07:20:13.172151+00:00
{'num_active_invoices': 2, 'invoices': [{1: {'payment_hash': '5aaa8b6d9f18d6785e34993fa873980a8ffc630f4d49a9301f85b7a8922637dd', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.014827251434326172}
/usr/local/lib/python3.13/site-packages/django/db/models/fields/__init__.py:1665: RuntimeWarning: DateTimeField Order.expires_at received a naive datetime (2025-07-30 07:20:13.807205) while time zone support is active.
  warnings.warn(
2025-07-30 07:20:14.154340+00:00
{'num_expired_orders': 1, 'expired_orders': [{0: 'Order 25: BUY BTC for 100.0 USD was Sending fiat - In chatroom'}], 'failed_order_expiry': [], 'reason_failure': []}
2025-07-30 07:20:14.181580+00:00
{'num_expired_orders': 1, 'expired_orders': [{0: 'Order 25: BUY BTC for 100.0 USD was Sending fiat - In chatroom'}], 'failed_order_expiry': [], 'reason_failure': [], 'num_expired_take_orders': 1, 'expired_take_orders': [{0: 'Order 25 taken by Robot(59,UniformTownsman766) for 100.00000000 fiat units was expired'}], 'failed_take_order_expiry': [], 'reason_take_failure': []}
.Updating order with new Locked bond from maker
2025-07-30 07:20:14.781704+00:00
{'num_active_invoices': 1, 'invoices': [{0: {'payment_hash': '5e7595c512c0a6e555e92c97e7fb5c6dbf44a15e418a8b5f363d700d8fbce039', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.0743861198425293}
.Updating order with new Locked bond from maker
2025-07-30 07:20:15.518942+00:00
{'num_active_invoices': 1, 'invoices': [{0: {'payment_hash': '2c2496ca127fd97406b7b5aa8a00d6648fe4b550ccd9a50d37867fd95397c24d', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.06289887428283691}
/usr/local/lib/python3.13/site-packages/django/db/models/fields/__init__.py:1665: RuntimeWarning: DateTimeField Order.expires_at received a naive datetime (2025-07-30 07:20:15.568889) while time zone support is active.
  warnings.warn(
2025-07-30 07:20:15.663450+00:00
{'num_expired_orders': 1, 'expired_orders': [{0: 'Order 27: BUY BTC for 84.0-201.7 USD was Public'}], 'failed_order_expiry': [], 'reason_failure': []}
.Updating order with new Locked bond from maker
2025-07-30 07:20:16.224416+00:00
{'num_active_invoices': 1, 'invoices': [{0: {'payment_hash': '5c2792b357cfb1825f3422d10d711ad4b1e9ed05b6f577203d9bb02766b80d3b', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.058937788009643555}
.Updating order with new Locked bond from maker
2025-07-30 07:20:16.926008+00:00
{'num_active_invoices': 1, 'invoices': [{0: {'payment_hash': '27d133051714e8258d2a8f1389d6561fa55419b42c60ba70082237d95b5eda51', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.06093931198120117}
Updating order with new Locked bond from taker
2025-07-30 07:20:17.525126+00:00
{'num_active_invoices': 2, 'invoices': [{0: {'payment_hash': '2279a3446612f5ef398931d355421edb8b5b93daf7029aaebadeb9b5513f171d', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.06670880317687988}
Updating order with new Locked escrow
2025-07-30 07:20:17.913676+00:00
{'num_active_invoices': 2, 'invoices': [{1: {'payment_hash': 'b5fd12bb9f4c285bbfd649c4cb5386827c569cd69cefe22467db0940cb2ced1e', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.027482271194458008}
Mining 1 blocks
Waiting for robot node chain sync 0s.Updating order with new Locked bond from maker
2025-07-30 07:20:19.530300+00:00
{'num_active_invoices': 1, 'invoices': [{0: {'payment_hash': 'e38f43a17755e4436eaf1f851537b192d54135666d0c23ee2c96d879593d696f', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.08494830131530762}
Updating order with new Locked bond from taker
2025-07-30 07:20:20.225670+00:00
{'num_active_invoices': 2, 'invoices': [{0: {'payment_hash': '8c1d39a584597785292a3964c449181d3a92cb86d7a28a1b30b30485f051eee7', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.15244054794311523}
Updating order with new Locked escrow
2025-07-30 07:20:20.562207+00:00
{'num_active_invoices': 2, 'invoices': [{1: {'payment_hash': 'af395e545303713e0b82f35fa07952d94afc0eeda67b6dc735b6da4694aab9be', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.038658857345581055}
Order: 30 IN_FLIGHT. Hash b09bc596fcac62e7ba5028f0baa2dc83a9268319f731ccb9a7e6411e2ce69245
Order: 30 IN_FLIGHT. Hash b09bc596fcac62e7ba5028f0baa2dc83a9268319f731ccb9a7e6411e2ce69245
Order: 30 SUCCEEDED. Hash: b09bc596fcac62e7ba5028f0baa2dc83a9268319f731ccb9a7e6411e2ce69245
.Updating order with new Locked bond from maker
2025-07-30 07:20:21.984827+00:00
{'num_active_invoices': 1, 'invoices': [{0: {'payment_hash': 'e11c46d75ce13bc1f8b9e2aa0ddd0f33e17b66987f54e6ec739c77f9be5856e9', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.02304983139038086}
Updating order with new Locked bond from taker
2025-07-30 07:20:22.583172+00:00
{'num_active_invoices': 2, 'invoices': [{0: {'payment_hash': '7c399dcd028431e32c473a4c4ea09e7cde4e1147c6640d8801ab234445f5f775', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.0920109748840332}
Updating order with new Locked escrow
2025-07-30 07:20:22.915254+00:00
{'num_active_invoices': 2, 'invoices': [{1: {'payment_hash': 'e7d09c88af20b1747a048ca19a54a2a6f4fade7e0605ef42f24ba55cb39a22d0', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.013429403305053711}
Mining 1 blocks
.Updating order with new Locked bond from maker
2025-07-30 07:20:24.345571+00:00
{'num_active_invoices': 1, 'invoices': [{0: {'payment_hash': '3ea1a3e1a23e0a2ebdfab85755f1f63a69ebce0fd2a9f7315887cffed007d46c', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.05774831771850586}
Updating order with new Locked bond from taker
2025-07-30 07:20:25.061821+00:00
{'num_active_invoices': 2, 'invoices': [{0: {'payment_hash': 'd3a2d498205008dcee740d39c6a0d605ee39ef973169c1d0287ba60e69370d36', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.12076497077941895}
/usr/local/lib/python3.13/site-packages/django/db/models/fields/__init__.py:1665: RuntimeWarning: DateTimeField Order.expires_at received a naive datetime (2025-07-30 07:20:25.125358) while time zone support is active.
  warnings.warn(
/usr/local/lib/python3.13/site-packages/django/db/models/fields/__init__.py:1665: RuntimeWarning: DateTimeField TakeOrder.expires_at received a naive datetime (2025-07-30 07:20:25.138722) while time zone support is active.
  warnings.warn(
2025-07-30 07:20:25.208910+00:00
{'num_expired_orders': 1, 'expired_orders': [{0: 'Order 32: BUY BTC for 100.0 USD was Waiting for trade collateral and buyer invoice'}], 'failed_order_expiry': [], 'reason_failure': []}
2025-07-30 07:20:25.237822+00:00
{'num_expired_orders': 1, 'expired_orders': [{0: 'Order 32: BUY BTC for 100.0 USD was Waiting for trade collateral and buyer invoice'}], 'failed_order_expiry': [], 'reason_failure': [], 'num_expired_take_orders': 1, 'expired_take_orders': [{0: 'Order 32 taken by Robot(75,UniformTownsman766) for 100.00000000 fiat units was expired'}], 'failed_take_order_expiry': [], 'reason_take_failure': []}
.Updating order with new Locked bond from maker
2025-07-30 07:20:25.833249+00:00
{'num_active_invoices': 1, 'invoices': [{0: {'payment_hash': '1990f6915ad1c73eb48ca1f75c55e569682000ef43827c8c6e456dfa1e5780f3', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.05046725273132324}
Updating order with new Locked bond from taker
2025-07-30 07:20:26.466885+00:00
{'num_active_invoices': 2, 'invoices': [{0: {'payment_hash': '8015f02df849f19c32485616ec3e7071ef33838d17ed03c2297ca6487c5713eb', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.08586907386779785}
.Updating order with new Locked bond from maker
2025-07-30 07:20:27.217530+00:00
{'num_active_invoices': 1, 'invoices': [{0: {'payment_hash': 'a27eec10e7b3b97596ff701c00b55504c0d49247c98998fcb35a8ceed5bc8b00', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.044358253479003906}
Updating order with new Locked bond from taker
2025-07-30 07:20:27.899691+00:00
{'num_active_invoices': 2, 'invoices': [{0: {'payment_hash': 'd5c728440730742b3b53f6c4fb61b5e904c401ce5e0c25307f9eb5419aff26f7', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.10148382186889648}
Updating order with new Locked escrow
2025-07-30 07:20:28.236076+00:00
{'num_active_invoices': 2, 'invoices': [{1: {'payment_hash': 'e42fcff0b698a2d55d24bee47b781f95ed849ffb03a42762a0fb7ade500b67d1', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.024800777435302734}
.Updating order with new Locked bond from maker
2025-07-30 07:20:29.525697+00:00
{'num_active_invoices': 1, 'invoices': [{0: {'payment_hash': '29564b69c0b22c75050859b9c6c02a726697eff4ccdde3403b066a1d759e4dec', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.06961369514465332}
Updating order with new Locked bond from taker
2025-07-30 07:20:30.180396+00:00
{'num_active_invoices': 2, 'invoices': [{0: {'payment_hash': '0cb79c90d59a5bc029a191d64c74419f34831d572d6e06de7b06e14d68d64b35', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.10748004913330078}
Updating order with new Locked escrow
2025-07-30 07:20:30.549728+00:00
{'num_active_invoices': 2, 'invoices': [{1: {'payment_hash': '46c30efba8942742f5c3ccd4cff8c2a673b685425ec927622a73e64fdb213aad', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.026851177215576172}
.Updating order with new Locked bond from maker
2025-07-30 07:20:31.765452+00:00
{'num_active_invoices': 1, 'invoices': [{0: {'payment_hash': 'df0539a5b8d0d3e57457bbdee486aa0627d76a2aa10c9153f537302d7af3dada', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.060454607009887695}
Updating order with new Locked bond from taker
2025-07-30 07:20:32.429211+00:00
{'num_active_invoices': 2, 'invoices': [{0: {'payment_hash': 'c8ab53702a61c87236c2e66f54d307da67718cf19c8570d35985bfad71172881', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.10465741157531738}
Updating order with new Locked escrow
2025-07-30 07:20:32.792029+00:00
{'num_active_invoices': 2, 'invoices': [{1: {'payment_hash': 'd1ea0db46af951729811ff27d65f62ce78fdd736fc0ffe3cd988d96a772d0a86', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.02348613739013672}
.Updating order with new Locked bond from maker
2025-07-30 07:20:33.397161+00:00
{'num_active_invoices': 1, 'invoices': [{0: {'payment_hash': '794f085afae26b11427a3d3a7a01642e6aee5a1a23a3f7df0a9c8bbc90fc465c', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.08007025718688965}
Updating order with new Locked bond from taker
2025-07-30 07:20:34.088150+00:00
{'num_active_invoices': 2, 'invoices': [{0: {'payment_hash': '40ce2917c35fb6cbccf4ae4d0e0d00c05fdaab1f7fe5d4731dabc5b1e5ca6673', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.1492600440979004}
Updating order with new Locked escrow
2025-07-30 07:20:34.474641+00:00
{'num_active_invoices': 2, 'invoices': [{1: {'payment_hash': '06194daff7baac73b190402869b221affa88c37d493c030179064e6bdf1469dd', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.03227949142456055}
.Updating order with new Locked bond from maker
2025-07-30 07:20:35.634289+00:00
{'num_active_invoices': 1, 'invoices': [{0: {'payment_hash': 'ef697e0b0b8f5e401bbb27aa5d502a50213c09b48c0fdcd1def7033d4d0e66f1', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.02581048011779785}
Updating order with new Locked bond from taker
2025-07-30 07:20:36.296370+00:00
{'num_active_invoices': 2, 'invoices': [{0: {'payment_hash': '4971dde2a3e40a530d294aa87552943b30ea9a6974a120da74d99e6d7faabe4d', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.07874727249145508}
Updating order with new Locked escrow
2025-07-30 07:20:36.608238+00:00
{'num_active_invoices': 2, 'invoices': [{1: {'payment_hash': '681507033b4884ba9d2ba47d415c5c1e0acd7b0ed2aaff85fc4e43e16a8e0765', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.016633987426757812}
.Updating order with new Locked bond from maker
2025-07-30 07:20:37.773715+00:00
{'num_active_invoices': 1, 'invoices': [{0: {'payment_hash': '74cb26e824dbf0d0131b6f2542865a728cd7878e71bb7b2a647995876949a97c', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.050382375717163086}
Updating order with new Locked bond from taker
2025-07-30 07:20:38.420310+00:00
{'num_active_invoices': 2, 'invoices': [{0: {'payment_hash': '5e53accee0a2bf2bca1febb87733c96bfa64a906528f7127853d088e6f4558ee', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.08768200874328613}
.Updating order with new Locked bond from maker
2025-07-30 07:20:39.674014+00:00
{'num_active_invoices': 1, 'invoices': [{0: {'payment_hash': '03d66e0f4d8e3ca725e00f0ff546a0646640dca29789e2b4ca931bbf2bc6b15c', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.03747868537902832}
Updating order with new Locked bond from taker
2025-07-30 07:20:40.327795+00:00
{'num_active_invoices': 2, 'invoices': [{0: {'payment_hash': '9fae948add16ced1028aabba5a6d72d3e59e102b9e1d2de9a457922146c8efb7', 'old_status': 'Generated', 'new_status': 'Locked'}}], 'time': 0.08249044418334961}
.
----------------------------------------------------------------------
Ran 70 tests in 65.619s

OK
Destroying test database for alias 'default'...
GET /api/info/
root@bc63981f11b6:/usr/src/robosats# curl -s localhost:8000/api/info/ | jq
{
  "num_public_buy_orders": 0,
  "num_public_sell_orders": 0,
  "book_liquidity": 0,
  "active_robots_today": 0,
  "last_day_nonkyc_btc_premium": 0,
  "last_day_volume": 0,
  "lifetime_volume": 0,
  "lnd_version": "v0.17.0-beta",
  "cln_version": "Not installed",
  "robosats_running_commit_hash": "00000000000000000000 dev",
  "version": {
    "major": 0,
    "minor": 8,
    "patch": 1
  },
  "alternative_site": "RoboSatsy56bwqn56qyadmcxkx767hnabg4mihxlmgyt6if5gnuxvzad.onion/offers/",
  "alternative_name": "RoboSats Mainnet",
  "node_alias": "🤖RoboSats⚡(RoboDevs)",
  "node_id": "033b58d7......",
  "network": "testnet",
  "maker_fee": 0.00025,
  "taker_fee": 0.00175,
  "bond_size": 3,
  "market_price_apis": "https://blockchain.info/ticker, https://api.yadio.io/exrates/BTC, https://bitpay.com/rates/BTC, https://criptoya.com/api/btc",
  "notice_severity": "none",
  "notice_message": "",
  "min_order_size": 20000,
  "max_order_size": 500000,
  "swap_enabled": true,
  "max_swap": 1000000,
  "current_swap_fee_rate": 0
}
Get /api/robot/ with a token that is too short
root@bc63981f11b6:/usr/src/robosats# curl -s -H "Authorization: as" localhost:8000/api/robot/ | jq
{
  "error_code": 7000,
  "bad_request": "Robot token SHA256 was provided in the header. However it is not a valid 39 or 40 characters Base91 string."
}
Get /api/robot/ with an invalid token
root@bc63981f11b6:/usr/src/robosats# curl -s -H "Authorization: Token 1A0AB3275F0E02C462DD1926464C046B797F6FAA" localhost:8000/api/robot/ | jq
{
  "error_code": 7001,
  "bad_request": "On the first request to a RoboSats coordinator, you must provide as well a valid public and encrypted private PGP keys and a nostr pubkey"
}
Get /api/robot/ with no token
root@bc63981f11b6:/usr/src/robosats# curl -s localhost:8000/api/robot/ | jq
{
  "error_code": 7003,
  "bad_request": "Authentication credentials were not provided."
}

Checklist before merging

  • Install pre-commit and initialize it: pip install pre-commit, then pre-commit install. Pre-commit installs git hooks that automatically check the codebase. If pre-commit fails when you commit your changes, please fix the problems it points out.

Copy link
Member

@KoalaSat KoalaSat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huge improvement to the base code. Thank you so much!

Please accept a small tip for your work. Paste here a LN invoice with a long expiration date for 200,000 sats

@aftermath2
Copy link
Contributor Author

@KoalaSat Much appreciated!

lnbc2m1p5gk0vgsp5z3gyyj0dza4p5agdwpl7yf3yg2nf5lsvyx0d64hdkmvsttkgxpxspp57sq3cjhkda8veln2s4ldtulsc3nv6rqxuplyfl04fduvax3p4q7qhp5uwcvgs5clswpfxhm7nyfjmaeysn6us0yvjdexn9yjkv3k7zjhp2sxq9z0rgqcqpnrzjqfsktpgyjffp7jkg40vmmqygzg6yd5fx7eyv5d0xp7ypwlwpf88tyrd27sqqfksqqyqqqqqqqqqqhwqq2q9qxpqysgqs8l4xvjcl3qgaav20038a96hwe8mtyey2qhtgyu573lfg4mzj3ypc9r7ynlramsryp6euamzfwv5zrrvtzfej4l3ya860cgccsyyteqpyktjfz

@RobosatsDevFund
Copy link

a51666c65b251c69a2eee43f0aa1eaf8b710c6bd7e0f4d6a722bffafb6408028

Copy link
Member

@KoalaSat KoalaSat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got a misalignment with a couple of codes, can you fix it? :)

@aftermath2
Copy link
Contributor Author

I got a misalignment with a couple of codes, can you fix it? :)

Sure, fixed in e0796ee

@KoalaSat KoalaSat merged commit 5c20260 into RoboSats:main Aug 13, 2025
3 checks passed
@aftermath2 aftermath2 deleted the error_responses_codes branch August 13, 2025 10:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bad_request should also return an error code

3 participants