2020-07-19 14:54:42 +07:00
|
|
|
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 = {
|
2022-07-26 16:29:42 +02:00
|
|
|
realizedSegwitGains: 0,
|
|
|
|
potentialSegwitGains: 0,
|
|
|
|
potentialP2shSegwitGains: 0,
|
2022-07-24 00:08:53 +02:00
|
|
|
potentialTaprootGains: 0,
|
|
|
|
realizedTaprootGains: 0
|
2020-07-19 14:54:42 +07:00
|
|
|
};
|
|
|
|
isRbfTransaction: boolean;
|
2022-07-24 19:39:13 +02:00
|
|
|
isTaproot: boolean;
|
2020-07-19 14:54:42 +07:00
|
|
|
|
|
|
|
constructor() { }
|
|
|
|
|
|
|
|
ngOnChanges() {
|
2020-07-19 15:28:27 +07:00
|
|
|
if (!this.tx) {
|
|
|
|
return;
|
|
|
|
}
|
2020-07-19 14:54:42 +07:00
|
|
|
this.segwitGains = calcSegwitFeeGains(this.tx);
|
|
|
|
this.isRbfTransaction = this.tx.vin.some((v) => v.sequence < 0xfffffffe);
|
2022-07-24 19:39:13 +02:00
|
|
|
this.isTaproot = this.tx.vin.some((v) => v.prevout && v.prevout.scriptpubkey_type === 'v1_p2tr');
|
2020-07-19 14:54:42 +07:00
|
|
|
}
|
|
|
|
}
|