mirror of
https://github.com/fullstack-cash/bch-api.git
synced 2026-09-21 16:52:04 -07:00
fix(ElectrumX): get methods for balance, utxos, and tx history compelte
This commit is contained in:
@@ -268,9 +268,9 @@ class Electrum {
|
||||
'blockchain.scripthash.get_balance',
|
||||
scripthash
|
||||
)
|
||||
console.log(
|
||||
`electrumResponse: ${JSON.stringify(electrumResponse, null, 2)}`
|
||||
)
|
||||
// console.log(
|
||||
// `electrumResponse: ${JSON.stringify(electrumResponse, null, 2)}`
|
||||
// )
|
||||
|
||||
return electrumResponse
|
||||
} catch (err) {
|
||||
@@ -281,6 +281,39 @@ class Electrum {
|
||||
throw err
|
||||
}
|
||||
}
|
||||
|
||||
// Returns a promise that resolves an array of transaction history for an
|
||||
// address. Expects input to be a cash address, and input validation to have
|
||||
// already been done by parent, calling function.
|
||||
async _transactionsFromElectrumx (address) {
|
||||
try {
|
||||
// Convert the address to a scripthash.
|
||||
const scripthash = _this.addressToScripthash(address)
|
||||
|
||||
if (!_this.isReady) {
|
||||
throw new Error(
|
||||
'ElectrumX server connection is not ready. Call await connectToServer() first.'
|
||||
)
|
||||
}
|
||||
|
||||
// Query the address transaction history from the ElectrumX server.
|
||||
const electrumResponse = await _this.electrumx.request(
|
||||
'blockchain.scripthash.get_history',
|
||||
scripthash
|
||||
)
|
||||
// console.log(
|
||||
// `electrumResponse: ${JSON.stringify(electrumResponse, null, 2)}`
|
||||
// )
|
||||
|
||||
return electrumResponse
|
||||
} catch (err) {
|
||||
// console.log('err1: ', err)
|
||||
|
||||
// Write out error to error log.
|
||||
wlogger.error('Error in elecrumx.js/_transactionsFromElectrumx(): ', err)
|
||||
throw err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Electrum
|
||||
|
||||
Reference in New Issue
Block a user