Allow HODL transaction to define nLockTime in blockheight or date/time
it still has a small UX quirks: the radio buttons dont get restored correctly after page reload
This commit is contained in:
parent
cad1f6e98b
commit
8ac9f4207d
2 changed files with 41 additions and 5 deletions
14
index.html
14
index.html
|
@ -408,7 +408,16 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p>Enter the date and time required to release the coins: </p>
|
<p id="timeLockedRbTypeBox">
|
||||||
|
Enter the
|
||||||
|
<input type="radio" id="timeLockedRbTypeDate" name="timeLockedRbType" value="date" checked="checked">
|
||||||
|
<label for="timeLockedRbTypeDate">date and time</label>
|
||||||
|
or
|
||||||
|
<input type="radio" id="timeLockedRbTypeBlockHeight" name="timeLockedRbType" value="blockheight">
|
||||||
|
<label for="timeLockedRbTypeBlockHeight">blockheight</label>
|
||||||
|
|
||||||
|
required to release the coins:
|
||||||
|
</p>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class='col-md-6'>
|
<div class='col-md-6'>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
@ -418,6 +427,9 @@
|
||||||
<span class="glyphicon glyphicon-calendar"></span>
|
<span class="glyphicon glyphicon-calendar"></span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
<div class='input-group hidden' id='timeLockedBlockHeight'>
|
||||||
|
<input type='text' id='timeLockedBlockHeightVal' class="form-control" placeholder="Blockheight" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -369,6 +369,16 @@ $(document).ready(function() {
|
||||||
format: "MM/DD/YYYY HH:mm",
|
format: "MM/DD/YYYY HH:mm",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#timeLockedRbTypeBox input').change(function(){
|
||||||
|
if ($('#timeLockedRbTypeDate').is(':checked')){
|
||||||
|
$('#timeLockedDateTimePicker').show();
|
||||||
|
$('#timeLockedBlockHeight').hide();
|
||||||
|
} else {
|
||||||
|
$('#timeLockedDateTimePicker').hide();
|
||||||
|
$('#timeLockedBlockHeight').removeClass('hidden').show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
$("#newTimeLockedAddress").click(function(){
|
$("#newTimeLockedAddress").click(function(){
|
||||||
|
|
||||||
$("#timeLockedData").removeClass('show').addClass('hidden').fadeOut();
|
$("#timeLockedData").removeClass('show').addClass('hidden').fadeOut();
|
||||||
|
@ -380,14 +390,28 @@ $(document).ready(function() {
|
||||||
$('#timeLockedPubKey').parent().addClass('has-error');
|
$('#timeLockedPubKey').parent().addClass('has-error');
|
||||||
}
|
}
|
||||||
|
|
||||||
var date = $('#timeLockedDateTimePicker').data("DateTimePicker").date();
|
var nLockTime = -1;
|
||||||
if(!date || !date.isValid()) {
|
|
||||||
$('#timeLockedDateTimePicker').parent().addClass('has-error');
|
if ($('#timeLockedRbTypeDate').is(':checked')){
|
||||||
|
// by date
|
||||||
|
var date = $('#timeLockedDateTimePicker').data("DateTimePicker").date();
|
||||||
|
if(!date || !date.isValid()) {
|
||||||
|
$('#timeLockedDateTimePicker').parent().addClass('has-error');
|
||||||
|
}
|
||||||
|
nLockTime = date.unix()
|
||||||
|
if (nLockTime < 500000000) {
|
||||||
|
$('#timeLockedDateTimePicker').parent().addClass('has-error');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
nLockTime = parseInt($('#timeLockedBlockHeightVal').val(), 10);
|
||||||
|
if (nLockTime >= 500000000) {
|
||||||
|
$('#timeLockedDateTimePicker').parent().addClass('has-error');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(($("#timeLockedPubKey").parent().hasClass('has-error')==false) && $("#timeLockedDateTimePicker").parent().hasClass('has-error')==false){
|
if(($("#timeLockedPubKey").parent().hasClass('has-error')==false) && $("#timeLockedDateTimePicker").parent().hasClass('has-error')==false){
|
||||||
try {
|
try {
|
||||||
var hodl = coinjs.simpleHodlAddress($("#timeLockedPubKey").val(), date.unix());
|
var hodl = coinjs.simpleHodlAddress($("#timeLockedPubKey").val(), nLockTime);
|
||||||
$("#timeLockedData .address").val(hodl['address']);
|
$("#timeLockedData .address").val(hodl['address']);
|
||||||
$("#timeLockedData .script").val(hodl['redeemScript']);
|
$("#timeLockedData .script").val(hodl['redeemScript']);
|
||||||
$("#timeLockedData .scriptUrl").val(document.location.origin+''+document.location.pathname+'?verify='+hodl['redeemScript']+'#verify');
|
$("#timeLockedData .scriptUrl").val(document.location.origin+''+document.location.pathname+'?verify='+hodl['redeemScript']+'#verify');
|
||||||
|
|
Loading…
Reference in a new issue