Skip to content

Commit

Permalink
add outpoint display with electrum 1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
Pantamis committed Jul 22, 2021
1 parent 83ae26f commit ea2b712
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
19 changes: 19 additions & 0 deletions app/api/electrumAddressApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,25 @@ function lookupTxBlockHash(txid) {
});
}

// Lookup the spending transaction and height of a given transaction output. Only works with Electrum 1.5 protocol

function lookupOutpointTx(txid, txout_idx) {
if (electrumClients.length == 0) {
return Promise.reject({ error: "No Electrum Server Connection", userText: noConnectionsErrorText });
}

return runOnAllServers(function(electrumClient) {
return electrumClient.request('blockchain.outpoint.subscribe', [txid, txout_idx]);
}).then(function(results) {
if (results.length <= 2) {
return electrumClient.request('blockchain.outpoint.unsubscribe', [txid, txout_idx]);
} else {
return results[1].slice(1)
}
});
}


function logStats(cmd, dt, success) {
if (!global.electrumStats.rpc[cmd]) {
global.electrumStats.rpc[cmd] = {count:0, time:0, successes:0, failures:0};
Expand Down
Binary file added btc-rpc-explorer-node-details.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 15 additions & 3 deletions views/includes/transaction-io-details.pug
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ mixin asciiHexDataDisplay(dataName, uniqueId, hex)
a(href=`./tx/${txInput.txid}#output-${txVin.vout}`) #{utils.ellipsize(txInput.txid, 20)}[#{txVin.vout}]

else

0


.tx-io-value.mt-3.mt-md-0
Expand Down Expand Up @@ -195,6 +195,10 @@ mixin asciiHexDataDisplay(dataName, uniqueId, hex)
- hiddenRow = true;
- hiddenRowCount++;

- var spent = false;
if (false && config.electrumServers && config.electrumServers.length > 0)
- spent = electrumAddressApi.lookupOutpointTx(vout, voutIndex)

div(data-txid=tx.txid, class=(hiddenRow ? "d-none" : ""))
.clearfix
.tx-io-label
Expand All @@ -220,9 +224,17 @@ mixin asciiHexDataDisplay(dataName, uniqueId, hex)
+darkBadge
span(title=`Output Type: ${utils.outputTypeName(vout.scriptPubKey.type)}`, data-bs-toggle="tooltip") #{utils.outputTypeAbbreviation(vout.scriptPubKey.type)}

if (spent)
.word-wrap
a(href=`./tx/${spent[0]}#output-${voutIndex}`) #{utils.ellipsizeMiddle(spent[0], 22)}
span ##{voutIndex}
each addr in vout.scriptPubKey.addresses
a(id=`output-${voutIndex}`, href=`./address/${addr}`)
span.font-monospace.word-wrap(class=(highlightRow ? "text-info" : null)) #{addr}
if (spent)
span.me-1 (addr:
a(id=`output-${voutIndex}`, href=`./address/${addr}`) #{addr})
else
a(id=`output-${voutIndex}`, href=`./address/${addr}`)
span.font-monospace.word-wrap(class=(highlightRow ? "text-info" : null)) #{addr}

if (highlightRow)
span(title="Current address", data-bs-toggle="tooltip")
Expand Down

0 comments on commit ea2b712

Please sign in to comment.