-
Notifications
You must be signed in to change notification settings - Fork 2
/
calcfee.js
34 lines (24 loc) · 849 Bytes
/
calcfee.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
function calcfee( count, averageFileSize, feeRate ) {
// utxoOutputValue = 10000
utxoOutputValue = 1000
commitTxSize = 68 + (43 + 1)
commitTxSize += 64
revealTxSize = 10.5 + (57.5 + 43)
revealTxSize += 64
feeSats = Math.ceil( ( averageFileSize / 4 + commitTxSize + revealTxSize ) * feeRate )
feeSats = 1e3 * Math.ceil(feeSats / 1e3)
feeSats = feeSats * count
baseService = 1000 * Math.ceil(feeSats * 0.1 / 1000)
feeSats += baseService
total = feeSats + utxoOutputValue * count
return total
}
function test() {
f = calcfee(1, 550, 10)
console.log('每个: ', f, 'sats')
console.log('每个: ', f * 30185/1e8 , 'USD')
console.log('900个: ', f * 30185/1e8 *900, 'USD')
console.log('900个: ', f * 900 , 'sats')
console.log('900个: ', f * 900 /1e8, 'BTC')
}
test()