2022-07-25 20:03:48 +03:00
|
|
|
async function feeRate(path) {
|
2022-07-25 19:37:16 +03:00
|
|
|
const template = await loadTemplateAsync(path)
|
2022-07-26 10:11:29 +03:00
|
|
|
Vue.component('fee-rate', {
|
|
|
|
name: 'fee-rate',
|
2022-07-25 19:37:16 +03:00
|
|
|
template,
|
|
|
|
|
2022-07-26 10:11:29 +03:00
|
|
|
props: ['rate', 'totalfee', 'sats_denominated'],
|
2022-07-25 19:37:16 +03:00
|
|
|
watch: {
|
|
|
|
immediate: true,
|
2022-07-25 19:40:35 +03:00
|
|
|
totalfee: function (newVal, oldVal) {
|
2022-07-25 19:37:16 +03:00
|
|
|
console.log('### ', newVal, oldVal)
|
|
|
|
}
|
|
|
|
},
|
2022-07-26 10:11:29 +03:00
|
|
|
computed: {
|
|
|
|
feeRate: {
|
|
|
|
get: function () {
|
|
|
|
return this['rate']
|
|
|
|
},
|
|
|
|
set: function (value) {
|
|
|
|
console.log('### computed update rate')
|
|
|
|
this.$emit('update:rate', +value)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2022-07-25 19:37:16 +03:00
|
|
|
|
|
|
|
data: function () {
|
|
|
|
return {
|
|
|
|
recommededFees: {
|
|
|
|
fastestFee: 1,
|
|
|
|
halfHourFee: 1,
|
|
|
|
hourFee: 1,
|
|
|
|
economyFee: 1,
|
|
|
|
minimumFee: 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
satBtc(val, showUnit = true) {
|
|
|
|
return satOrBtc(val, showUnit, this['sats_denominated'])
|
|
|
|
},
|
2022-07-26 10:11:29 +03:00
|
|
|
|
2022-07-25 19:37:16 +03:00
|
|
|
refreshRecommendedFees: async function () {
|
|
|
|
const {
|
|
|
|
bitcoin: {fees: feesAPI}
|
|
|
|
} = mempoolJS()
|
|
|
|
|
|
|
|
const fn = async () => feesAPI.getFeesRecommended()
|
|
|
|
this.recommededFees = await retryWithDelay(fn)
|
|
|
|
},
|
|
|
|
getFeeRateLabel: function (feeRate) {
|
|
|
|
const fees = this.recommededFees
|
|
|
|
if (feeRate >= fees.fastestFee)
|
|
|
|
return `High Priority (${feeRate} sat/vB)`
|
|
|
|
if (feeRate >= fees.halfHourFee)
|
|
|
|
return `Medium Priority (${feeRate} sat/vB)`
|
|
|
|
if (feeRate >= fees.hourFee) return `Low Priority (${feeRate} sat/vB)`
|
|
|
|
return `No Priority (${feeRate} sat/vB)`
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
created: async function () {
|
|
|
|
console.log('### created fees ')
|
|
|
|
await this.refreshRecommendedFees()
|
|
|
|
this.feeRate = this.recommededFees.halfHourFee
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|