better identification of lightning outputs. (#320)

* better identification of lightning outputs.
* identify liquid pegouts and emergency pegouts.
fixes #324
This commit is contained in:
fiatjaf 2021-02-03 02:40:31 -03:00 committed by GitHub
parent 448cb8e264
commit 276117fba9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 40 additions and 7 deletions

View File

@ -1,2 +1,18 @@
<span *ngIf="multisig" class="badge badge-pill badge-warning" i18n="address-labels.multisig">multisig {{ multisigM }} of {{ multisigN }}</span>
<span *ngIf="secondLayerClose" class="badge badge-pill badge-warning" i18n="address-labels.upper-layer-peg-out">Layer{{ network === 'liquid' ? '3' : '2' }} Peg-out</span>
<span
*ngIf="multisig"
class="badge badge-pill badge-warning"
i18n="address-labels.multisig"
>multisig {{ multisigM }} of {{ multisigN }}</span
>
<span
*ngIf="lightning"
class="badge badge-pill badge-warning"
i18n="address-labels.upper-layer-peg-out"
>Lightning {{ lightning }}</span
>
<span
*ngIf="liquid"
class="badge badge-pill badge-warning"
i18n="address-labels.upper-layer-peg-out"
>Liquid {{ liquid }}</span
>

View File

@ -18,7 +18,8 @@ export class AddressLabelsComponent implements OnInit {
multisigM: number;
multisigN: number;
secondLayerClose = false;
lightning = null;
liquid = null;
constructor(
stateService: StateService,
@ -36,6 +37,26 @@ export class AddressLabelsComponent implements OnInit {
handleVin() {
if (this.vin.inner_witnessscript_asm) {
if (this.vin.inner_witnessscript_asm.indexOf('OP_DEPTH OP_PUSHNUM_12 OP_EQUAL OP_IF OP_PUSHNUM_11') === 0) {
if (this.vin.witness.length > 11) {
this.liquid = 'Peg Out';
} else {
this.liquid = 'Emergency Peg Out';
}
}
[
[/^OP_DUP OP_HASH160/, 'HTLC'],
[/^OP_IF OP_PUSHBYTES_33 \w{33} OP_ELSE OP_PUSHBYTES_2 \w{2} OP_CSV OP_DROP/, 'Force Close']
].forEach(
([re, label]) => {
if (re.test(this.vin.inner_witnessscript_asm)) {
this.lightning = label;
return;
}
}
);
if (this.vin.inner_witnessscript_asm.indexOf('OP_CHECKMULTISIG') > -1) {
const matches = this.getMatches(this.vin.inner_witnessscript_asm, /OP_PUSHNUM_([0-9])/g, 1);
this.multisig = true;
@ -46,10 +67,6 @@ export class AddressLabelsComponent implements OnInit {
this.multisig = false;
}
}
if (/OP_IF (.+) OP_ELSE (.+) OP_CSV OP_DROP/.test(this.vin.inner_witnessscript_asm)) {
this.secondLayerClose = true;
}
}
if (this.vin.inner_redeemscript_asm && this.vin.inner_redeemscript_asm.indexOf('OP_CHECKMULTISIG') > -1) {