Skip to content

Commit

Permalink
fix: minor fee calculation fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
michael1011 committed Aug 4, 2019
1 parent 6d6f2fb commit 9075469
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 21 deletions.
8 changes: 3 additions & 5 deletions lib/Boltz.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,11 @@ class Boltz {

await Promise.all(promises);

await Promise.all([
this.walletManager.init(),
this.notifications.init(),
]);

await this.walletManager.init();
await this.service.init(this.config.pairs);

await this.notifications.init();

try {
this.grpcServer.listen();
} catch (error) {
Expand Down
14 changes: 7 additions & 7 deletions lib/notifications/NotificationProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import Swap from '../db/models/Swap';
import Service from '../service/Service';
import DiscordClient from './DiscordClient';
import CommandHandler from './CommandHandler';
import { OutputType } from '../proto/boltzrpc_pb';
import ReverseSwap from '../db/models/ReverseSwap';
import BackupScheduler from '../backup/BackupScheduler';
import { SwapUpdateEvent, OrderSide } from '../consts/Enums';
import { NotificationConfig, CurrencyConfig } from '../Config';
import { OutputType, CurrencyInfo, LndInfo, ChainInfo } from '../proto/boltzrpc_pb';
import {
splitPairId,
getInvoiceAmt,
Expand Down Expand Up @@ -84,15 +84,15 @@ class NotificationProvider {
private checkConnections = async () => {
const info = await this.service.getInfo();

info.getChainsMap().forEach(async ([symbol, chain]) => {
await this.checkConnection(`${symbol} node`, chain.chain);
await this.checkConnection(`${symbol} LND`, chain.lnd);
info.getChainsMap().forEach(async (currency: CurrencyInfo, symbol: string) => {
await this.checkConnection(`${symbol} LND`, currency.getLnd());
await this.checkConnection(`${symbol} node`, currency.getChain());
});
}

private checkConnection = async (service: string, object: { error: string } | undefined) => {
if (object) {
if (object.error === '') {
private checkConnection = async (service: string, object: ChainInfo | LndInfo | undefined) => {
if (object !== undefined) {
if (object.getError() === '') {
if (this.disconnected.has(service)) {
this.disconnected.delete(service);
await this.sendReconnected(service);
Expand Down
4 changes: 2 additions & 2 deletions lib/rates/FeeProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class FeeProvider {
public percentageFees = new Map<string, number>();

public static transactionSizes = {
normalClaim: 140,
normalClaim: 170,

reverseLockup: 153,
reverseClaim: 138,
Expand Down Expand Up @@ -64,7 +64,7 @@ class FeeProvider {
return satPerVbyte * FeeProvider.transactionSizes.reverseLockup;
} else {
// The claim transaction which spends a nested SegWit swap output and
// sends it to a P2WPKH address has about 140 vbytes
// sends it to a P2WPKH address has about 170 vbytes
return satPerVbyte * FeeProvider.transactionSizes.normalClaim;
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/service/Service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ class Service {
) => {
const swap = await this.swapRepository.getSwapByInvoice(invoice);

if (swap !== undefined) {
if (swap) {
throw Errors.SWAP_WITH_INVOICE_EXISTS();
}

Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"inquirer": "^6.5.0",
"node-forge": "^0.8.5",
"node-schedule": "^1.3.2",
"sequelize": "^5.12.2",
"sequelize": "^5.12.3",
"sqlite3": "^4.0.9",
"toml": "^3.0.0",
"typescript": "^3.5.3",
Expand Down
4 changes: 2 additions & 2 deletions test/unit/rates/FeeProvider.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ describe('FeeProvider', () => {
]);

const expected = [
5040,
6120,
5508,

420,
510,
459,
];

Expand Down

0 comments on commit 9075469

Please sign in to comment.