Add possibility in verify view for HD wallets to choose the address format.

This commit is contained in:
Kiyomichi Kosaka 2021-04-05 19:03:02 +02:00
parent 9a0175e18f
commit 00519cb2ab
3 changed files with 23 additions and 3 deletions

View File

@ -1191,7 +1191,7 @@
<p>The path of key derivation</p> <p>The path of key derivation</p>
<div class="row"> <div class="row">
<div class="col-md-8"> <div class="col-md-6">
<b>Path</b><br> <b>Path</b><br>
<select class="form-control" id="hdpathtype""> <select class="form-control" id="hdpathtype"">
<option value="simple">Simple: m/i</option> <option value="simple">Simple: m/i</option>
@ -1216,6 +1216,15 @@
<input type="text" class="form-control derivation_index_end" value="1"> <input type="text" class="form-control derivation_index_end" value="1">
</div> </div>
<div class="col-md-2">
<b>Address format</b><br>
<select class="form-control derivation_addr_format">
<option value="bech32">Bech32</option>
<option value="segwit">SegWit</option>
<option value="legacy">Legacy</option>
</select>
</div>
</div> </div>
<hr> <hr>
@ -1226,7 +1235,7 @@
<div class="derived_data"> <div class="derived_data">
<table class="table table-striped table-hover"> <table class="table table-striped table-hover">
<thead> <thead>
<tr><td><b>Index</b></td><td><b>Address</b><td><b>Private Key (WIF)</b></td></td><td><b>Extended xPub</b></td><td><b>Extended xPrv</b></td></tr> <tr><td><b>Index</b></td><td><b>Address</b></td><td><b>Redeem script</b></td><td><b>Private Key (WIF)</b></td><td><b>Extended xPub</b></td><td><b>Extended xPrv</b></td></tr>
</thead> </thead>
<tbody> <tbody>
</tbody> </tbody>

View File

@ -618,10 +618,20 @@
var privkey = (r.key_bytes).slice(1, 33); var privkey = (r.key_bytes).slice(1, 33);
var privkeyHex = Crypto.util.bytesToHex(privkey); var privkeyHex = Crypto.util.bytesToHex(privkey);
var pubkey = coinjs.newPubkey(privkeyHex); var pubkey = coinjs.newPubkey(privkeyHex);
var addr_format = $("#verifyHDaddress .derivation_addr_format").val();
if (addr_format == "bech32") {
var address = coinjs.bech32Address(pubkey);
} else if (addr_format == "segwit") {
var address = coinjs.segwitAddress(pubkey);
} else {
var address = {'address': coinjs.pubkey2address(pubkey),
'redeemscript': ''};
}
r.keys = {'privkey':privkeyHex, r.keys = {'privkey':privkeyHex,
'pubkey':pubkey, 'pubkey':pubkey,
'address':coinjs.pubkey2address(pubkey), 'address':address.address,
'script':address.redeemscript,
'wif':coinjs.privkey2wif(privkeyHex)}; 'wif':coinjs.privkey2wif(privkeyHex)};
} else if(r.key_bytes[0] == 0x02 || r.key_bytes[0] == 0x03) { } else if(r.key_bytes[0] == 0x02 || r.key_bytes[0] == 0x03) {

View File

@ -1714,6 +1714,7 @@ $(document).ready(function() {
html += '<tr>'; html += '<tr>';
html += '<td>'+i+'</td>'; html += '<td>'+i+'</td>';
html += '<td><input type="text" class="form-control" value="'+derived.keys.address+'" readonly></td>'; html += '<td><input type="text" class="form-control" value="'+derived.keys.address+'" readonly></td>';
html += '<td><input type="text" class="form-control" value="'+derived.keys.script+'" readonly></td>';
html += '<td><input type="text" class="form-control" value="'+((derived.keys.wif)?derived.keys.wif:'')+'" readonly></td>'; html += '<td><input type="text" class="form-control" value="'+((derived.keys.wif)?derived.keys.wif:'')+'" readonly></td>';
html += '<td><input type="text" class="form-control" value="'+derived.keys_extended.pubkey+'" readonly></td>'; html += '<td><input type="text" class="form-control" value="'+derived.keys_extended.pubkey+'" readonly></td>';
html += '<td><input type="text" class="form-control" value="'+((derived.keys_extended.privkey)?derived.keys_extended.privkey:'')+'" readonly></td>'; html += '<td><input type="text" class="form-control" value="'+((derived.keys_extended.privkey)?derived.keys_extended.privkey:'')+'" readonly></td>';