-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathupdateFee.js
More file actions
executable file
·111 lines (81 loc) · 2.33 KB
/
updateFee.js
File metadata and controls
executable file
·111 lines (81 loc) · 2.33 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
'use strict';
const {
utils: {
aws: { dino: { updateDatabaseEntry } },
database: {
metadata: {
getFeeData
}
}
},
constants: {
aws: {
database: {
// tableNameToKey,
tableNames: { METADATA },
// metadataPartitionKeyValues: { feeData }
}
},
environment: {
isProductionMode
}
}
} = require( '@bitcoin-api/full-stack-api' );
const {
doBitcoinRequest,
constants: {
megaServerId
}
} = require( '@bitcoin-api/full-stack-backend' );
const feeMultiplier = isProductionMode ? 0.1 : 1;
// const feeMultiplier = isProductionMode ? 0.008 : 1;
const defaultFeeRate = 0.0002;
// const blessingFee = 0.00000100;
// const trinityFee = 0;
// const sacramentFee = 0;
/*
0.0002 feerate equals 1.07 Canadian Dollar default
[for a 1kB transaction (supposedly default is 250kB)]
Mar. 25, 2:04 a.m. UTC
*/
module.exports = Object.freeze( () => {
console.log( 'running updateFee, YES🐺💰💰💰💰' );
const args = [
'estimatesmartfee',
'6'
];
return doBitcoinRequest({ args }).then( results => {
const parsedBitcoinRequestResults = JSON.parse( results );
const rawFeerateValue = parsedBitcoinRequestResults.feerate;
const rawFeerateValueAsNumber = Number( rawFeerateValue );
const fee = Number.isNaN( rawFeerateValueAsNumber ) ? (
defaultFeeRate
) : rawFeerateValueAsNumber;
const tableName = METADATA;
const entry = getFeeData({
fee,
feeMultiplier,
businessFeeData: {
// can customize fee values here
payroll: {
amount: 0.00001,
},
insurance: {
amount: 0.00002,
},
commission: {
amount: 0.00003,
},
},
megaServerId
});
return updateDatabaseEntry({
tableName,
entry,
});
}).then( () => {
console.log(`
updateFee executed successfully, YES YES YES🐺💰💰💰💰
`);
});
});