Merge pull request #4386 from mempool/mononaut/fix-electrum-p2pk
Fix electrum p2pk/scripthash format
This commit is contained in:
commit
5723f167df
@ -573,7 +573,9 @@ class BitcoinRoutes {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const addressData = await bitcoinApi.$getScriptHash(req.params.scripthash);
|
// electrum expects scripthashes in little-endian
|
||||||
|
const electrumScripthash = req.params.scripthash.match(/../g)?.reverse().join('') ?? '';
|
||||||
|
const addressData = await bitcoinApi.$getScriptHash(electrumScripthash);
|
||||||
res.json(addressData);
|
res.json(addressData);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e instanceof Error && e.message && (e.message.indexOf('too long') > 0 || e.message.indexOf('confirmed status') > 0)) {
|
if (e instanceof Error && e.message && (e.message.indexOf('too long') > 0 || e.message.indexOf('confirmed status') > 0)) {
|
||||||
@ -590,11 +592,13 @@ class BitcoinRoutes {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// electrum expects scripthashes in little-endian
|
||||||
|
const electrumScripthash = req.params.scripthash.match(/../g)?.reverse().join('') ?? '';
|
||||||
let lastTxId: string = '';
|
let lastTxId: string = '';
|
||||||
if (req.query.after_txid && typeof req.query.after_txid === 'string') {
|
if (req.query.after_txid && typeof req.query.after_txid === 'string') {
|
||||||
lastTxId = req.query.after_txid;
|
lastTxId = req.query.after_txid;
|
||||||
}
|
}
|
||||||
const transactions = await bitcoinApi.$getScriptHashTransactions(req.params.scripthash, lastTxId);
|
const transactions = await bitcoinApi.$getScriptHashTransactions(electrumScripthash, lastTxId);
|
||||||
res.json(transactions);
|
res.json(transactions);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e instanceof Error && e.message && (e.message.indexOf('too long') > 0 || e.message.indexOf('confirmed status') > 0)) {
|
if (e instanceof Error && e.message && (e.message.indexOf('too long') > 0 || e.message.indexOf('confirmed status') > 0)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user