Use network-specific feature activation dates
This commit is contained in:
parent
130ae8c3a5
commit
9f453deceb
@ -254,3 +254,30 @@ export function selectPowerOfTen(val: number): { divider: number, unit: string }
|
||||
|
||||
return selectedPowerOfTen;
|
||||
}
|
||||
|
||||
const featureActivation = {
|
||||
mainnet: {
|
||||
rbf: 399701,
|
||||
segwit: 477120,
|
||||
taproot: 709632,
|
||||
},
|
||||
testnet: {
|
||||
rbf: 720255,
|
||||
segwit: 872730,
|
||||
taproot: 2032291,
|
||||
},
|
||||
signet: {
|
||||
rbf: 0,
|
||||
segwit: 0,
|
||||
taproot: 0,
|
||||
},
|
||||
};
|
||||
|
||||
export function isFeatureActive(network: string, height: number, feature: 'rbf' | 'segwit' | 'taproot'): boolean {
|
||||
const activationHeight = featureActivation[network || 'mainnet']?.[feature];
|
||||
if (activationHeight != null) {
|
||||
return height >= activationHeight;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ import { BlockExtended, CpfpInfo } from '../../interfaces/node-api.interface';
|
||||
import { LiquidUnblinding } from './liquid-ublinding';
|
||||
import { RelativeUrlPipe } from '../../shared/pipes/relative-url/relative-url.pipe';
|
||||
import { Price, PriceService } from '../../services/price.service';
|
||||
import { isFeatureActive } from '../../bitcoin.utils';
|
||||
|
||||
@Component({
|
||||
selector: 'app-transaction',
|
||||
@ -438,9 +439,9 @@ export class TransactionComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
|
||||
setFeatures(): void {
|
||||
if (this.tx) {
|
||||
this.segwitEnabled = !this.tx.status.confirmed || this.tx.status.block_height >= 477120;
|
||||
this.taprootEnabled = !this.tx.status.confirmed || this.tx.status.block_height >= 709632;
|
||||
this.rbfEnabled = !this.tx.status.confirmed || this.tx.status.block_height > 399700;
|
||||
this.segwitEnabled = !this.tx.status.confirmed || isFeatureActive(this.stateService.network, this.tx.status.block_height, 'segwit');
|
||||
this.taprootEnabled = !this.tx.status.confirmed || isFeatureActive(this.stateService.network, this.tx.status.block_height, 'taproot');
|
||||
this.rbfEnabled = !this.tx.status.confirmed || isFeatureActive(this.stateService.network, this.tx.status.block_height, 'rbf');
|
||||
} else {
|
||||
this.segwitEnabled = false;
|
||||
this.taprootEnabled = false;
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { Component, ChangeDetectionStrategy, OnChanges, Input } from '@angular/core';
|
||||
import { calcSegwitFeeGains } from '../../bitcoin.utils';
|
||||
import { calcSegwitFeeGains, isFeatureActive } from '../../bitcoin.utils';
|
||||
import { Transaction } from '../../interfaces/electrs.interface';
|
||||
import { StateService } from '../../services/state.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-tx-features',
|
||||
@ -25,15 +26,17 @@ export class TxFeaturesComponent implements OnChanges {
|
||||
rbfEnabled: boolean;
|
||||
taprootEnabled: boolean;
|
||||
|
||||
constructor() { }
|
||||
constructor(
|
||||
private stateService: StateService,
|
||||
) { }
|
||||
|
||||
ngOnChanges() {
|
||||
if (!this.tx) {
|
||||
return;
|
||||
}
|
||||
this.segwitEnabled = !this.tx.status.confirmed || this.tx.status.block_height >= 477120;
|
||||
this.taprootEnabled = !this.tx.status.confirmed || this.tx.status.block_height >= 709632;
|
||||
this.rbfEnabled = !this.tx.status.confirmed || this.tx.status.block_height > 399700;
|
||||
this.segwitEnabled = !this.tx.status.confirmed || isFeatureActive(this.stateService.network, this.tx.status.block_height, 'segwit');
|
||||
this.taprootEnabled = !this.tx.status.confirmed || isFeatureActive(this.stateService.network, this.tx.status.block_height, 'taproot');
|
||||
this.rbfEnabled = !this.tx.status.confirmed || isFeatureActive(this.stateService.network, this.tx.status.block_height, 'rbf');
|
||||
this.segwitGains = calcSegwitFeeGains(this.tx);
|
||||
this.isRbfTransaction = this.tx.vin.some((v) => v.sequence < 0xfffffffe);
|
||||
this.isTaproot = this.tx.vin.some((v) => v.prevout && v.prevout.scriptpubkey_type === 'v1_p2tr');
|
||||
|
Loading…
x
Reference in New Issue
Block a user