Implement max, add some minimal validation
MODIFY
HiddenWallet/HiddenWallet.GUI/app/html/wallet-content.html
HiddenWallet/HiddenWallet.GUI/app/html/wallet-content.html
<input id="address-to-send" type="text" class="form-control" placeholder="186n7me3QKajQZJnUsVsezVhVrSwyFCCZ" required />
<br />
<label>Amount (BTC):</label> <br />
- <button class="btn btn-sm btn-primary">MAX</button>
+ <button class="btn btn-sm btn-primary" onclick="setAmountToAll()">MAX</button>
<input id="amount-to-send" type="text" onkeypress='return event.charCode >= 48 && event.charCode <= 57 || event.keyCode == 46' placeholder="0.1" required />
<br /> <br />
<label>Fee: &nbsp</label>
<label class="radio-inline">
- <input type="radio" name="fee-radio">Fast
+ <input id="fast-fee-radio" type="radio" name="fee-radio" checked>Fast
</label>
<label class="radio-inline">
- <input type="radio" name="fee-radio">Slow
+ <input id="slow-fee-radio" type="radio" name="fee-radio">Slow
</label>
<br />
<br />
- <button class="btn btn-lg btn-primary btn-block" onclick="recoverWallet()">Build Transaction</button>
+ <button class="btn btn-lg btn-primary btn-block" onclick="buildTransaction()">Build Transaction</button>
</div>
\ No newline at end of file

MODIFY
HiddenWallet/HiddenWallet.GUI/app/js/wallet-phase.js
HiddenWallet/HiddenWallet.GUI/app/js/wallet-phase.js
@@ -146,3 +146,28 @@ function updateWalletContent() {
}
}
}
+
+function setAmountToAll() {
+ document.getElementById("amount-to-send").value = "all";
+}
+
+function buildTransaction() {
+ var address = document.getElementById("address-to-send").value;
+ var amount = document.getElementById("amount-to-send").value;
+ var fastFeeChecked = document.getElementById("fast-fee-radio").checked;
+ var slowFeeChecked = document.getElementById("slow-fee-radio").checked;
+
+ if (!address) {
+ alert("Wrong address!");
+ return;
+ }
+ if (!amount || amount <= 0) {
+ alert("Wrong amount!");
+ return;
+ }
+ // if both are checked or none are checked (cannot happen)
+ if ((fastFeeChecked && slowFeeChecked) || (!fastFeeChecked && !slowFeeChecked)) {
+ alert("Wrong fee tpye!");
+ return;
+ }
+}
\ No newline at end of file

Implement max, add some minimal validation