mirror of
https://github.com/mempool/mempool.git
synced 2025-09-27 20:39:29 +02:00
refactor simplicity tapleaf detection
This commit is contained in:
@@ -320,7 +320,7 @@ export class TaprootAddressScriptsComponent implements OnChanges {
|
|||||||
const hex = node.value.script.hex.slice(0, 300);
|
const hex = node.value.script.hex.slice(0, 300);
|
||||||
asmContent = `
|
asmContent = `
|
||||||
<div style="margin-top: 10px; border-top: 1px solid #333; padding-top: 5px; word-break: break-all; white-space: normal; font-family: monospace; font-size: 12px;">
|
<div style="margin-top: 10px; border-top: 1px solid #333; padding-top: 5px; word-break: break-all; white-space: normal; font-family: monospace; font-size: 12px;">
|
||||||
<td>Simplicity tapscript: ${hex} ${node.value.script.hex.length > 300 ? '...' : ''}</td>
|
<td>Simplicity script: ${hex} ${node.value.script.hex.length > 300 ? '...' : ''}</td>
|
||||||
</div>`;
|
</div>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -234,7 +234,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr *ngIf="vin.inner_witnessscript_asm">
|
<tr *ngIf="vin.inner_witnessscript_asm">
|
||||||
@if (isLiquid && vin.inner_simplicityscript) {
|
@if (isLiquid && vin.inner_simplicityscript) {
|
||||||
<td i18n="transactions-list.p2tr-simplicity-tapscript">P2TR Simplicity tapscript</td>
|
<td i18n="transactions-list.p2tr-simplicity-script">P2TR Simplicity script</td>
|
||||||
<td style="text-align: left;">
|
<td style="text-align: left;">
|
||||||
<div [innerHTML]="showFullScript[vindex] ? vin.inner_simplicityscript : vin.inner_simplicityscript.slice(0, 1000)"></div>
|
<div [innerHTML]="showFullScript[vindex] ? vin.inner_simplicityscript : vin.inner_simplicityscript.slice(0, 1000)"></div>
|
||||||
<div *ngIf="vin.inner_simplicityscript.length > 1000" style="display: flex;">
|
<div *ngIf="vin.inner_simplicityscript.length > 1000" style="display: flex;">
|
||||||
|
@@ -338,14 +338,15 @@ export class TransactionsListComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
} else { // check for simplicity script spends
|
} else { // check for simplicity script spends
|
||||||
for (const vin of tx.vin) {
|
for (const vin of tx.vin) {
|
||||||
if (vin.prevout?.scriptpubkey_type === 'v1_p2tr' && vin.inner_witnessscript_asm) {
|
if (vin.prevout?.scriptpubkey_type === 'v1_p2tr' && vin.inner_witnessscript_asm) {
|
||||||
const hasAnnex = vin.witness?.[vin.witness.length - 1].startsWith('50');
|
const hasAnnex = vin.witness[vin.witness.length - 1].startsWith('50');
|
||||||
// script spend
|
const isScriptSpend = vin.witness.length > (hasAnnex ? 2 : 1);
|
||||||
if (vin.witness.length > (hasAnnex ? 2 : 1)) {
|
if (isScriptSpend) {
|
||||||
const controlBlock = vin.witness[vin.witness.length - (hasAnnex ? 2 : 1)];
|
const controlBlock = hasAnnex ? vin.witness[vin.witness.length - 2] : vin.witness[vin.witness.length - 1];
|
||||||
const script = vin.witness[vin.witness.length - (hasAnnex ? 3 : 2)];
|
const scriptHex = hasAnnex ? vin.witness[vin.witness.length - 3] : vin.witness[vin.witness.length - 2];
|
||||||
// simplicity tapleaf version
|
const tapleafVersion = parseInt(controlBlock.slice(0, 2), 16) & 0xfe;
|
||||||
if (controlBlock.startsWith('be') || controlBlock.startsWith('bf')) {
|
// simplicity script spend
|
||||||
vin.inner_simplicityscript = script;
|
if (tapleafVersion === 0xbe) {
|
||||||
|
vin.inner_simplicityscript = scriptHex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -128,6 +128,7 @@ export class AddressTypeInfo {
|
|||||||
// flags
|
// flags
|
||||||
isMultisig?: { m: number, n: number };
|
isMultisig?: { m: number, n: number };
|
||||||
tapscript?: boolean;
|
tapscript?: boolean;
|
||||||
|
simplicity?: boolean;
|
||||||
|
|
||||||
constructor (network: string, address: string, type?: AddressType, vin?: Vin[], vout?: Vout) {
|
constructor (network: string, address: string, type?: AddressType, vin?: Vin[], vout?: Vout) {
|
||||||
this.network = network;
|
this.network = network;
|
||||||
@@ -157,19 +158,20 @@ export class AddressTypeInfo {
|
|||||||
if (this.type === 'v1_p2tr') {
|
if (this.type === 'v1_p2tr') {
|
||||||
for (let i = 0; i < vin.length; i++) {
|
for (let i = 0; i < vin.length; i++) {
|
||||||
const v = vin[i];
|
const v = vin[i];
|
||||||
if (v.inner_witnessscript_asm) {
|
const hasAnnex = v.witness[v.witness.length - 1].startsWith('50');
|
||||||
this.tapscript = true;
|
const isScriptSpend = v.witness.length > (hasAnnex ? 2 : 1);
|
||||||
const hasAnnex = v.witness[v.witness.length - 1].startsWith('50');
|
if (isScriptSpend) {
|
||||||
const controlBlock = hasAnnex ? v.witness[v.witness.length - 2] : v.witness[v.witness.length - 1];
|
const controlBlock = hasAnnex ? v.witness[v.witness.length - 2] : v.witness[v.witness.length - 1];
|
||||||
const scriptHex = hasAnnex ? v.witness[v.witness.length - 3] : v.witness[v.witness.length - 2];
|
const scriptHex = hasAnnex ? v.witness[v.witness.length - 3] : v.witness[v.witness.length - 2];
|
||||||
|
const tapleafVersion = parseInt(controlBlock.slice(0, 2), 16) & 0xfe;
|
||||||
|
|
||||||
if ((this.network === 'liquid' || this.network === 'liquidtestnet')
|
if (tapleafVersion === 0xc0 && v.inner_witnessscript_asm) {
|
||||||
&& (controlBlock.startsWith('be') || controlBlock.startsWith('bf'))
|
this.tapscript = true;
|
||||||
) {
|
this.processScript(new ScriptInfo('inner_witnessscript', scriptHex, v.inner_witnessscript_asm, v.witness, controlBlock, vinIds?.[i]));
|
||||||
|
} else if (this.network === 'liquid' || this.network === 'liquidtestnet' && tapleafVersion === 0xbe) {
|
||||||
|
this.simplicity = true;
|
||||||
v.inner_simplicityscript = scriptHex;
|
v.inner_simplicityscript = scriptHex;
|
||||||
this.processScript(new ScriptInfo('inner_simplicityscript', scriptHex, null, v.witness, controlBlock, vinIds?.[i]));
|
this.processScript(new ScriptInfo('inner_simplicityscript', scriptHex, null, v.witness, controlBlock, vinIds?.[i]));
|
||||||
} else {
|
|
||||||
this.processScript(new ScriptInfo('inner_witnessscript', scriptHex, v.inner_witnessscript_asm, v.witness, controlBlock, vinIds?.[i]));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user