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;
|
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 { LiquidUnblinding } from './liquid-ublinding';
|
||||||
import { RelativeUrlPipe } from '../../shared/pipes/relative-url/relative-url.pipe';
|
import { RelativeUrlPipe } from '../../shared/pipes/relative-url/relative-url.pipe';
|
||||||
import { Price, PriceService } from '../../services/price.service';
|
import { Price, PriceService } from '../../services/price.service';
|
||||||
|
import { isFeatureActive } from '../../bitcoin.utils';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-transaction',
|
selector: 'app-transaction',
|
||||||
@ -438,9 +439,9 @@ export class TransactionComponent implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
|
|
||||||
setFeatures(): void {
|
setFeatures(): void {
|
||||||
if (this.tx) {
|
if (this.tx) {
|
||||||
this.segwitEnabled = !this.tx.status.confirmed || this.tx.status.block_height >= 477120;
|
this.segwitEnabled = !this.tx.status.confirmed || isFeatureActive(this.stateService.network, this.tx.status.block_height, 'segwit');
|
||||||
this.taprootEnabled = !this.tx.status.confirmed || this.tx.status.block_height >= 709632;
|
this.taprootEnabled = !this.tx.status.confirmed || isFeatureActive(this.stateService.network, this.tx.status.block_height, 'taproot');
|
||||||
this.rbfEnabled = !this.tx.status.confirmed || this.tx.status.block_height > 399700;
|
this.rbfEnabled = !this.tx.status.confirmed || isFeatureActive(this.stateService.network, this.tx.status.block_height, 'rbf');
|
||||||
} else {
|
} else {
|
||||||
this.segwitEnabled = false;
|
this.segwitEnabled = false;
|
||||||
this.taprootEnabled = false;
|
this.taprootEnabled = false;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { Component, ChangeDetectionStrategy, OnChanges, Input } from '@angular/core';
|
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 { Transaction } from '../../interfaces/electrs.interface';
|
||||||
|
import { StateService } from '../../services/state.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-tx-features',
|
selector: 'app-tx-features',
|
||||||
@ -25,15 +26,17 @@ export class TxFeaturesComponent implements OnChanges {
|
|||||||
rbfEnabled: boolean;
|
rbfEnabled: boolean;
|
||||||
taprootEnabled: boolean;
|
taprootEnabled: boolean;
|
||||||
|
|
||||||
constructor() { }
|
constructor(
|
||||||
|
private stateService: StateService,
|
||||||
|
) { }
|
||||||
|
|
||||||
ngOnChanges() {
|
ngOnChanges() {
|
||||||
if (!this.tx) {
|
if (!this.tx) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.segwitEnabled = !this.tx.status.confirmed || this.tx.status.block_height >= 477120;
|
this.segwitEnabled = !this.tx.status.confirmed || isFeatureActive(this.stateService.network, this.tx.status.block_height, 'segwit');
|
||||||
this.taprootEnabled = !this.tx.status.confirmed || this.tx.status.block_height >= 709632;
|
this.taprootEnabled = !this.tx.status.confirmed || isFeatureActive(this.stateService.network, this.tx.status.block_height, 'taproot');
|
||||||
this.rbfEnabled = !this.tx.status.confirmed || this.tx.status.block_height > 399700;
|
this.rbfEnabled = !this.tx.status.confirmed || isFeatureActive(this.stateService.network, this.tx.status.block_height, 'rbf');
|
||||||
this.segwitGains = calcSegwitFeeGains(this.tx);
|
this.segwitGains = calcSegwitFeeGains(this.tx);
|
||||||
this.isRbfTransaction = this.tx.vin.some((v) => v.sequence < 0xfffffffe);
|
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');
|
this.isTaproot = this.tx.vin.some((v) => v.prevout && v.prevout.scriptpubkey_type === 'v1_p2tr');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user