Address page with QR code

This commit is contained in:
Simon Lindh
2019-11-13 14:51:44 +08:00
parent 309e851ead
commit 480016ef07
18 changed files with 8241 additions and 93 deletions

View File

@@ -13,4 +13,7 @@ export interface AbstractBitcoinApi {
getBlockTransactionsFromIndex(hash: string, index: number): Promise<IBlock>;
getBlocks(): Promise<string>;
getBlocksFromHeight(height: number): Promise<string>;
getAddress(address: string): Promise<IBlock>;
getAddressTransactions(address: string): Promise<IBlock>;
getAddressTransactionsFromLastSeenTxid(address: string, lastSeenTxid: string): Promise<IBlock>;
}

View File

@@ -84,22 +84,27 @@ class BitcoindApi implements AbstractBitcoinApi {
getBlock(hash: string): Promise<IBlock> {
throw new Error('Method not implemented.');
}
getBlocks(): Promise<string> {
throw new Error('Method not implemented.');
}
getBlocksFromHeight(height: number): Promise<string> {
throw new Error('Method not implemented.');
}
getBlockTransactions(hash: string): Promise<IBlock> {
throw new Error('Method not implemented.');
}
getBlockTransactionsFromIndex(hash: string, index: number): Promise<IBlock> {
throw new Error('Method not implemented.');
}
getAddress(address: string): Promise<IBlock> {
throw new Error('Method not implemented.');
}
getAddressTransactions(address: string): Promise<IBlock> {
throw new Error('Method not implemented.');
}
getAddressTransactionsFromLastSeenTxid(address: string, lastSeenTxid: string): Promise<IBlock> {
throw new Error('Method not implemented.');
}
}
export default BitcoindApi;

View File

@@ -149,6 +149,39 @@ class EsploraApi implements AbstractBitcoinApi {
}
});
}
getAddress(address: string): Promise<IBlock> {
return new Promise(async (resolve, reject) => {
try {
const blockInfo: AxiosResponse = await this.client.get('/address/' + address);
resolve(blockInfo.data);
} catch (error) {
reject(error);
}
});
}
getAddressTransactions(address: string): Promise<IBlock> {
return new Promise(async (resolve, reject) => {
try {
const blockInfo: AxiosResponse = await this.client.get('/address/' + address + '/txs');
resolve(blockInfo.data);
} catch (error) {
reject(error);
}
});
}
getAddressTransactionsFromLastSeenTxid(address: string, lastSeenTxid: string): Promise<IBlock> {
return new Promise(async (resolve, reject) => {
try {
const blockInfo: AxiosResponse = await this.client.get('/address/' + address + '/txs/chain/' + lastSeenTxid);
resolve(blockInfo.data);
} catch (error) {
reject(error);
}
});
}
}
export default EsploraApi;