Moved method $validateAddress

This commit is contained in:
softsimon 2021-01-11 14:30:58 +07:00
parent 905ddbb363
commit 20406fa522
No known key found for this signature in database
GPG Key ID: 488D7DCFB5A430D7
3 changed files with 6 additions and 7 deletions

View File

@ -234,6 +234,10 @@ class BitcoinApi implements AbstractBitcoinApi {
});
}
protected $validateAddress(address: string): Promise<IBitcoinApi.AddressInformation> {
return this.bitcoindClient.validateAddress(address);
}
private async $calculateFeeFromInputs(transaction: IEsploraApi.Transaction, addPrevout: boolean): Promise<IEsploraApi.Transaction> {
if (transaction.vin[0].is_coinbase) {
transaction.fee = 0;

View File

@ -31,10 +31,6 @@ class BitcoinBaseApi {
return this.bitcoindClient.getRawMemPool(true);
}
$validateAddress(address: string): Promise<IBitcoinApi.AddressInformation> {
return this.bitcoindClient.validateAddress(address);
}
}
export default new BitcoinBaseApi();

View File

@ -4,7 +4,6 @@ import { IBitcoinApi } from './bitcoin-api.interface';
import { IEsploraApi } from './esplora-api.interface';
import { IElectrumApi } from './electrum-api.interface';
import BitcoinApi from './bitcoin-api';
import bitcoinBaseApi from './bitcoin-base.api';
import mempool from '../mempool';
import logger from '../../logger';
import * as ElectrumClient from '@mempool/electrum-client';
@ -64,7 +63,7 @@ class BitcoindElectrsApi extends BitcoinApi implements AbstractBitcoinApi {
}
async $getAddress(address: string): Promise<IEsploraApi.Address> {
const addressInfo = await bitcoinBaseApi.$validateAddress(address);
const addressInfo = await this.$validateAddress(address);
if (!addressInfo || !addressInfo.isvalid) {
return ({
'address': address,
@ -117,7 +116,7 @@ class BitcoindElectrsApi extends BitcoinApi implements AbstractBitcoinApi {
}
async $getAddressTransactions(address: string, lastSeenTxId: string): Promise<IEsploraApi.Transaction[]> {
const addressInfo = await bitcoinBaseApi.$validateAddress(address);
const addressInfo = await this.$validateAddress(address);
if (!addressInfo || !addressInfo.isvalid) {
return [];
}