Skip to content
Permalink
Browse files

Merge pull request #3 from loon3/dev

updated to v0.2.9
  • Loading branch information...
loon3 committed Jun 5, 2019
2 parents 300d952 + 45ac0aa commit 79d22c7ec7136b2e2944b677eed9ff44aaa7dd89
@@ -1,21 +1,12 @@
<div id="dialogTxFee-body" align="center" style="padding: 30px 20px 0px 20px; margin-bottom: -10px;" >
<div style="padding-bottom: 25px">
<div>BTC Tx Fee</div>

<div id="dialogTxFee-current" class="h3" style="padding: 10px 0 20px 0;"></div>

<div>BTC Tx Fee</div>
<div id="dialogTxFee-current" class="h3" style="padding: 10px 0 20px 0;"></div>
<div style="width: 240px; margin: auto; padding-bottom: 10px;">
<fieldset class="form-group">
<label for="dialogTxFee-new">Enter New Amount</label>
<input id="dialogTxFee-new" type="text" class="form-control" autocomplete="off" style="text-align: center" maxlength="10">
</fieldset>
</div>


<div id="dialogTxFee-message">Recommended tx fee is <span id='dialogTxFee-default'></span> BTC</div>

</div>

</div>
</div>
</div>


@@ -11,6 +11,16 @@ const observer = lozad(); // lazy loads elements with default selector as '.loza



function getBtcUsdRate(callback){

var source_html = "https://api.coindesk.com/v1/bpi/currentprice.json"

$.getJSON( source_html, function( data ) {
callback(data.bpi.USD.rate_float)
})

}

function isValidAddress(address) {

try {
@@ -173,6 +183,36 @@ function feeRecommendedCallback(callback){
})
}

function getFeeUpdate2(callback){
var source_html = "https://api.blockcypher.com/v1/btc/main"
$.getJSON( source_html, function( data ) {

var fee_recommended_priority = (parseInt(parseInt(data.high_fee_per_kb)/1000) * default_txsize_byte) / 100000000
var fee_recommended_economy = (parseInt(parseInt(data.low_fee_per_kb)/1000) * default_txsize_byte) / 100000000

chrome.storage.local.set({fee_recommended_priority: fee_recommended_priority, fee_recommended_economy: fee_recommended_economy}, function() {
chrome.storage.local.get(['fee_custom'], function(result) {
if(!result.fee_custom){
chrome.storage.local.set({fee_custom: fee_recommended_priority})
callback(fee_recommended_priority, fee_recommended_priority, fee_recommended_economy)
} else {
callback(result.fee_custom, fee_recommended_priority, fee_recommended_economy)
}

})
});
})
}

function feeRecommendedCallback2(callback){
chrome.storage.local.get(['fee_recommended_priority'], function(resultp) {
chrome.storage.local.get(['fee_recommended_economy'], function(resulte) {
callback(resultp.fee_recommended_priority, resulte.fee_recommended_economy)
})
})

}

