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
|
2021-07-08 20:10:14 +02:00
|
|
|
import logging
|
2021-10-08 17:56:49 +02:00
|
|
|
from numbers import Number
|
2022-10-20 15:47:48 +05:30
|
|
|
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
|
2022-10-20 15:47:48 +05:30
|
|
|
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
|
2022-10-20 15:47:48 +05:30
|
|
|
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
|
|
|
|
2022-10-20 09:44:36 +02:00
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
2021-10-08 17:56:49 +02:00
|
|
|
|
2026-08-08 14:57:14 +02:00
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
2021-10-08 17:56:49 +02:00
|
|
|
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)
|
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)
|
2022-11-14 21:26:32 +01:00
|
|
|
assert (
|
|
|
|
|
specter_regtest_configured.config["testing"]["allow_threading_for_testing"]
|
|
|
|
|
== False
|
|
|
|
|
) # Tests fail with threading
|
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."
|
|
|
|
|
)
|
|
|
|
|
|
2022-10-20 15:47:48 +05:30
|
|
|
# Wrong token
|
|
|
|
|
headers = {"Authorization": "Bearer " + "sometoken"}
|
2021-07-08 20:10:14 +02:00
|
|
|
result = client.get(
|
2022-10-20 09:44:36 +02:00
|
|
|
"/api/v1alpha/wallets/a_simple_wallet/psbt",
|
|
|
|
|
follow_redirects=True,
|
|
|
|
|
headers=headers,
|
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 = {
|
2022-10-20 15:47:48 +05:30
|
|
|
"Authorization": "Bearer "
|
2026-08-08 14:57:14 +02:00
|
|
|
+ create_registered_jwt_token(specter_regtest_configured, "admin")
|
2021-07-08 20:10:14 +02:00
|
|
|
}
|
|
|
|
|
result = client.get(
|
2022-10-20 09:44:36 +02:00
|
|
|
"/api/v1alpha/wallets/a_simple_wallet/psbt",
|
|
|
|
|
follow_redirects=True,
|
|
|
|
|
headers=headers,
|
2021-07-08 20:10:14 +02:00
|
|
|
)
|
|
|
|
|
assert result.status_code == 403
|
2022-10-20 09:44:36 +02:00
|
|
|
assert (
|
|
|
|
|
json.loads(result.data)["message"]
|
|
|
|
|
== "The wallet does not belong to the user in the request."
|
|
|
|
|
)
|
2021-07-08 20:10:14 +02:00
|
|
|
|
|
|
|
|
# Proper authorized (the wallet is owned by someuser)
|
|
|
|
|
headers = {
|
2022-10-20 15:47:48 +05:30
|
|
|
"Authorization": "Bearer "
|
2026-08-08 14:57:14 +02:00
|
|
|
+ create_registered_jwt_token(specter_regtest_configured, "someuser")
|
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)
|
2021-10-08 17:56:49 +02:00
|
|
|
assert data["result"] == {}
|
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)
|
2021-07-08 20:10:14 +02:00
|
|
|
caplog.set_level(logging.DEBUG)
|
|
|
|
|
""" testing the registration """
|
2021-08-03 14:52:18 +02:00
|
|
|
|
|
|
|
|
headers = {
|
2022-10-20 15:47:48 +05:30
|
|
|
"Authorization": "Bearer "
|
2026-08-08 14:57:14 +02:00
|
|
|
+ create_registered_jwt_token(specter_regtest_configured, "someuser"),
|
2021-08-03 14:52:18 +02:00
|
|
|
"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
|
|
|
|
|
|
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" : [
|
|
|
|
|
{
|
2021-08-03 14:52:18 +02:00
|
|
|
"address": "bcrt1qgc6h85z43g3ss2dl5zdrzrp3ef6av4neqcqhh8",
|
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": "",
|
2022-08-02 09:15:32 +02:00
|
|
|
"subtract_from": "0",
|
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"]
|
2021-10-08 17:56:49 +02:00
|
|
|
assert almost_equal(data["result"]["fee_rate"], 64)
|
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):
|
2022-10-20 15:47:48 +05:30
|
|
|
"""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)
|
2022-11-14 21:26:32 +01:00
|
|
|
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"}]} '
|
2022-11-14 21:26:32 +01:00
|
|
|
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(
|
2022-11-14 21:26:32 +01:00
|
|
|
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"},
|
|
|
|
|
)
|
2022-11-14 21:26:32 +01:00
|
|
|
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
|