
{# 
    total_wallet_balances - Title showing the wallet total balance + amount confirmed and unconfirmed (if there is any unconfirmed amount).
    Parameters:
    - wallet: Wallet object
    - specter: Specter object
 #}
{% macro total_wallet_balances(wallet, specter) -%}
    <div style="display: flex; flex-direction: column; min-width: 300px; align-items: center">
        <span style="line-height:30px; font-size: 1.1em;">Balance:</span>
        <div class="smaller-card">
            <div> 
                Total amount: <span id="fullbalance_amount">{{ wallet.amount_total | btcunitamount }}</span>
                {% if specter.unit == 'sat' %}
                    sats
                {% else %}
                    {% if specter.is_testnet %}t{%endif%}{% if specter.is_liquid %}L{%endif%}BTC
                {% endif %}
                {% if specter.price_check %} 
                    <span class="note">({{ wallet.amount_total | altunit }})</span>
                {% endif %}
            </div>
            {% if wallet.amount_unconfirmed > 0 or wallet.amount_immature > 0 %}
                <div>
                    Confirmed: {{ wallet.amount_confirmed | btcunitamount }}
                    {% if specter.unit == 'sat' %}
                        sats
                    {% else %}
                        {% if specter.is_testnet %}t{%endif%}{% if specter.is_liquid %}L{%endif%}BTC
                    {% endif %}
                    {% if specter.price_check %} 
                        <span class="note">({{ wallet.amount_confirmed | altunit }})</span>
                    {% endif %}
                </div>
                {% if wallet.amount_unconfirmed > 0 %}
                <div>
                    Unconfirmed: {{ wallet.amount_unconfirmed | btcunitamount }}
                    {% if specter.unit == 'sat' %}
                        sats
                    {% else %}
                        {% if specter.is_testnet %}t{%endif%}{% if specter.is_liquid %}L{%endif%}BTC
                    {% endif %}
                    {% if specter.price_check %} 
                        <span class="note">({{ wallet.amount_unconfirmed | altunit }})</span>
                    {% endif %}
                </div>
                {% endif %}
                {% if wallet.amount_immature > 0 and specter.chain == "regtest" %}
                <div style="color: grey; display: flex;">
                    Immature: {{ wallet.amount_immature | btcunitamount }} 
                    {% if specter.unit == 'sat' %}
                        sats
                    {% else %}
                        {% if specter.is_testnet %}t{%endif%}{% if specter.is_liquid %}L{%endif%}BTC
                    {% endif %}
                    {% if specter.price_check %} 
                        <span class="note" style="color: grey">({{ wallet.amount_immature | altunit }})</span>
                    {% endif %}
                    <tool-tip width="200px">
                        <h4 slot="title">{{ _("What are immature outputs?") }}</h4>
                        <span slot="paragraph">
                        {{ _('The UTXO of coinbase transactions (mining rewards) have the special condition that they cannot be spent for at least 100 blocks. Their amount is not included in the total balance here. You see these outputs because you are using regtest and have mined blocks.') }}
                         </span>
                    </tool-tip>
                </div>
                {% endif %}
                {% elif wallet.amount_immature > 0 and specter.chain == "main" %}
                <div style="color: #ccc; display: flex">
                    Immature: {{ wallet.amount_immature | btcunitamount }} 
                    {% if specter.unit == 'sat' %}
                        sats
                    {% else %}
                        {% if specter.is_testnet %}t{%endif%}{% if specter.is_liquid %}L{%endif%}BTC
                    {% endif %}
                    {% if specter.price_check %} 
                        <span class="note" style="color: grey">({{ wallet.amount_immature | altunit }})</span>
                    {% endif %}
                    <tool-tip width="200px">
                        <h4 slot="title">{{ _("What are immature outputs?") }}</h4>
                        <span slot="paragraph">
                        {{ _('The UTXO of coinbase transactions (mining rewards) have the special condition that they cannot be spent for at least 100 blocks. Their amount is not included in the total balance here.') }}
                        </span>
                    </tool-tip>
                </div>
            {% endif %}
        </div>
        {% if specter.is_liquid %}
        {% if wallet.balance.get("assets", {}) %}
            <div style="margin-bottom: 15px;">
                <small style="line-height:30px">Assets:<br>
                {% for asset in wallet.balance.get("assets",{}).keys() | sort %}
                    {% set balance = wallet.balance.get("assets",{}).get(asset, {}) %}
                    <div style="margin: 0 10px; display: inline-block;">
                        {{ (balance.get("trusted", 0) + balance.get("untrusted_pending", 0) + balance.get("immature", 0)) | btcamount }}
                        <asset-label data-asset="{{asset}}" data-label="{{asset | assetlabel}}" edit-mode="enabled"></asset-label>
                    </div>
                {% endfor %}
                </small>
            </div>
        {% endif %}
        {% include 'includes/overlay/liquid_assets_registry.html' %}
        <small style="line-height: 30px;">
            <button type="button" class="btn" style="margin: auto;" onclick="showPageOverlay('liquid-assets-registry')">{{ _("Show assets list") }}</button>
        </small>
        <br>
        {% endif %}
    </div>
    {% if wallet.rescan_progress or specter.utxorescanwallet == wallet.alias %}
        <span id="wallet_rescan_data" style="display: contents;">
            <h2>Rescanning blockchain: <span id="{{ wallet.alias }}_balances_wallet_rescan_percents">{{ "%.2f"|format(specter.info["utxorescan"] if specter.utxorescanwallet == wallet.alias else wallet.rescan_progress * 100) }}</span>%</h2>
            <span class="warning">
                <img src="{{ url_for('static', filename='img/info_sign.svg') }}" style="width: 20px;"/><br>
                Total balance and transactions history may show outdated data during scanning.<br>Please wait until the scanning is complete before you start using the wallet.
            </span>
        </span>
    {% endif %}
{%- endmacro %}
