Refactored "features" and "fee rating" from transaction into components.

This commit is contained in:
softsimon
2020-07-19 14:54:42 +07:00
parent c893608a41
commit cca69556d0
10 changed files with 129 additions and 74 deletions

View File

@@ -0,0 +1,27 @@
import { Component, ChangeDetectionStrategy, OnChanges, Input } from '@angular/core';
import { calcSegwitFeeGains } from 'src/app/bitcoin.utils';
import { Transaction } from 'src/app/interfaces/electrs.interface';
@Component({
selector: 'app-tx-features',
templateUrl: './tx-features.component.html',
styleUrls: ['./tx-features.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class TxFeaturesComponent implements OnChanges {
@Input() tx: Transaction;
segwitGains = {
realizedGains: 0,
potentialBech32Gains: 0,
potentialP2shGains: 0,
};
isRbfTransaction: boolean;
constructor() { }
ngOnChanges() {
this.segwitGains = calcSegwitFeeGains(this.tx);
this.isRbfTransaction = this.tx.vin.some((v) => v.sequence < 0xfffffffe);
}
}