Address chart support p2pks
This commit is contained in:
		
							parent
							
								
									82f1fa5110
								
							
						
					
					
						commit
						2c16dda7c0
					
				| @ -22,6 +22,7 @@ import { AmountShortenerPipe } from '../../shared/pipes/amount-shortener.pipe'; | |||||||
| }) | }) | ||||||
| export class AddressGraphComponent implements OnInit, OnChanges { | export class AddressGraphComponent implements OnInit, OnChanges { | ||||||
|   @Input() address: string; |   @Input() address: string; | ||||||
|  |   @Input() isPubkey: boolean = false; | ||||||
|   @Input() stats: ChainStats; |   @Input() stats: ChainStats; | ||||||
|   @Input() right: number | string = 10; |   @Input() right: number | string = 10; | ||||||
|   @Input() left: number | string = 70; |   @Input() left: number | string = 70; | ||||||
| @ -49,7 +50,9 @@ export class AddressGraphComponent implements OnInit, OnChanges { | |||||||
| 
 | 
 | ||||||
|   ngOnChanges(changes: SimpleChanges): void { |   ngOnChanges(changes: SimpleChanges): void { | ||||||
|     this.isLoading = true; |     this.isLoading = true; | ||||||
|     this.electrsApiService.getAddressSummary$(this.address).pipe( |     (this.isPubkey | ||||||
|  |       ? this.electrsApiService.getScriptHashSummary$((this.address.length === 66 ? '21' : '41') + this.address + 'ac') | ||||||
|  |       : this.electrsApiService.getAddressSummary$(this.address)).pipe( | ||||||
|       catchError(e => { |       catchError(e => { | ||||||
|         this.error = `Failed to fetch address balance history: ${e?.status || ''} ${e?.statusText || 'unknown error'}`; |         this.error = `Failed to fetch address balance history: ${e?.status || ''} ${e?.statusText || 'unknown error'}`; | ||||||
|         return of(null); |         return of(null); | ||||||
|  | |||||||
| @ -56,7 +56,7 @@ | |||||||
|       <div class="box"> |       <div class="box"> | ||||||
|         <div class="row"> |         <div class="row"> | ||||||
|           <div class="col-md"> |           <div class="col-md"> | ||||||
|             <app-address-graph [address]="addressString" [stats]="address.chain_stats" /> |             <app-address-graph [address]="addressString" [isPubkey]="address?.is_pubkey" [stats]="address.chain_stats" /> | ||||||
|           </div> |           </div> | ||||||
|         </div> |         </div> | ||||||
|       </div> |       </div> | ||||||
|  | |||||||
| @ -159,6 +159,16 @@ export class ElectrsApiService { | |||||||
|     ); |     ); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|  |   getScriptHashSummary$(script: string,  txid?: string): Observable<AddressTxSummary[]> { | ||||||
|  |     let params = new HttpParams(); | ||||||
|  |     if (txid) { | ||||||
|  |       params = params.append('after_txid', txid); | ||||||
|  |     } | ||||||
|  |     return from(calcScriptHash$(script)).pipe( | ||||||
|  |       switchMap(scriptHash => this.httpClient.get<AddressTxSummary[]>(this.apiBaseUrl + this.apiBasePath + '/api/scripthash/' + scriptHash + '/txs/summary', { params })), | ||||||
|  |     ); | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|   getAsset$(assetId: string): Observable<Asset> { |   getAsset$(assetId: string): Observable<Asset> { | ||||||
|     return this.httpClient.get<Asset>(this.apiBaseUrl + this.apiBasePath + '/api/asset/' + assetId); |     return this.httpClient.get<Asset>(this.apiBaseUrl + this.apiBasePath + '/api/asset/' + assetId); | ||||||
|   } |   } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user