specter-desktop/tests/test_rest.py

212 lines
7.3 KiB
Python
Raw Permalink Normal View History

Feature: Api framework (#1232) * Included API end points Included 3 API end points: ###/api/specter ["GET"] Basic Specter info from app.specter class ###/api/full_txlist/ ["GET"] Full Transaction list for all wallets ###"/api/wallet_info/<wallet_alias>/ ["GET"] More detailed wallet info and transactions from the app.specter.wallet_manager class * Update src/cryptoadvance/specter/controller.py Include `wallet.check_unused()` Co-authored-by: benk10 <ben.kaufman10@gmail.com> * API Update Made a few changes: - Flattened the wallet list to be similar to full transaction list - included versioning on url `/v1alpha/` - Included `wallet.utxo` data - Improved `safe_serialize` for better json output Pending Updates: - Create a separate file for API (as a blueprint) - Explore using Flask-restful for improved authentication (downside is that it is another dependency - not sure if already a requirement for specter) * adding a rest-api * Implemented API end points inside of example.py * Merging with remote * Fixed API.md * Removing example-resources * migrating to focal due to cryptography needs newer pip * fix the image * black and tidy up * Deleted more useless stuff * first take for psbt (still broken) * get tests to work * fix devices_signed undefined * fix part2 * fix part 3 * fix part 4 * Rest Get-Requests for psbt working * fix part 5 * extending psbt_creator with json format * tests finished. bitcoind_regtest changed to scope session * speed up tests * fix tests * tiny test for LiquidRpc, probes improvements * try fixing testing-infra * kick * finally fix infra, hopefully * removing assertion * refactoring and fixing API * fix the rest-tests * fix last liquid failing test * polishing: error_handling via decorator * split-up docs * fix requirements.in * polishing REST-API * optimize startup for internal_nodes * Update src/cryptoadvance/specter/internal_node.py Co-authored-by: benk10 <ben.kaufman10@gmail.com> Co-authored-by: Alpha Zeta <40473443+pxsocs@users.noreply.github.com> Co-authored-by: benk10 <ben.kaufman10@gmail.com> Co-authored-by: Alpha Zeta <alphazeta@protonmail.com> Co-authored-by: Stepan Snigirev <snigirev.stepan@gmail.com>
2021-07-08 20:10:14 +02:00
import base64
UIUX: Overhaul of UTXO list, handling of locked UTXOs and scrollbar added to tx-table web component (#1580) * Added tests/bitcoin to gitignore * Ensure locked UTXO can't be used for transactions, fix rounding error in coin selection, fix styling/text in general settings. * overhaul of checkbox logic in utxolist including mouseover event for checkboxes, manage psbt button action added, icon info popups added,design changes in utxo- and txlist to make the display quieter * change of balance display, scrollbars for main and tx table, bugfixes (pagination, coin selection, unsigned labeling) & some styling finetuning * deleted locked utxo balance calculations, added doc strings regarding balances * jinja comment added in tx table, making scrollbar less vivid, tx table settings changed to no compact view toggle and scrollbar on by default * more granular amount properties, little test fix. * applying new amount properties to the frontend and other parts of the code & improving balance display design * refactored a_simple_wallet to be only used in test_rest once * tests for amounts and test performance optimisations. * fix spec_node_configured * fix spec_wallet_send.js * fix spec_wallet_utxo.js * keep action teaser div hidden on wallets overview. * minor bug fix in tx-table, added includeShadowDom to cypress.json, adapted spec_wallet_utxo.js to new utxo list logic and added tests of new functionality to it. * fix spec_plugins.js and switch back to includeShadowDom false The problem with true is, that you are no longer able to spot when you need to apply the workaround described in https://docs.cypress.io/api/commands/shadow#Known-Issue as you only need to apply in a shadow-DOM. Feel free to switch it back in any test you see fit. Cypress.config('includeShadowDom',true) * better organisation of wallet utxo spec file * some wait-tweaks to cypress tests to make them run smoother on cirrus, note: cypress tests green in local dev. * longer wait in spec_elm_multi_segwit_wallet.js * fixing spec_elm_multi_segwit_wallet.js * more checks whether checkboxes get selected and additional waits for cirrus in spec_wallet_utxo.js. Co-authored-by: Kim Neunert <k9ert@gmx.de>
2022-04-08 11:07:01 +02:00
import json
Feature: Api framework (#1232) * Included API end points Included 3 API end points: ###/api/specter ["GET"] Basic Specter info from app.specter class ###/api/full_txlist/ ["GET"] Full Transaction list for all wallets ###"/api/wallet_info/<wallet_alias>/ ["GET"] More detailed wallet info and transactions from the app.specter.wallet_manager class * Update src/cryptoadvance/specter/controller.py Include `wallet.check_unused()` Co-authored-by: benk10 <ben.kaufman10@gmail.com> * API Update Made a few changes: - Flattened the wallet list to be similar to full transaction list - included versioning on url `/v1alpha/` - Included `wallet.utxo` data - Improved `safe_serialize` for better json output Pending Updates: - Create a separate file for API (as a blueprint) - Explore using Flask-restful for improved authentication (downside is that it is another dependency - not sure if already a requirement for specter) * adding a rest-api * Implemented API end points inside of example.py * Merging with remote * Fixed API.md * Removing example-resources * migrating to focal due to cryptography needs newer pip * fix the image * black and tidy up * Deleted more useless stuff * first take for psbt (still broken) * get tests to work * fix devices_signed undefined * fix part2 * fix part 3 * fix part 4 * Rest Get-Requests for psbt working * fix part 5 * extending psbt_creator with json format * tests finished. bitcoind_regtest changed to scope session * speed up tests * fix tests * tiny test for LiquidRpc, probes improvements * try fixing testing-infra * kick * finally fix infra, hopefully * removing assertion * refactoring and fixing API * fix the rest-tests * fix last liquid failing test * polishing: error_handling via decorator * split-up docs * fix requirements.in * polishing REST-API * optimize startup for internal_nodes * Update src/cryptoadvance/specter/internal_node.py Co-authored-by: benk10 <ben.kaufman10@gmail.com> Co-authored-by: Alpha Zeta <40473443+pxsocs@users.noreply.github.com> Co-authored-by: benk10 <ben.kaufman10@gmail.com> Co-authored-by: Alpha Zeta <alphazeta@protonmail.com> Co-authored-by: Stepan Snigirev <snigirev.stepan@gmail.com>
2021-07-08 20:10:14 +02:00
import logging
from numbers import Number
import jwt
UIUX: Overhaul of UTXO list, handling of locked UTXOs and scrollbar added to tx-table web component (#1580) * Added tests/bitcoin to gitignore * Ensure locked UTXO can't be used for transactions, fix rounding error in coin selection, fix styling/text in general settings. * overhaul of checkbox logic in utxolist including mouseover event for checkboxes, manage psbt button action added, icon info popups added,design changes in utxo- and txlist to make the display quieter * change of balance display, scrollbars for main and tx table, bugfixes (pagination, coin selection, unsigned labeling) & some styling finetuning * deleted locked utxo balance calculations, added doc strings regarding balances * jinja comment added in tx table, making scrollbar less vivid, tx table settings changed to no compact view toggle and scrollbar on by default * more granular amount properties, little test fix. * applying new amount properties to the frontend and other parts of the code & improving balance display design * refactored a_simple_wallet to be only used in test_rest once * tests for amounts and test performance optimisations. * fix spec_node_configured * fix spec_wallet_send.js * fix spec_wallet_utxo.js * keep action teaser div hidden on wallets overview. * minor bug fix in tx-table, added includeShadowDom to cypress.json, adapted spec_wallet_utxo.js to new utxo list logic and added tests of new functionality to it. * fix spec_plugins.js and switch back to includeShadowDom false The problem with true is, that you are no longer able to spot when you need to apply the workaround described in https://docs.cypress.io/api/commands/shadow#Known-Issue as you only need to apply in a shadow-DOM. Feel free to switch it back in any test you see fit. Cypress.config('includeShadowDom',true) * better organisation of wallet utxo spec file * some wait-tweaks to cypress tests to make them run smoother on cirrus, note: cypress tests green in local dev. * longer wait in spec_elm_multi_segwit_wallet.js * fixing spec_elm_multi_segwit_wallet.js * more checks whether checkboxes get selected and additional waits for cirrus in spec_wallet_utxo.js. Co-authored-by: Kim Neunert <k9ert@gmx.de>
2022-04-08 11:07:01 +02:00
import pytest
import datetime
import random
from flask import current_app as app
UIUX: Overhaul of UTXO list, handling of locked UTXOs and scrollbar added to tx-table web component (#1580) * Added tests/bitcoin to gitignore * Ensure locked UTXO can't be used for transactions, fix rounding error in coin selection, fix styling/text in general settings. * overhaul of checkbox logic in utxolist including mouseover event for checkboxes, manage psbt button action added, icon info popups added,design changes in utxo- and txlist to make the display quieter * change of balance display, scrollbars for main and tx table, bugfixes (pagination, coin selection, unsigned labeling) & some styling finetuning * deleted locked utxo balance calculations, added doc strings regarding balances * jinja comment added in tx table, making scrollbar less vivid, tx table settings changed to no compact view toggle and scrollbar on by default * more granular amount properties, little test fix. * applying new amount properties to the frontend and other parts of the code & improving balance display design * refactored a_simple_wallet to be only used in test_rest once * tests for amounts and test performance optimisations. * fix spec_node_configured * fix spec_wallet_send.js * fix spec_wallet_utxo.js * keep action teaser div hidden on wallets overview. * minor bug fix in tx-table, added includeShadowDom to cypress.json, adapted spec_wallet_utxo.js to new utxo list logic and added tests of new functionality to it. * fix spec_plugins.js and switch back to includeShadowDom false The problem with true is, that you are no longer able to spot when you need to apply the workaround described in https://docs.cypress.io/api/commands/shadow#Known-Issue as you only need to apply in a shadow-DOM. Feel free to switch it back in any test you see fit. Cypress.config('includeShadowDom',true) * better organisation of wallet utxo spec file * some wait-tweaks to cypress tests to make them run smoother on cirrus, note: cypress tests green in local dev. * longer wait in spec_elm_multi_segwit_wallet.js * fixing spec_elm_multi_segwit_wallet.js * more checks whether checkboxes get selected and additional waits for cirrus in spec_wallet_utxo.js. Co-authored-by: Kim Neunert <k9ert@gmx.de>
2022-04-08 11:07:01 +02:00
from cryptoadvance.specter.managers.device_manager import DeviceManager
from cryptoadvance.specter.specter import Specter
from cryptoadvance.specter.specter_error import SpecterError
from cryptoadvance.specter.util.wallet_importer import WalletImporter
from cryptoadvance.specter.user import User
UIUX: Overhaul of UTXO list, handling of locked UTXOs and scrollbar added to tx-table web component (#1580) * Added tests/bitcoin to gitignore * Ensure locked UTXO can't be used for transactions, fix rounding error in coin selection, fix styling/text in general settings. * overhaul of checkbox logic in utxolist including mouseover event for checkboxes, manage psbt button action added, icon info popups added,design changes in utxo- and txlist to make the display quieter * change of balance display, scrollbars for main and tx table, bugfixes (pagination, coin selection, unsigned labeling) & some styling finetuning * deleted locked utxo balance calculations, added doc strings regarding balances * jinja comment added in tx table, making scrollbar less vivid, tx table settings changed to no compact view toggle and scrollbar on by default * more granular amount properties, little test fix. * applying new amount properties to the frontend and other parts of the code & improving balance display design * refactored a_simple_wallet to be only used in test_rest once * tests for amounts and test performance optimisations. * fix spec_node_configured * fix spec_wallet_send.js * fix spec_wallet_utxo.js * keep action teaser div hidden on wallets overview. * minor bug fix in tx-table, added includeShadowDom to cypress.json, adapted spec_wallet_utxo.js to new utxo list logic and added tests of new functionality to it. * fix spec_plugins.js and switch back to includeShadowDom false The problem with true is, that you are no longer able to spot when you need to apply the workaround described in https://docs.cypress.io/api/commands/shadow#Known-Issue as you only need to apply in a shadow-DOM. Feel free to switch it back in any test you see fit. Cypress.config('includeShadowDom',true) * better organisation of wallet utxo spec file * some wait-tweaks to cypress tests to make them run smoother on cirrus, note: cypress tests green in local dev. * longer wait in spec_elm_multi_segwit_wallet.js * fixing spec_elm_multi_segwit_wallet.js * more checks whether checkboxes get selected and additional waits for cirrus in spec_wallet_utxo.js. Co-authored-by: Kim Neunert <k9ert@gmx.de>
2022-04-08 11:07:01 +02:00
logger = logging.getLogger(__name__)
def create_registered_jwt_token(specter, username):
user = specter.user_manager.get_user_by_username(username)
jwt_token_id = User.generate_token_id()
jwt_token_life = 3600
jwt_token = User.generate_jwt_token(
username, jwt_token_id, "test token", jwt_token_life
)
user.add_jwt_token(jwt_token_id, jwt_token, "test token", jwt_token_life)
return jwt_token
def almost_equal(a: Number, b: Number, precision: float = 0.01) -> bool:
"""
Checks if a and b are not very different.
Default precision is 1%
"""
if a == b:
return True
diff = 2 * (a - b) / (a + b)
return (diff < precision) and (diff > -precision)
Feature: Api framework (#1232) * Included API end points Included 3 API end points: ###/api/specter ["GET"] Basic Specter info from app.specter class ###/api/full_txlist/ ["GET"] Full Transaction list for all wallets ###"/api/wallet_info/<wallet_alias>/ ["GET"] More detailed wallet info and transactions from the app.specter.wallet_manager class * Update src/cryptoadvance/specter/controller.py Include `wallet.check_unused()` Co-authored-by: benk10 <ben.kaufman10@gmail.com> * API Update Made a few changes: - Flattened the wallet list to be similar to full transaction list - included versioning on url `/v1alpha/` - Included `wallet.utxo` data - Improved `safe_serialize` for better json output Pending Updates: - Create a separate file for API (as a blueprint) - Explore using Flask-restful for improved authentication (downside is that it is another dependency - not sure if already a requirement for specter) * adding a rest-api * Implemented API end points inside of example.py * Merging with remote * Fixed API.md * Removing example-resources * migrating to focal due to cryptography needs newer pip * fix the image * black and tidy up * Deleted more useless stuff * first take for psbt (still broken) * get tests to work * fix devices_signed undefined * fix part2 * fix part 3 * fix part 4 * Rest Get-Requests for psbt working * fix part 5 * extending psbt_creator with json format * tests finished. bitcoind_regtest changed to scope session * speed up tests * fix tests * tiny test for LiquidRpc, probes improvements * try fixing testing-infra * kick * finally fix infra, hopefully * removing assertion * refactoring and fixing API * fix the rest-tests * fix last liquid failing test * polishing: error_handling via decorator * split-up docs * fix requirements.in * polishing REST-API * optimize startup for internal_nodes * Update src/cryptoadvance/specter/internal_node.py Co-authored-by: benk10 <ben.kaufman10@gmail.com> Co-authored-by: Alpha Zeta <40473443+pxsocs@users.noreply.github.com> Co-authored-by: benk10 <ben.kaufman10@gmail.com> Co-authored-by: Alpha Zeta <alphazeta@protonmail.com> Co-authored-by: Stepan Snigirev <snigirev.stepan@gmail.com>
2021-07-08 20:10:14 +02:00
UIUX: Overhaul of UTXO list, handling of locked UTXOs and scrollbar added to tx-table web component (#1580) * Added tests/bitcoin to gitignore * Ensure locked UTXO can't be used for transactions, fix rounding error in coin selection, fix styling/text in general settings. * overhaul of checkbox logic in utxolist including mouseover event for checkboxes, manage psbt button action added, icon info popups added,design changes in utxo- and txlist to make the display quieter * change of balance display, scrollbars for main and tx table, bugfixes (pagination, coin selection, unsigned labeling) & some styling finetuning * deleted locked utxo balance calculations, added doc strings regarding balances * jinja comment added in tx table, making scrollbar less vivid, tx table settings changed to no compact view toggle and scrollbar on by default * more granular amount properties, little test fix. * applying new amount properties to the frontend and other parts of the code & improving balance display design * refactored a_simple_wallet to be only used in test_rest once * tests for amounts and test performance optimisations. * fix spec_node_configured * fix spec_wallet_send.js * fix spec_wallet_utxo.js * keep action teaser div hidden on wallets overview. * minor bug fix in tx-table, added includeShadowDom to cypress.json, adapted spec_wallet_utxo.js to new utxo list logic and added tests of new functionality to it. * fix spec_plugins.js and switch back to includeShadowDom false The problem with true is, that you are no longer able to spot when you need to apply the workaround described in https://docs.cypress.io/api/commands/shadow#Known-Issue as you only need to apply in a shadow-DOM. Feel free to switch it back in any test you see fit. Cypress.config('includeShadowDom',true) * better organisation of wallet utxo spec file * some wait-tweaks to cypress tests to make them run smoother on cirrus, note: cypress tests green in local dev. * longer wait in spec_elm_multi_segwit_wallet.js * fixing spec_elm_multi_segwit_wallet.js * more checks whether checkboxes get selected and additional waits for cirrus in spec_wallet_utxo.js. Co-authored-by: Kim Neunert <k9ert@gmx.de>
2022-04-08 11:07:01 +02:00
def test_rr_psbt_get(client, specter_regtest_configured, bitcoin_regtest, caplog):
create_a_simple_wallet(specter_regtest_configured, bitcoin_regtest)
assert (
specter_regtest_configured.config["testing"]["allow_threading_for_testing"]
== False
) # Tests fail with threading
Feature: Api framework (#1232) * Included API end points Included 3 API end points: ###/api/specter ["GET"] Basic Specter info from app.specter class ###/api/full_txlist/ ["GET"] Full Transaction list for all wallets ###"/api/wallet_info/<wallet_alias>/ ["GET"] More detailed wallet info and transactions from the app.specter.wallet_manager class * Update src/cryptoadvance/specter/controller.py Include `wallet.check_unused()` Co-authored-by: benk10 <ben.kaufman10@gmail.com> * API Update Made a few changes: - Flattened the wallet list to be similar to full transaction list - included versioning on url `/v1alpha/` - Included `wallet.utxo` data - Improved `safe_serialize` for better json output Pending Updates: - Create a separate file for API (as a blueprint) - Explore using Flask-restful for improved authentication (downside is that it is another dependency - not sure if already a requirement for specter) * adding a rest-api * Implemented API end points inside of example.py * Merging with remote * Fixed API.md * Removing example-resources * migrating to focal due to cryptography needs newer pip * fix the image * black and tidy up * Deleted more useless stuff * first take for psbt (still broken) * get tests to work * fix devices_signed undefined * fix part2 * fix part 3 * fix part 4 * Rest Get-Requests for psbt working * fix part 5 * extending psbt_creator with json format * tests finished. bitcoind_regtest changed to scope session * speed up tests * fix tests * tiny test for LiquidRpc, probes improvements * try fixing testing-infra * kick * finally fix infra, hopefully * removing assertion * refactoring and fixing API * fix the rest-tests * fix last liquid failing test * polishing: error_handling via decorator * split-up docs * fix requirements.in * polishing REST-API * optimize startup for internal_nodes * Update src/cryptoadvance/specter/internal_node.py Co-authored-by: benk10 <ben.kaufman10@gmail.com> Co-authored-by: Alpha Zeta <40473443+pxsocs@users.noreply.github.com> Co-authored-by: benk10 <ben.kaufman10@gmail.com> Co-authored-by: Alpha Zeta <alphazeta@protonmail.com> Co-authored-by: Stepan Snigirev <snigirev.stepan@gmail.com>
2021-07-08 20:10:14 +02:00
caplog.set_level(logging.DEBUG)
""" testing the registration """
# Unauthorized
result = client.get("/api/v1alpha/wallets/some_wallet/psbt", follow_redirects=True)
assert result.status_code == 401
assert json.loads(result.data)["message"].startswith(
"The server could not verify that you are authorized to access the URL requested."
)
# Wrong token
headers = {"Authorization": "Bearer " + "sometoken"}
Feature: Api framework (#1232) * Included API end points Included 3 API end points: ###/api/specter ["GET"] Basic Specter info from app.specter class ###/api/full_txlist/ ["GET"] Full Transaction list for all wallets ###"/api/wallet_info/<wallet_alias>/ ["GET"] More detailed wallet info and transactions from the app.specter.wallet_manager class * Update src/cryptoadvance/specter/controller.py Include `wallet.check_unused()` Co-authored-by: benk10 <ben.kaufman10@gmail.com> * API Update Made a few changes: - Flattened the wallet list to be similar to full transaction list - included versioning on url `/v1alpha/` - Included `wallet.utxo` data - Improved `safe_serialize` for better json output Pending Updates: - Create a separate file for API (as a blueprint) - Explore using Flask-restful for improved authentication (downside is that it is another dependency - not sure if already a requirement for specter) * adding a rest-api * Implemented API end points inside of example.py * Merging with remote * Fixed API.md * Removing example-resources * migrating to focal due to cryptography needs newer pip * fix the image * black and tidy up * Deleted more useless stuff * first take for psbt (still broken) * get tests to work * fix devices_signed undefined * fix part2 * fix part 3 * fix part 4 * Rest Get-Requests for psbt working * fix part 5 * extending psbt_creator with json format * tests finished. bitcoind_regtest changed to scope session * speed up tests * fix tests * tiny test for LiquidRpc, probes improvements * try fixing testing-infra * kick * finally fix infra, hopefully * removing assertion * refactoring and fixing API * fix the rest-tests * fix last liquid failing test * polishing: error_handling via decorator * split-up docs * fix requirements.in * polishing REST-API * optimize startup for internal_nodes * Update src/cryptoadvance/specter/internal_node.py Co-authored-by: benk10 <ben.kaufman10@gmail.com> Co-authored-by: Alpha Zeta <40473443+pxsocs@users.noreply.github.com> Co-authored-by: benk10 <ben.kaufman10@gmail.com> Co-authored-by: Alpha Zeta <alphazeta@protonmail.com> Co-authored-by: Stepan Snigirev <snigirev.stepan@gmail.com>
2021-07-08 20:10:14 +02:00
result = client.get(
"/api/v1alpha/wallets/a_simple_wallet/psbt",
follow_redirects=True,
headers=headers,
Feature: Api framework (#1232) * Included API end points Included 3 API end points: ###/api/specter ["GET"] Basic Specter info from app.specter class ###/api/full_txlist/ ["GET"] Full Transaction list for all wallets ###"/api/wallet_info/<wallet_alias>/ ["GET"] More detailed wallet info and transactions from the app.specter.wallet_manager class * Update src/cryptoadvance/specter/controller.py Include `wallet.check_unused()` Co-authored-by: benk10 <ben.kaufman10@gmail.com> * API Update Made a few changes: - Flattened the wallet list to be similar to full transaction list - included versioning on url `/v1alpha/` - Included `wallet.utxo` data - Improved `safe_serialize` for better json output Pending Updates: - Create a separate file for API (as a blueprint) - Explore using Flask-restful for improved authentication (downside is that it is another dependency - not sure if already a requirement for specter) * adding a rest-api * Implemented API end points inside of example.py * Merging with remote * Fixed API.md * Removing example-resources * migrating to focal due to cryptography needs newer pip * fix the image * black and tidy up * Deleted more useless stuff * first take for psbt (still broken) * get tests to work * fix devices_signed undefined * fix part2 * fix part 3 * fix part 4 * Rest Get-Requests for psbt working * fix part 5 * extending psbt_creator with json format * tests finished. bitcoind_regtest changed to scope session * speed up tests * fix tests * tiny test for LiquidRpc, probes improvements * try fixing testing-infra * kick * finally fix infra, hopefully * removing assertion * refactoring and fixing API * fix the rest-tests * fix last liquid failing test * polishing: error_handling via decorator * split-up docs * fix requirements.in * polishing REST-API * optimize startup for internal_nodes * Update src/cryptoadvance/specter/internal_node.py Co-authored-by: benk10 <ben.kaufman10@gmail.com> Co-authored-by: Alpha Zeta <40473443+pxsocs@users.noreply.github.com> Co-authored-by: benk10 <ben.kaufman10@gmail.com> Co-authored-by: Alpha Zeta <alphazeta@protonmail.com> Co-authored-by: Stepan Snigirev <snigirev.stepan@gmail.com>
2021-07-08 20:10:14 +02:00
)
assert result.status_code == 401
assert json.loads(result.data)["message"].startswith(
"The server could not verify that you are authorized to access the URL requested."
)
# Admin but not authorized (admin is NOT allowed to read everything)
headers = {
"Authorization": "Bearer "
+ create_registered_jwt_token(specter_regtest_configured, "admin")
Feature: Api framework (#1232) * Included API end points Included 3 API end points: ###/api/specter ["GET"] Basic Specter info from app.specter class ###/api/full_txlist/ ["GET"] Full Transaction list for all wallets ###"/api/wallet_info/<wallet_alias>/ ["GET"] More detailed wallet info and transactions from the app.specter.wallet_manager class * Update src/cryptoadvance/specter/controller.py Include `wallet.check_unused()` Co-authored-by: benk10 <ben.kaufman10@gmail.com> * API Update Made a few changes: - Flattened the wallet list to be similar to full transaction list - included versioning on url `/v1alpha/` - Included `wallet.utxo` data - Improved `safe_serialize` for better json output Pending Updates: - Create a separate file for API (as a blueprint) - Explore using Flask-restful for improved authentication (downside is that it is another dependency - not sure if already a requirement for specter) * adding a rest-api * Implemented API end points inside of example.py * Merging with remote * Fixed API.md * Removing example-resources * migrating to focal due to cryptography needs newer pip * fix the image * black and tidy up * Deleted more useless stuff * first take for psbt (still broken) * get tests to work * fix devices_signed undefined * fix part2 * fix part 3 * fix part 4 * Rest Get-Requests for psbt working * fix part 5 * extending psbt_creator with json format * tests finished. bitcoind_regtest changed to scope session * speed up tests * fix tests * tiny test for LiquidRpc, probes improvements * try fixing testing-infra * kick * finally fix infra, hopefully * removing assertion * refactoring and fixing API * fix the rest-tests * fix last liquid failing test * polishing: error_handling via decorator * split-up docs * fix requirements.in * polishing REST-API * optimize startup for internal_nodes * Update src/cryptoadvance/specter/internal_node.py Co-authored-by: benk10 <ben.kaufman10@gmail.com> Co-authored-by: Alpha Zeta <40473443+pxsocs@users.noreply.github.com> Co-authored-by: benk10 <ben.kaufman10@gmail.com> Co-authored-by: Alpha Zeta <alphazeta@protonmail.com> Co-authored-by: Stepan Snigirev <snigirev.stepan@gmail.com>
2021-07-08 20:10:14 +02:00
}
result = client.get(
"/api/v1alpha/wallets/a_simple_wallet/psbt",
follow_redirects=True,
headers=headers,
Feature: Api framework (#1232) * Included API end points Included 3 API end points: ###/api/specter ["GET"] Basic Specter info from app.specter class ###/api/full_txlist/ ["GET"] Full Transaction list for all wallets ###"/api/wallet_info/<wallet_alias>/ ["GET"] More detailed wallet info and transactions from the app.specter.wallet_manager class * Update src/cryptoadvance/specter/controller.py Include `wallet.check_unused()` Co-authored-by: benk10 <ben.kaufman10@gmail.com> * API Update Made a few changes: - Flattened the wallet list to be similar to full transaction list - included versioning on url `/v1alpha/` - Included `wallet.utxo` data - Improved `safe_serialize` for better json output Pending Updates: - Create a separate file for API (as a blueprint) - Explore using Flask-restful for improved authentication (downside is that it is another dependency - not sure if already a requirement for specter) * adding a rest-api * Implemented API end points inside of example.py * Merging with remote * Fixed API.md * Removing example-resources * migrating to focal due to cryptography needs newer pip * fix the image * black and tidy up * Deleted more useless stuff * first take for psbt (still broken) * get tests to work * fix devices_signed undefined * fix part2 * fix part 3 * fix part 4 * Rest Get-Requests for psbt working * fix part 5 * extending psbt_creator with json format * tests finished. bitcoind_regtest changed to scope session * speed up tests * fix tests * tiny test for LiquidRpc, probes improvements * try fixing testing-infra * kick * finally fix infra, hopefully * removing assertion * refactoring and fixing API * fix the rest-tests * fix last liquid failing test * polishing: error_handling via decorator * split-up docs * fix requirements.in * polishing REST-API * optimize startup for internal_nodes * Update src/cryptoadvance/specter/internal_node.py Co-authored-by: benk10 <ben.kaufman10@gmail.com> Co-authored-by: Alpha Zeta <40473443+pxsocs@users.noreply.github.com> Co-authored-by: benk10 <ben.kaufman10@gmail.com> Co-authored-by: Alpha Zeta <alphazeta@protonmail.com> Co-authored-by: Stepan Snigirev <snigirev.stepan@gmail.com>
2021-07-08 20:10:14 +02:00
)
assert result.status_code == 403
assert (
json.loads(result.data)["message"]
== "The wallet does not belong to the user in the request."
)
Feature: Api framework (#1232) * Included API end points Included 3 API end points: ###/api/specter ["GET"] Basic Specter info from app.specter class ###/api/full_txlist/ ["GET"] Full Transaction list for all wallets ###"/api/wallet_info/<wallet_alias>/ ["GET"] More detailed wallet info and transactions from the app.specter.wallet_manager class * Update src/cryptoadvance/specter/controller.py Include `wallet.check_unused()` Co-authored-by: benk10 <ben.kaufman10@gmail.com> * API Update Made a few changes: - Flattened the wallet list to be similar to full transaction list - included versioning on url `/v1alpha/` - Included `wallet.utxo` data - Improved `safe_serialize` for better json output Pending Updates: - Create a separate file for API (as a blueprint) - Explore using Flask-restful for improved authentication (downside is that it is another dependency - not sure if already a requirement for specter) * adding a rest-api * Implemented API end points inside of example.py * Merging with remote * Fixed API.md * Removing example-resources * migrating to focal due to cryptography needs newer pip * fix the image * black and tidy up * Deleted more useless stuff * first take for psbt (still broken) * get tests to work * fix devices_signed undefined * fix part2 * fix part 3 * fix part 4 * Rest Get-Requests for psbt working * fix part 5 * extending psbt_creator with json format * tests finished. bitcoind_regtest changed to scope session * speed up tests * fix tests * tiny test for LiquidRpc, probes improvements * try fixing testing-infra * kick * finally fix infra, hopefully * removing assertion * refactoring and fixing API * fix the rest-tests * fix last liquid failing test * polishing: error_handling via decorator * split-up docs * fix requirements.in * polishing REST-API * optimize startup for internal_nodes * Update src/cryptoadvance/specter/internal_node.py Co-authored-by: benk10 <ben.kaufman10@gmail.com> Co-authored-by: Alpha Zeta <40473443+pxsocs@users.noreply.github.com> Co-authored-by: benk10 <ben.kaufman10@gmail.com> Co-authored-by: Alpha Zeta <alphazeta@protonmail.com> Co-authored-by: Stepan Snigirev <snigirev.stepan@gmail.com>
2021-07-08 20:10:14 +02:00
# Proper authorized (the wallet is owned by someuser)
headers = {
"Authorization": "Bearer "
+ create_registered_jwt_token(specter_regtest_configured, "someuser")
Feature: Api framework (#1232) * Included API end points Included 3 API end points: ###/api/specter ["GET"] Basic Specter info from app.specter class ###/api/full_txlist/ ["GET"] Full Transaction list for all wallets ###"/api/wallet_info/<wallet_alias>/ ["GET"] More detailed wallet info and transactions from the app.specter.wallet_manager class * Update src/cryptoadvance/specter/controller.py Include `wallet.check_unused()` Co-authored-by: benk10 <ben.kaufman10@gmail.com> * API Update Made a few changes: - Flattened the wallet list to be similar to full transaction list - included versioning on url `/v1alpha/` - Included `wallet.utxo` data - Improved `safe_serialize` for better json output Pending Updates: - Create a separate file for API (as a blueprint) - Explore using Flask-restful for improved authentication (downside is that it is another dependency - not sure if already a requirement for specter) * adding a rest-api * Implemented API end points inside of example.py * Merging with remote * Fixed API.md * Removing example-resources * migrating to focal due to cryptography needs newer pip * fix the image * black and tidy up * Deleted more useless stuff * first take for psbt (still broken) * get tests to work * fix devices_signed undefined * fix part2 * fix part 3 * fix part 4 * Rest Get-Requests for psbt working * fix part 5 * extending psbt_creator with json format * tests finished. bitcoind_regtest changed to scope session * speed up tests * fix tests * tiny test for LiquidRpc, probes improvements * try fixing testing-infra * kick * finally fix infra, hopefully * removing assertion * refactoring and fixing API * fix the rest-tests * fix last liquid failing test * polishing: error_handling via decorator * split-up docs * fix requirements.in * polishing REST-API * optimize startup for internal_nodes * Update src/cryptoadvance/specter/internal_node.py Co-authored-by: benk10 <ben.kaufman10@gmail.com> Co-authored-by: Alpha Zeta <40473443+pxsocs@users.noreply.github.com> Co-authored-by: benk10 <ben.kaufman10@gmail.com> Co-authored-by: Alpha Zeta <alphazeta@protonmail.com> Co-authored-by: Stepan Snigirev <snigirev.stepan@gmail.com>
2021-07-08 20:10:14 +02:00
}
result = client.get(
"/api/v1alpha/wallets/a_simple_wallet/psbt",
follow_redirects=True,
headers=headers,
)
assert result.status_code == 200
data = json.loads(result.data)
assert data["result"] == {}
Feature: Api framework (#1232) * Included API end points Included 3 API end points: ###/api/specter ["GET"] Basic Specter info from app.specter class ###/api/full_txlist/ ["GET"] Full Transaction list for all wallets ###"/api/wallet_info/<wallet_alias>/ ["GET"] More detailed wallet info and transactions from the app.specter.wallet_manager class * Update src/cryptoadvance/specter/controller.py Include `wallet.check_unused()` Co-authored-by: benk10 <ben.kaufman10@gmail.com> * API Update Made a few changes: - Flattened the wallet list to be similar to full transaction list - included versioning on url `/v1alpha/` - Included `wallet.utxo` data - Improved `safe_serialize` for better json output Pending Updates: - Create a separate file for API (as a blueprint) - Explore using Flask-restful for improved authentication (downside is that it is another dependency - not sure if already a requirement for specter) * adding a rest-api * Implemented API end points inside of example.py * Merging with remote * Fixed API.md * Removing example-resources * migrating to focal due to cryptography needs newer pip * fix the image * black and tidy up * Deleted more useless stuff * first take for psbt (still broken) * get tests to work * fix devices_signed undefined * fix part2 * fix part 3 * fix part 4 * Rest Get-Requests for psbt working * fix part 5 * extending psbt_creator with json format * tests finished. bitcoind_regtest changed to scope session * speed up tests * fix tests * tiny test for LiquidRpc, probes improvements * try fixing testing-infra * kick * finally fix infra, hopefully * removing assertion * refactoring and fixing API * fix the rest-tests * fix last liquid failing test * polishing: error_handling via decorator * split-up docs * fix requirements.in * polishing REST-API * optimize startup for internal_nodes * Update src/cryptoadvance/specter/internal_node.py Co-authored-by: benk10 <ben.kaufman10@gmail.com> Co-authored-by: Alpha Zeta <40473443+pxsocs@users.noreply.github.com> Co-authored-by: benk10 <ben.kaufman10@gmail.com> Co-authored-by: Alpha Zeta <alphazeta@protonmail.com> Co-authored-by: Stepan Snigirev <snigirev.stepan@gmail.com>
2021-07-08 20:10:14 +02:00
UIUX: Overhaul of UTXO list, handling of locked UTXOs and scrollbar added to tx-table web component (#1580) * Added tests/bitcoin to gitignore * Ensure locked UTXO can't be used for transactions, fix rounding error in coin selection, fix styling/text in general settings. * overhaul of checkbox logic in utxolist including mouseover event for checkboxes, manage psbt button action added, icon info popups added,design changes in utxo- and txlist to make the display quieter * change of balance display, scrollbars for main and tx table, bugfixes (pagination, coin selection, unsigned labeling) & some styling finetuning * deleted locked utxo balance calculations, added doc strings regarding balances * jinja comment added in tx table, making scrollbar less vivid, tx table settings changed to no compact view toggle and scrollbar on by default * more granular amount properties, little test fix. * applying new amount properties to the frontend and other parts of the code & improving balance display design * refactored a_simple_wallet to be only used in test_rest once * tests for amounts and test performance optimisations. * fix spec_node_configured * fix spec_wallet_send.js * fix spec_wallet_utxo.js * keep action teaser div hidden on wallets overview. * minor bug fix in tx-table, added includeShadowDom to cypress.json, adapted spec_wallet_utxo.js to new utxo list logic and added tests of new functionality to it. * fix spec_plugins.js and switch back to includeShadowDom false The problem with true is, that you are no longer able to spot when you need to apply the workaround described in https://docs.cypress.io/api/commands/shadow#Known-Issue as you only need to apply in a shadow-DOM. Feel free to switch it back in any test you see fit. Cypress.config('includeShadowDom',true) * better organisation of wallet utxo spec file * some wait-tweaks to cypress tests to make them run smoother on cirrus, note: cypress tests green in local dev. * longer wait in spec_elm_multi_segwit_wallet.js * fixing spec_elm_multi_segwit_wallet.js * more checks whether checkboxes get selected and additional waits for cirrus in spec_wallet_utxo.js. Co-authored-by: Kim Neunert <k9ert@gmx.de>
2022-04-08 11:07:01 +02:00
def test_rr_psbt_post(specter_regtest_configured, bitcoin_regtest, client, caplog):
create_a_simple_wallet(specter_regtest_configured, bitcoin_regtest)
Feature: Api framework (#1232) * Included API end points Included 3 API end points: ###/api/specter ["GET"] Basic Specter info from app.specter class ###/api/full_txlist/ ["GET"] Full Transaction list for all wallets ###"/api/wallet_info/<wallet_alias>/ ["GET"] More detailed wallet info and transactions from the app.specter.wallet_manager class * Update src/cryptoadvance/specter/controller.py Include `wallet.check_unused()` Co-authored-by: benk10 <ben.kaufman10@gmail.com> * API Update Made a few changes: - Flattened the wallet list to be similar to full transaction list - included versioning on url `/v1alpha/` - Included `wallet.utxo` data - Improved `safe_serialize` for better json output Pending Updates: - Create a separate file for API (as a blueprint) - Explore using Flask-restful for improved authentication (downside is that it is another dependency - not sure if already a requirement for specter) * adding a rest-api * Implemented API end points inside of example.py * Merging with remote * Fixed API.md * Removing example-resources * migrating to focal due to cryptography needs newer pip * fix the image * black and tidy up * Deleted more useless stuff * first take for psbt (still broken) * get tests to work * fix devices_signed undefined * fix part2 * fix part 3 * fix part 4 * Rest Get-Requests for psbt working * fix part 5 * extending psbt_creator with json format * tests finished. bitcoind_regtest changed to scope session * speed up tests * fix tests * tiny test for LiquidRpc, probes improvements * try fixing testing-infra * kick * finally fix infra, hopefully * removing assertion * refactoring and fixing API * fix the rest-tests * fix last liquid failing test * polishing: error_handling via decorator * split-up docs * fix requirements.in * polishing REST-API * optimize startup for internal_nodes * Update src/cryptoadvance/specter/internal_node.py Co-authored-by: benk10 <ben.kaufman10@gmail.com> Co-authored-by: Alpha Zeta <40473443+pxsocs@users.noreply.github.com> Co-authored-by: benk10 <ben.kaufman10@gmail.com> Co-authored-by: Alpha Zeta <alphazeta@protonmail.com> Co-authored-by: Stepan Snigirev <snigirev.stepan@gmail.com>
2021-07-08 20:10:14 +02:00
caplog.set_level(logging.DEBUG)
""" testing the registration """
headers = {
"Authorization": "Bearer "
+ create_registered_jwt_token(specter_regtest_configured, "someuser"),
"Content-type": "application/json",
}
result = client.get(
"/api/v1alpha/wallets/a_simple_wallet/",
follow_redirects=True,
headers=headers,
)
# Why the heck does this fail?
# assert json.loads(result.data)["a_simple_wallet"]["info"]["balance"] > 0
Feature: Api framework (#1232) * Included API end points Included 3 API end points: ###/api/specter ["GET"] Basic Specter info from app.specter class ###/api/full_txlist/ ["GET"] Full Transaction list for all wallets ###"/api/wallet_info/<wallet_alias>/ ["GET"] More detailed wallet info and transactions from the app.specter.wallet_manager class * Update src/cryptoadvance/specter/controller.py Include `wallet.check_unused()` Co-authored-by: benk10 <ben.kaufman10@gmail.com> * API Update Made a few changes: - Flattened the wallet list to be similar to full transaction list - included versioning on url `/v1alpha/` - Included `wallet.utxo` data - Improved `safe_serialize` for better json output Pending Updates: - Create a separate file for API (as a blueprint) - Explore using Flask-restful for improved authentication (downside is that it is another dependency - not sure if already a requirement for specter) * adding a rest-api * Implemented API end points inside of example.py * Merging with remote * Fixed API.md * Removing example-resources * migrating to focal due to cryptography needs newer pip * fix the image * black and tidy up * Deleted more useless stuff * first take for psbt (still broken) * get tests to work * fix devices_signed undefined * fix part2 * fix part 3 * fix part 4 * Rest Get-Requests for psbt working * fix part 5 * extending psbt_creator with json format * tests finished. bitcoind_regtest changed to scope session * speed up tests * fix tests * tiny test for LiquidRpc, probes improvements * try fixing testing-infra * kick * finally fix infra, hopefully * removing assertion * refactoring and fixing API * fix the rest-tests * fix last liquid failing test * polishing: error_handling via decorator * split-up docs * fix requirements.in * polishing REST-API * optimize startup for internal_nodes * Update src/cryptoadvance/specter/internal_node.py Co-authored-by: benk10 <ben.kaufman10@gmail.com> Co-authored-by: Alpha Zeta <40473443+pxsocs@users.noreply.github.com> Co-authored-by: benk10 <ben.kaufman10@gmail.com> Co-authored-by: Alpha Zeta <alphazeta@protonmail.com> Co-authored-by: Stepan Snigirev <snigirev.stepan@gmail.com>
2021-07-08 20:10:14 +02:00
result = client.post(
"/api/v1alpha/wallets/some_wallet/psbt",
data=dict(address="someaddress", amount=0.5),
follow_redirects=True,
)
assert result.status_code == 401
assert json.loads(result.data)["message"].startswith(
"The server could not verify that you are authorized to access the URL requested."
)
result = client.post(
"/api/v1alpha/wallets/a_simple_wallet/psbt",
data="""
{
"recipients" : [
{
"address": "bcrt1qgc6h85z43g3ss2dl5zdrzrp3ef6av4neqcqhh8",
Feature: Api framework (#1232) * Included API end points Included 3 API end points: ###/api/specter ["GET"] Basic Specter info from app.specter class ###/api/full_txlist/ ["GET"] Full Transaction list for all wallets ###"/api/wallet_info/<wallet_alias>/ ["GET"] More detailed wallet info and transactions from the app.specter.wallet_manager class * Update src/cryptoadvance/specter/controller.py Include `wallet.check_unused()` Co-authored-by: benk10 <ben.kaufman10@gmail.com> * API Update Made a few changes: - Flattened the wallet list to be similar to full transaction list - included versioning on url `/v1alpha/` - Included `wallet.utxo` data - Improved `safe_serialize` for better json output Pending Updates: - Create a separate file for API (as a blueprint) - Explore using Flask-restful for improved authentication (downside is that it is another dependency - not sure if already a requirement for specter) * adding a rest-api * Implemented API end points inside of example.py * Merging with remote * Fixed API.md * Removing example-resources * migrating to focal due to cryptography needs newer pip * fix the image * black and tidy up * Deleted more useless stuff * first take for psbt (still broken) * get tests to work * fix devices_signed undefined * fix part2 * fix part 3 * fix part 4 * Rest Get-Requests for psbt working * fix part 5 * extending psbt_creator with json format * tests finished. bitcoind_regtest changed to scope session * speed up tests * fix tests * tiny test for LiquidRpc, probes improvements * try fixing testing-infra * kick * finally fix infra, hopefully * removing assertion * refactoring and fixing API * fix the rest-tests * fix last liquid failing test * polishing: error_handling via decorator * split-up docs * fix requirements.in * polishing REST-API * optimize startup for internal_nodes * Update src/cryptoadvance/specter/internal_node.py Co-authored-by: benk10 <ben.kaufman10@gmail.com> Co-authored-by: Alpha Zeta <40473443+pxsocs@users.noreply.github.com> Co-authored-by: benk10 <ben.kaufman10@gmail.com> Co-authored-by: Alpha Zeta <alphazeta@protonmail.com> Co-authored-by: Stepan Snigirev <snigirev.stepan@gmail.com>
2021-07-08 20:10:14 +02:00
"amount": 0.1,
"unit": "btc",
"label": "someLabel"
},
{
"address": "bcrt1q3kfetuxpxvujasww6xas94nawklvpz0e52uw8a",
"amount": 111211,
"unit": "sat",
"label": "someOtherLabel"
}
],
"rbf_tx_id": "",
"subtract_from": "0",
Feature: Api framework (#1232) * Included API end points Included 3 API end points: ###/api/specter ["GET"] Basic Specter info from app.specter class ###/api/full_txlist/ ["GET"] Full Transaction list for all wallets ###"/api/wallet_info/<wallet_alias>/ ["GET"] More detailed wallet info and transactions from the app.specter.wallet_manager class * Update src/cryptoadvance/specter/controller.py Include `wallet.check_unused()` Co-authored-by: benk10 <ben.kaufman10@gmail.com> * API Update Made a few changes: - Flattened the wallet list to be similar to full transaction list - included versioning on url `/v1alpha/` - Included `wallet.utxo` data - Improved `safe_serialize` for better json output Pending Updates: - Create a separate file for API (as a blueprint) - Explore using Flask-restful for improved authentication (downside is that it is another dependency - not sure if already a requirement for specter) * adding a rest-api * Implemented API end points inside of example.py * Merging with remote * Fixed API.md * Removing example-resources * migrating to focal due to cryptography needs newer pip * fix the image * black and tidy up * Deleted more useless stuff * first take for psbt (still broken) * get tests to work * fix devices_signed undefined * fix part2 * fix part 3 * fix part 4 * Rest Get-Requests for psbt working * fix part 5 * extending psbt_creator with json format * tests finished. bitcoind_regtest changed to scope session * speed up tests * fix tests * tiny test for LiquidRpc, probes improvements * try fixing testing-infra * kick * finally fix infra, hopefully * removing assertion * refactoring and fixing API * fix the rest-tests * fix last liquid failing test * polishing: error_handling via decorator * split-up docs * fix requirements.in * polishing REST-API * optimize startup for internal_nodes * Update src/cryptoadvance/specter/internal_node.py Co-authored-by: benk10 <ben.kaufman10@gmail.com> Co-authored-by: Alpha Zeta <40473443+pxsocs@users.noreply.github.com> Co-authored-by: benk10 <ben.kaufman10@gmail.com> Co-authored-by: Alpha Zeta <alphazeta@protonmail.com> Co-authored-by: Stepan Snigirev <snigirev.stepan@gmail.com>
2021-07-08 20:10:14 +02:00
"fee_rate": "64",
"rbf": true
}
""",
follow_redirects=True,
headers=headers,
)
print(result.data)
assert result.status_code == 200
data = json.loads(result.data)
assert "bcrt1qgc6h85z43g3ss2dl5zdrzrp3ef6av4neqcqhh8" in data["result"]["address"]
assert "bcrt1q3kfetuxpxvujasww6xas94nawklvpz0e52uw8a" in data["result"]["address"]
assert 0.1 in data["result"]["amount"]
assert 0.00111211 in data["result"]["amount"]
assert data["result"]["tx"]
assert data["result"]["inputs"]
assert data["result"]["outputs"]
assert almost_equal(data["result"]["fee_rate"], 64)
Feature: Api framework (#1232) * Included API end points Included 3 API end points: ###/api/specter ["GET"] Basic Specter info from app.specter class ###/api/full_txlist/ ["GET"] Full Transaction list for all wallets ###"/api/wallet_info/<wallet_alias>/ ["GET"] More detailed wallet info and transactions from the app.specter.wallet_manager class * Update src/cryptoadvance/specter/controller.py Include `wallet.check_unused()` Co-authored-by: benk10 <ben.kaufman10@gmail.com> * API Update Made a few changes: - Flattened the wallet list to be similar to full transaction list - included versioning on url `/v1alpha/` - Included `wallet.utxo` data - Improved `safe_serialize` for better json output Pending Updates: - Create a separate file for API (as a blueprint) - Explore using Flask-restful for improved authentication (downside is that it is another dependency - not sure if already a requirement for specter) * adding a rest-api * Implemented API end points inside of example.py * Merging with remote * Fixed API.md * Removing example-resources * migrating to focal due to cryptography needs newer pip * fix the image * black and tidy up * Deleted more useless stuff * first take for psbt (still broken) * get tests to work * fix devices_signed undefined * fix part2 * fix part 3 * fix part 4 * Rest Get-Requests for psbt working * fix part 5 * extending psbt_creator with json format * tests finished. bitcoind_regtest changed to scope session * speed up tests * fix tests * tiny test for LiquidRpc, probes improvements * try fixing testing-infra * kick * finally fix infra, hopefully * removing assertion * refactoring and fixing API * fix the rest-tests * fix last liquid failing test * polishing: error_handling via decorator * split-up docs * fix requirements.in * polishing REST-API * optimize startup for internal_nodes * Update src/cryptoadvance/specter/internal_node.py Co-authored-by: benk10 <ben.kaufman10@gmail.com> Co-authored-by: Alpha Zeta <40473443+pxsocs@users.noreply.github.com> Co-authored-by: benk10 <ben.kaufman10@gmail.com> Co-authored-by: Alpha Zeta <alphazeta@protonmail.com> Co-authored-by: Stepan Snigirev <snigirev.stepan@gmail.com>
2021-07-08 20:10:14 +02:00
assert data["result"]["tx_full_size"]
assert data["result"]["base64"]
assert data["result"]["time"]
assert data["result"]["sigs_count"] == 0
UIUX: Overhaul of UTXO list, handling of locked UTXOs and scrollbar added to tx-table web component (#1580) * Added tests/bitcoin to gitignore * Ensure locked UTXO can't be used for transactions, fix rounding error in coin selection, fix styling/text in general settings. * overhaul of checkbox logic in utxolist including mouseover event for checkboxes, manage psbt button action added, icon info popups added,design changes in utxo- and txlist to make the display quieter * change of balance display, scrollbars for main and tx table, bugfixes (pagination, coin selection, unsigned labeling) & some styling finetuning * deleted locked utxo balance calculations, added doc strings regarding balances * jinja comment added in tx table, making scrollbar less vivid, tx table settings changed to no compact view toggle and scrollbar on by default * more granular amount properties, little test fix. * applying new amount properties to the frontend and other parts of the code & improving balance display design * refactored a_simple_wallet to be only used in test_rest once * tests for amounts and test performance optimisations. * fix spec_node_configured * fix spec_wallet_send.js * fix spec_wallet_utxo.js * keep action teaser div hidden on wallets overview. * minor bug fix in tx-table, added includeShadowDom to cypress.json, adapted spec_wallet_utxo.js to new utxo list logic and added tests of new functionality to it. * fix spec_plugins.js and switch back to includeShadowDom false The problem with true is, that you are no longer able to spot when you need to apply the workaround described in https://docs.cypress.io/api/commands/shadow#Known-Issue as you only need to apply in a shadow-DOM. Feel free to switch it back in any test you see fit. Cypress.config('includeShadowDom',true) * better organisation of wallet utxo spec file * some wait-tweaks to cypress tests to make them run smoother on cirrus, note: cypress tests green in local dev. * longer wait in spec_elm_multi_segwit_wallet.js * fixing spec_elm_multi_segwit_wallet.js * more checks whether checkboxes get selected and additional waits for cirrus in spec_wallet_utxo.js. Co-authored-by: Kim Neunert <k9ert@gmx.de>
2022-04-08 11:07:01 +02:00
def create_a_simple_wallet(specter: Specter, bitcoin_regtest):
"""ToDo: Could potentially do this with a fixture but this is only relevant for this file only"""
payload = jwt.decode(
User.generate_jwt_token(
"someuser", "tokenid", "tokendescription", random.randrange(100, 200)
),
app.config["SECRET_KEY"],
algorithms=["HS256"],
)
username = payload["username"]
someuser = specter.user_manager.get_user_by_username(username)
wm = someuser.wallet_manager
assert not wm.working_folder is None
UIUX: Overhaul of UTXO list, handling of locked UTXOs and scrollbar added to tx-table web component (#1580) * Added tests/bitcoin to gitignore * Ensure locked UTXO can't be used for transactions, fix rounding error in coin selection, fix styling/text in general settings. * overhaul of checkbox logic in utxolist including mouseover event for checkboxes, manage psbt button action added, icon info popups added,design changes in utxo- and txlist to make the display quieter * change of balance display, scrollbars for main and tx table, bugfixes (pagination, coin selection, unsigned labeling) & some styling finetuning * deleted locked utxo balance calculations, added doc strings regarding balances * jinja comment added in tx table, making scrollbar less vivid, tx table settings changed to no compact view toggle and scrollbar on by default * more granular amount properties, little test fix. * applying new amount properties to the frontend and other parts of the code & improving balance display design * refactored a_simple_wallet to be only used in test_rest once * tests for amounts and test performance optimisations. * fix spec_node_configured * fix spec_wallet_send.js * fix spec_wallet_utxo.js * keep action teaser div hidden on wallets overview. * minor bug fix in tx-table, added includeShadowDom to cypress.json, adapted spec_wallet_utxo.js to new utxo list logic and added tests of new functionality to it. * fix spec_plugins.js and switch back to includeShadowDom false The problem with true is, that you are no longer able to spot when you need to apply the workaround described in https://docs.cypress.io/api/commands/shadow#Known-Issue as you only need to apply in a shadow-DOM. Feel free to switch it back in any test you see fit. Cypress.config('includeShadowDom',true) * better organisation of wallet utxo spec file * some wait-tweaks to cypress tests to make them run smoother on cirrus, note: cypress tests green in local dev. * longer wait in spec_elm_multi_segwit_wallet.js * fixing spec_elm_multi_segwit_wallet.js * more checks whether checkboxes get selected and additional waits for cirrus in spec_wallet_utxo.js. Co-authored-by: Kim Neunert <k9ert@gmx.de>
2022-04-08 11:07:01 +02:00
# Create a Wallet
wallet_json = '{"label": "a_simple_wallet", "blockheight": 0, "descriptor": "wpkh([1ef4e492/84h/1h/0h]tpubDC5EUwdy9WWpzqMWKNhVmXdMgMbi4ywxkdysRdNr1MdM4SCfVLbNtsFvzY6WKSuzsaVAitj6FmP6TugPuNT6yKZDLsHrSwMd816TnqX7kuc/0/*)#xp8lv5nr", "devices": [{"type": "trezor", "label": "trezor"}]} '
dm = someuser.device_manager
wallet_importer = WalletImporter(wallet_json, specter, device_manager=dm)
UIUX: Overhaul of UTXO list, handling of locked UTXOs and scrollbar added to tx-table web component (#1580) * Added tests/bitcoin to gitignore * Ensure locked UTXO can't be used for transactions, fix rounding error in coin selection, fix styling/text in general settings. * overhaul of checkbox logic in utxolist including mouseover event for checkboxes, manage psbt button action added, icon info popups added,design changes in utxo- and txlist to make the display quieter * change of balance display, scrollbars for main and tx table, bugfixes (pagination, coin selection, unsigned labeling) & some styling finetuning * deleted locked utxo balance calculations, added doc strings regarding balances * jinja comment added in tx table, making scrollbar less vivid, tx table settings changed to no compact view toggle and scrollbar on by default * more granular amount properties, little test fix. * applying new amount properties to the frontend and other parts of the code & improving balance display design * refactored a_simple_wallet to be only used in test_rest once * tests for amounts and test performance optimisations. * fix spec_node_configured * fix spec_wallet_send.js * fix spec_wallet_utxo.js * keep action teaser div hidden on wallets overview. * minor bug fix in tx-table, added includeShadowDom to cypress.json, adapted spec_wallet_utxo.js to new utxo list logic and added tests of new functionality to it. * fix spec_plugins.js and switch back to includeShadowDom false The problem with true is, that you are no longer able to spot when you need to apply the workaround described in https://docs.cypress.io/api/commands/shadow#Known-Issue as you only need to apply in a shadow-DOM. Feel free to switch it back in any test you see fit. Cypress.config('includeShadowDom',true) * better organisation of wallet utxo spec file * some wait-tweaks to cypress tests to make them run smoother on cirrus, note: cypress tests green in local dev. * longer wait in spec_elm_multi_segwit_wallet.js * fixing spec_elm_multi_segwit_wallet.js * more checks whether checkboxes get selected and additional waits for cirrus in spec_wallet_utxo.js. Co-authored-by: Kim Neunert <k9ert@gmx.de>
2022-04-08 11:07:01 +02:00
wallet_importer.create_nonexisting_signers(
dm,
UIUX: Overhaul of UTXO list, handling of locked UTXOs and scrollbar added to tx-table web component (#1580) * Added tests/bitcoin to gitignore * Ensure locked UTXO can't be used for transactions, fix rounding error in coin selection, fix styling/text in general settings. * overhaul of checkbox logic in utxolist including mouseover event for checkboxes, manage psbt button action added, icon info popups added,design changes in utxo- and txlist to make the display quieter * change of balance display, scrollbars for main and tx table, bugfixes (pagination, coin selection, unsigned labeling) & some styling finetuning * deleted locked utxo balance calculations, added doc strings regarding balances * jinja comment added in tx table, making scrollbar less vivid, tx table settings changed to no compact view toggle and scrollbar on by default * more granular amount properties, little test fix. * applying new amount properties to the frontend and other parts of the code & improving balance display design * refactored a_simple_wallet to be only used in test_rest once * tests for amounts and test performance optimisations. * fix spec_node_configured * fix spec_wallet_send.js * fix spec_wallet_utxo.js * keep action teaser div hidden on wallets overview. * minor bug fix in tx-table, added includeShadowDom to cypress.json, adapted spec_wallet_utxo.js to new utxo list logic and added tests of new functionality to it. * fix spec_plugins.js and switch back to includeShadowDom false The problem with true is, that you are no longer able to spot when you need to apply the workaround described in https://docs.cypress.io/api/commands/shadow#Known-Issue as you only need to apply in a shadow-DOM. Feel free to switch it back in any test you see fit. Cypress.config('includeShadowDom',true) * better organisation of wallet utxo spec file * some wait-tweaks to cypress tests to make them run smoother on cirrus, note: cypress tests green in local dev. * longer wait in spec_elm_multi_segwit_wallet.js * fixing spec_elm_multi_segwit_wallet.js * more checks whether checkboxes get selected and additional waits for cirrus in spec_wallet_utxo.js. Co-authored-by: Kim Neunert <k9ert@gmx.de>
2022-04-08 11:07:01 +02:00
{"unknown_cosigner_0_name": "trezor", "unknown_cosigner_0_type": "trezor"},
)
wallet = wallet_importer.create_wallet(wm)
UIUX: Overhaul of UTXO list, handling of locked UTXOs and scrollbar added to tx-table web component (#1580) * Added tests/bitcoin to gitignore * Ensure locked UTXO can't be used for transactions, fix rounding error in coin selection, fix styling/text in general settings. * overhaul of checkbox logic in utxolist including mouseover event for checkboxes, manage psbt button action added, icon info popups added,design changes in utxo- and txlist to make the display quieter * change of balance display, scrollbars for main and tx table, bugfixes (pagination, coin selection, unsigned labeling) & some styling finetuning * deleted locked utxo balance calculations, added doc strings regarding balances * jinja comment added in tx table, making scrollbar less vivid, tx table settings changed to no compact view toggle and scrollbar on by default * more granular amount properties, little test fix. * applying new amount properties to the frontend and other parts of the code & improving balance display design * refactored a_simple_wallet to be only used in test_rest once * tests for amounts and test performance optimisations. * fix spec_node_configured * fix spec_wallet_send.js * fix spec_wallet_utxo.js * keep action teaser div hidden on wallets overview. * minor bug fix in tx-table, added includeShadowDom to cypress.json, adapted spec_wallet_utxo.js to new utxo list logic and added tests of new functionality to it. * fix spec_plugins.js and switch back to includeShadowDom false The problem with true is, that you are no longer able to spot when you need to apply the workaround described in https://docs.cypress.io/api/commands/shadow#Known-Issue as you only need to apply in a shadow-DOM. Feel free to switch it back in any test you see fit. Cypress.config('includeShadowDom',true) * better organisation of wallet utxo spec file * some wait-tweaks to cypress tests to make them run smoother on cirrus, note: cypress tests green in local dev. * longer wait in spec_elm_multi_segwit_wallet.js * fixing spec_elm_multi_segwit_wallet.js * more checks whether checkboxes get selected and additional waits for cirrus in spec_wallet_utxo.js. Co-authored-by: Kim Neunert <k9ert@gmx.de>
2022-04-08 11:07:01 +02:00
try:
# fund it with some coins
bitcoin_regtest.testcoin_faucet(address=wallet.getnewaddress())
# make sure it's confirmed
bitcoin_regtest.mine()
# Realize that the wallet has funds:
wallet.update()
except SpecterError as se:
if str(se).startswith("Timeout"):
pytest.fail(
"We got a Bitcoin-RPC timeout while setting up the test, minting some coins. Test Error! Check cpu/mem utilastion and btc/elem logs!"
)
return
else:
raise se
assert wallet.fullbalance >= 20