-
Notifications
You must be signed in to change notification settings - Fork 234
/
sign_tx_method.jinja
101 lines (100 loc) · 4.86 KB
/
sign_tx_method.jinja
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
{#
sign_tx_method - Popup to choose how to sign for a device.
Parameters:
- wallet: The wallet object used.
- device: The device object used.
- psbt: The psbt to be signed.
- specter: The active chain
#}
{% macro sign_tx_method(wallet, device, psbt, chain) -%}
{% set device_psbts = device.create_psbts(psbt['base64'], wallet) %}
<div id="{{ device.alias }}_sign_tx_method" class="flex-center flex-column hidden">
<h2>Sign Transaction</h2><br>
<div>
Please choose a signing method for your {{ device.name }}.
</div>
{% if device.hwi_support %}
<button id="{{ device.alias }}_hwi_sign_btn" class="btn flex-item" style="width: 190px; margin: 15px auto;">
<img src="{{ url_for('static', filename='img/usb_tiny.svg') }}" height="12px">Sign via USB (HWI)
</button>
<script>
document.getElementById("{{ device.alias }}_hwi_sign_btn").addEventListener("click", e => {
e.preventDefault();
hidePageOverlay();
let fingerprint = null;
{% for wallet_key in wallet.keys %}
{% for device_key in device.keys %}
{% if device_key == wallet_key %}
fingerprint = '{{ device.keys[loop.index0].fingerprint }}'
{% endif %}
{% endfor %}
{% endfor %}
signTx(combine, '{{ device.device_type }}', '{{ device_psbts["hwi"] }}', fingerprint);
});
</script>
{% endif %}
{% if device.sd_card_support %}
{% include "includes/overlay/sd_card_sign.jinja" %}
<button id="{{ device.alias }}_file_sign_btn" class="btn flex-item" style="width: 190px; margin: 15px auto;">
Sign with SD Card file
</button>
<script>
document.getElementById("{{ device.alias }}_file_sign_btn").addEventListener("click", e => {
e.preventDefault();
hidePageOverlay();
showPageOverlay('{{ device.alias }}_sign_tx_file');
});
</script>
{% endif %}
{% if device.qr_code_support %}
{% include "includes/overlay/qr_code_sign.jinja" %}
<button id="{{ device.alias }}_qr_sign_btn" class="btn flex-item" style="width: 190px; margin: 15px auto;">
Sign with QR codes
</button>
<script>
document.getElementById("{{ device.alias }}_qr_sign_btn").addEventListener("click", e => {
e.preventDefault();
hidePageOverlay();
showPageOverlay('{{ device.alias }}_sign_tx_qr');
});
</script>
{% endif %}
{% if device.hot_wallet %}
<button id="{{ device.alias }}_hot_sign_btn" class="btn flex-item" style="width: 190px; margin: 15px auto;">
{% from "components/bitcoin_svg.jinja" import bitcoin_svg %}
{{ bitcoin_svg(chain, 16) }} Sign with Bitcoin Core
</button>
<script>
document.getElementById("{{ device.alias }}_hot_sign_btn").addEventListener("click", async function(e) {
e.preventDefault();
hidePageOverlay();
showPageOverlay('hot_enter_passphrase')
});
</script>
<div id="hot_enter_passphrase" class="hidden">
{% set is_encrypted = device.is_encrypted(wallet.manager) %}
{% if is_encrypted %}
<h2>Enter decryption password</h2>
{% else %}
<h2>Proceed with signing</h2>
{% endif %}
<form action="?" method="POST" id="hot_enter_passphrase__content" class="flex-center flex-column">
<br/>
<div>
{% if is_encrypted %}
<input name="passphrase" type="password" id="hwi_enter_passphrase__passphrase" />
{% else %}
Wallet is not encrypted, just click the button.
<input name="passphrase" type="hidden" id="hwi_enter_passphrase__passphrase" value="" />
{% endif %}
<input name="device" type="hidden" value="{{ device.alias }}" />
<input name="psbt" type="hidden" value='{{ psbt|tojson|safe }}' />
</div>
<br/>
<br/>
<button id="hot_enter_passphrase__submit" class="btn" type="submit" name="action" value="signhotwallet">Sign transaction</button>
</form>
</div>
{% endif %}
</div>
{%- endmacro %}