{% extends "base.jinja" %}
{% block main %}
    <style>
		.arrow:hover {
			background-color: #ddd;
			color: black;
		}

		.arrow {
			text-decoration: none;
			display: inline-block;
			margin: 0px 16px 16px;
			border-radius: 50%;
			color: #fff;
			font-size: 1.5em;
		}

		.disabled {
			visibility: hidden;
		}
	</style>
    <h1 id="title">Wallets Overview</h1>
	<p style="width: 80%; text-align: center; margin-left: auto; margin-right: auto;">Here you can see the combined balance and transactions history of all your Specter wallets.</p>
    <h1>
        <small style="line-height:30px">Total balance:</small><br>
        <span style="color: #fff">
			{% set fullbalance = specter.wallet_manager.wallets.values() | sum(attribute='fullbalance') %}
            {{ fullbalance | btcunitamount }}
            {% if specter.unit == 'sat' %}
				sats
			{% else %}
				{% if specter.chain !='main' %}t{%endif%}BTC
			{% endif %}
        </span><br>
		<span class="note">{{ fullbalance | altunit }}</span>
        {% if specter.wallet_manager.wallets.values() | sum(attribute='balance.untrusted_pending') > 0 %}<br>
            <small>( {{ specter.wallet_manager.wallets.values() | sum(attribute='balance.trusted') | btcunitamount }} confirmed, {{ specter.wallet_manager.wallets.values() | sum(attribute='balance.untrusted_pending') | btcunitamount }} pending )</small>
        {% endif %}
    </h1>
    {% set validate_merkle_proofs=specter.config.validate_merkle_proofs %}
    {% set transactions = specter.wallet_manager.full_txlist(idx, validate_merkle_proofs) %}
	{% set next_transactions = specter.wallet_manager.full_txlist(idx + 1, validate_merkle_proofs) %}
	{% if idx != 0 or next_transactions|length != 0 %}
		<div>
			<a href="./?idx={{ idx - 1 }}" class="arrow {% if idx == 0 %}disabled{% endif %}">&#8249;</a>
			{% if next_transactions|length > 0 or idx != 0 %}
			Page {{ idx + 1 }}
			{% endif %}
			<a href="./?idx={{ idx + 1 }}" class="arrow {% if next_transactions|length == 0 %}disabled{% endif %}">&#8250;</a>
		</div>
	{% endif %}
    <div class="table-holder">
        {% from 'wallet/history/components/tx_table.jinja' import tx_table %}
        {% from 'wallet/history/txs/components/full_tx_table.jinja' import full_tx_table %}
        {{
            tx_table(
                transactions == [],
                full_tx_table(transactions=transactions, wallet=none, specter=specter, includeValidatedBlockhash=validate_merkle_proofs),
		includeValidatedBlockhash=validate_merkle_proofs,
            )
        }}
    </div>
{% endblock %}
