Merge pull request #4389 from ncois/fix-p2pk-balance
Fix P2PK balance display in address page (duplicate)
This commit is contained in:
		
						commit
						59c513f2a5
					
				
							
								
								
									
										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,17 +156,45 @@ export class TransactionsListComponent implements OnInit, OnChanges { | |||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         if (this.address) { |         if (this.address) { | ||||||
|           const addressIn = tx.vout |           const isP2PKUncompressed = this.address.length === 130; | ||||||
|             .filter((v: Vout) => v.scriptpubkey_address === this.address) |           const isP2PKCompressed = this.address.length === 66; | ||||||
|             .map((v: Vout) => v.value || 0) |           if (isP2PKCompressed) { | ||||||
|             .reduce((a: number, b: number) => a + b, 0); |             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 |             const addressOut = tx.vin | ||||||
|             .filter((v: Vin) => v.prevout && v.prevout.scriptpubkey_address === this.address) |               .filter((v: Vin) => v.prevout && v.prevout.scriptpubkey === '21' + this.address + 'ac') | ||||||
|             .map((v: Vin) => v.prevout.value || 0) |               .map((v: Vin) => v.prevout.value || 0) | ||||||
|             .reduce((a: number, b: number) => a + b, 0); |               .reduce((a: number, b: number) => a + b, 0); | ||||||
| 
 | 
 | ||||||
|           tx['addressValue'] = addressIn - addressOut; |             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) | ||||||
|  |               .reduce((a: number, b: number) => a + b, 0); | ||||||
|  | 
 | ||||||
|  |             const addressOut = tx.vin | ||||||
|  |               .filter((v: Vin) => v.prevout && v.prevout.scriptpubkey_address === this.address) | ||||||
|  |               .map((v: Vin) => v.prevout.value || 0) | ||||||
|  |               .reduce((a: number, b: number) => a + b, 0); | ||||||
|  | 
 | ||||||
|  |             tx['addressValue'] = addressIn - addressOut; | ||||||
|  |           } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         this.priceService.getBlockPrice$(tx.status.block_time).pipe( |         this.priceService.getBlockPrice$(tx.status.block_time).pipe( | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user