Fix P2PK balance display in address page
This commit is contained in:
		
							parent
							
								
									5723f167df
								
							
						
					
					
						commit
						76a07315f3
					
				
							
								
								
									
										3
									
								
								contributors/ncois.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								contributors/ncois.txt
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,3 @@
 | 
			
		||||
I hereby accept the terms of the Contributor License Agreement in the CONTRIBUTING.md file of the mempool/mempool git repository as of November 16, 2023.
 | 
			
		||||
 | 
			
		||||
Signed: ncois
 | 
			
		||||
@ -156,6 +156,33 @@ export class TransactionsListComponent implements OnInit, OnChanges {
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (this.address) {
 | 
			
		||||
          const isP2PKUncompressed = this.address.length === 130;
 | 
			
		||||
          const isP2PKCompressed = this.address.length === 66;
 | 
			
		||||
          if (isP2PKCompressed) {
 | 
			
		||||
            const addressIn = tx.vout
 | 
			
		||||
              .filter((v: Vout) => v.scriptpubkey === '21' + this.address + 'ac')
 | 
			
		||||
              .map((v: Vout) => v.value || 0)
 | 
			
		||||
              .reduce((a: number, b: number) => a + b, 0);
 | 
			
		||||
 | 
			
		||||
            const addressOut = tx.vin
 | 
			
		||||
              .filter((v: Vin) => v.prevout && v.prevout.scriptpubkey === '21' + this.address + 'ac')
 | 
			
		||||
              .map((v: Vin) => v.prevout.value || 0)
 | 
			
		||||
              .reduce((a: number, b: number) => a + b, 0);
 | 
			
		||||
 | 
			
		||||
            tx['addressValue'] = addressIn - addressOut;
 | 
			
		||||
          } else if (isP2PKUncompressed) {
 | 
			
		||||
            const addressIn = tx.vout
 | 
			
		||||
              .filter((v: Vout) => v.scriptpubkey === '41' + this.address + 'ac')
 | 
			
		||||
              .map((v: Vout) => v.value || 0)
 | 
			
		||||
              .reduce((a: number, b: number) => a + b, 0);
 | 
			
		||||
 | 
			
		||||
            const addressOut = tx.vin
 | 
			
		||||
              .filter((v: Vin) => v.prevout && v.prevout.scriptpubkey === '41' + this.address + 'ac')
 | 
			
		||||
              .map((v: Vin) => v.prevout.value || 0)
 | 
			
		||||
              .reduce((a: number, b: number) => a + b, 0);
 | 
			
		||||
 | 
			
		||||
            tx['addressValue'] = addressIn - addressOut;
 | 
			
		||||
          } else {
 | 
			
		||||
            const addressIn = tx.vout
 | 
			
		||||
              .filter((v: Vout) => v.scriptpubkey_address === this.address)
 | 
			
		||||
              .map((v: Vout) => v.value || 0)
 | 
			
		||||
@ -168,6 +195,7 @@ export class TransactionsListComponent implements OnInit, OnChanges {
 | 
			
		||||
 | 
			
		||||
            tx['addressValue'] = addressIn - addressOut;
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        this.priceService.getBlockPrice$(tx.status.block_time).pipe(
 | 
			
		||||
          tap((price) => tx['price'] = price)
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user