function getutxos(add_from, mnemonic, amountremaining, callback){

var privkey = getprivkey(add_from, mnemonic);
@@ -226,7 +226,7 @@ function pageCollectAsset(assetname, assetimage, assetdivisible, assetquantity,

assetInfo += "<div align= 'center' style='position: relative; top: -30px; background-color: #38444f;'>Asset Information</div>"
assetInfo += "<div style='padding: 0 15px 0 15px;'>"
assetInfo += "<div class='row' style='width: 100%; padding: 0 0 28px 0; text-align: center; margin: auto;'><div class='col'><button type='button' class='btn btn-primary btn-block asset-send-button' data-image='"+assetimage+"' data-asset='"+assetname+"' data-qty='"+assetquantity+"' data-divisible='"+assetdivisible+"' data-alias='"+assetalias+"'>Send</button></div><div class='col'><button type='button' class='btn btn-info btn-block' disabled>Trade (Soon!)</button></div></div>"
assetInfo += "<div class='row' style='width: 100%; padding: 0 0 28px 0; text-align: center; margin: auto;'><div class='col'><button type='button' class='btn btn-primary btn-block asset-send-button' data-image='"+assetimage+"' data-asset='"+assetname+"' data-qty='"+assetquantity+"' data-divisible='"+assetdivisible+"' data-alias='"+assetalias+"'>Send</button></div><div class='col'><button type='button' class='btn btn-info btn-block' disabled>Trade (Soon!)</button></div><div class='col'><button type='button' class='btn btn-success btn-block' disabled>Sell (Soon!)</button></div></div>"

//<div class='col'><button type='button' class='btn btn-info btn-block' disabled>Trade (Soon!)</button></div><div class='col'><button type='button' class='btn btn-success btn-block' disabled>Gift (Soon!)</button></div><div class='col'><button type='button' class='btn btn-warning btn-block' disabled>Bonus (Soon!)</button></div>

@@ -369,15 +369,13 @@ function pageCollectSearchModal(){
//})



function sendAssetModal(asset, assetImage, divisible, balance, fee_custom){

feeRecommendedCallback(function(fee_recommended){
feeRecommendedCallback2(function(fee_recommended_priority, fee_recommended_economy){

if(fee_recommended != fee_custom){
var txfeebutton = "<div style='padding: 20px;'><button id='substitute-defaultfee-button' class='btn btn-warning btn-sm'>Click to replace with recommended fee<br><b>"+fee_recommended+" BTC</b></button></div>"
} else {
var txfeebutton = ""
}
var txfeebutton = addFeeButtons(fee_recommended_priority, fee_recommended_economy)


var btcbalance = $("#body").data("balance_btc")

@@ -403,6 +401,8 @@ function sendAssetModal(asset, assetImage, divisible, balance, fee_custom){
}

$(this).find(".dialog-transfee").html(fee_custom)


$(this).find('.dialog-txfeebutton').html(txfeebutton)

})
@@ -77,14 +77,11 @@ function pageCreateManage(address){

function lockAssetModal(asset, alias, address, divisible, fee_custom){

feeRecommendedCallback(function(fee_recommended){
feeRecommendedCallback2(function(fee_recommended_priority, fee_recommended_economy){

if(fee_recommended != fee_custom){
var txfeebutton = "<div style='padding: 20px;'><button id='substitute-defaultfee-button' class='btn btn-warning btn-sm'>Click to replace with recommended fee<br><b>"+fee_recommended+" BTC</b></button></div>"
} else {
var txfeebutton = ""
}

var txfeebutton = addFeeButtons(fee_recommended_priority, fee_recommended_economy)


var lockAssetDialog = new BootstrapDialog({
title: "Lock Asset",
cssClass: "modal-nofade",
@@ -148,15 +145,11 @@ function lockAssetModal(asset, alias, address, divisible, fee_custom){

function anchorImageModal(asset, alias, address, message, fee_custom){

feeRecommendedCallback(function(fee_recommended){
feeRecommendedCallback2(function(fee_recommended_priority, fee_recommended_economy){

if(fee_recommended != fee_custom){
var txfeebutton = "<div style='padding: 20px;'><button id='substitute-defaultfee-button' class='btn btn-warning btn-sm'>Click to replace with recommended fee<br><b>"+fee_recommended+" BTC</b></button></div>"
} else {
var txfeebutton = ""
}

var anchorImageDialog = new BootstrapDialog({
var txfeebutton = addFeeButtons(fee_recommended_priority, fee_recommended_economy)

var anchorImageDialog = new BootstrapDialog({
title: "Anchor Image",
cssClass: "modal-nofade",
message: function(dialog){
@@ -302,14 +295,10 @@ function uploadImgurModal_test(){

function issueAssetModal(assetid, fee_custom){

feeRecommendedCallback(function(fee_recommended){
feeRecommendedCallback2(function(fee_recommended_priority, fee_recommended_economy){

var txfeebutton = addFeeButtons(fee_recommended_priority, fee_recommended_economy)

if(fee_recommended != fee_custom){
var txfeebutton = "<div style='padding: 20px;'><button id='substitute-defaultfee-button' class='btn btn-warning btn-sm'>Click to replace with recommended fee<br><b>"+fee_recommended+" BTC</b></button></div>"
} else {
var txfeebutton = ""
}

var btcbalance = $("#body").data("balance_btc")

var assetIssueDialog = new BootstrapDialog({
@@ -248,14 +248,17 @@ function initInventory(passphrase, address){
$("#page-container-collect-content").show()

$("#page-container-collect-content").html("<div align='center'><i class='fa fa-spinner fa-spin fa-3x fa-fw'></i></div>")

getFeeUpdate(function(fee, feeRecommended){
getBtcUsdRate(function(usdRate){
$("#body").data("usd_btc", usdRate)

getFeeUpdate2(function(fee, feeRecommendedPriority, feeRecommendedEconomy){
getAddressBalance(address, function(data){
var balance = parseInt(data.balance) / 100000000

$("#body").data("balance_btc", data.balance)
$("#body").data("fee_btc", fee)
$("#body").data("fee_btc_recommended", feeRecommended)
$("#body").data("fee_btc_recommended_priority", feeRecommendedPriority)
$("#body").data("fee_btc_recommended_economy", feeRecommendedEconomy)

$("#header-balance-btc").html(balance)

@@ -270,7 +273,7 @@ function initInventory(passphrase, address){
idleCheck()
})
})

})
})


@@ -214,8 +214,19 @@ $( document ).ready(function() {
window.open(url, '_blank', "width=800,height=600,top=50,left=50")
})

$(document).on("click", 'button#substitute-defaultfee-button', function (event) {
feeRecommendedCallback(function(fee_recommended){
$(document).on("click", 'button.substitute-defaultfee-button', function (event) {

var feetype = $(this).data("feetype")
console.log(feetype)

feeRecommendedCallback2(function(fee_recommended_priority, fee_recommended_economy){

if(feetype == "priority"){
var fee_recommended = fee_recommended_priority
}else{
var fee_recommended = fee_recommended_economy
}

$("#body").data("fee_btc", fee_recommended)
$(".dialog-transfee").html(fee_recommended)
$(".dialog-txfeebutton").hide()
@@ -638,16 +649,13 @@ function balanceClickModal(currentaddr){
function txFeeModal(){

var txfee = $("#body").data("fee_btc")
var default_fee = $("#body").data("fee_btc_recommended")


var txFeeDialog = new BootstrapDialog({
title: "BTC Tx Fee",
cssClass: "modal-nofade",
message: function(dialog){
var $message = $('<div></div>').load('modal/dialog-txfee.html', function(){
$(this).find("#dialogTxFee-current").html(txfee)
$(this).find("#dialogTxFee-default").html(default_fee)
})

return $message
@@ -699,6 +707,15 @@ function txFeeModal(){
txFeeDialog.open()
}

function addFeeButtons(fee_recommended_priority, fee_recommended_economy){
var btc_usdRate = $("#body").data("usd_btc")
var fee_recommended_priority_usdRate = (parseFloat(fee_recommended_priority) * parseFloat(btc_usdRate)).toFixed(2)
var fee_recommended_economy_usdRate = (parseFloat(fee_recommended_economy) * parseFloat(btc_usdRate)).toFixed(2)

var txfeebutton = "<div style='padding: 20px;' class='row'><div class='col-6'><button class='substitute-defaultfee-button btn btn-danger btn-sm' data-feetype='priority'>Use priority fee (~20 min)<br><b>"+fee_recommended_priority+" BTC / $"+fee_recommended_priority_usdRate+"</b></button></div><div class='col-6'><button class='btn btn-primary btn-sm substitute-defaultfee-button' data-feetype='economy'>Use economy fee (~3 hrs)<br><b>"+fee_recommended_economy+" BTC / $"+fee_recommended_economy_usdRate+"</b></button></div><div class='col-12 small' style='font-style: italic; padding-top: 20px;'>Fees are paid in BTC, equivalent amount in USD for reference only.</div></div>"

return txfeebutton
}

function startWebsocket(address, bc_token){

@@ -239,7 +239,7 @@ function createIssuance_opreturn(add_from, assetid, quantity, divisible, descrip
var key = bitcoinjs.ECPair.fromWIF(privkey, NETWORK);
tx.sign(0, key);

var final_trans = tx.build().toHex();
var final_trans = tx.buildIncomplete().toHex();

callback(final_trans) //push raw tx to the bitcoin network

@@ -27,5 +27,5 @@
"manifest_version": 2,
"name": "Freeport",
"short_name": "freeport",
"version": "0.2.8"
"version": "0.2.9"
}
@@ -34,3 +34,5 @@ v0.2.6 - Link Twitter username to address
v0.2.7 - UX improvement, update Twitter link method

v0.2.8 - Fix lock divisible asset bug

v0.2.9 - Add priority and economy fee estimates

0 comments on commit 79d22c7

Please sign in to comment.
You can’t perform that action at this time.