Browse Source

spv, zero conf tx fix

v0.25
pbca26 7 years ago
parent
commit
50466ea8f9
  1. 4
      routes/shepherd/electrum/listunspent.js
  2. 10
      routes/shepherd/electrum/transactions.js

4
routes/shepherd/electrum/listunspent.js

@ -61,7 +61,7 @@ module.exports = (shepherd) => {
amountSats: _utxoItem.value, amountSats: _utxoItem.value,
interest: interest, interest: interest,
interestSats: Math.floor(interest * 100000000), interestSats: Math.floor(interest * 100000000),
confirmations: currentHeight - _utxoItem.height, confirmations: Number(_utxoItem.height) === 0 ? 0 : currentHeight - _utxoItem.height,
spendable: true, spendable: true,
verified: false, verified: false,
}; };
@ -87,7 +87,7 @@ module.exports = (shepherd) => {
address, address,
amount: Number(_utxoItem.value) * 0.00000001, amount: Number(_utxoItem.value) * 0.00000001,
amountSats: _utxoItem.value, amountSats: _utxoItem.value,
confirmations: currentHeight - _utxoItem.height, confirmations: Number(_utxoItem.height) === 0 ? 0 : currentHeight - _utxoItem.height,
spendable: true, spendable: true,
verified: false, verified: false,
}; };

10
routes/shepherd/electrum/transactions.js

@ -107,8 +107,8 @@ module.exports = (shepherd) => {
inputs: txInputs, inputs: txInputs,
outputs: decodedTx.outputs, outputs: decodedTx.outputs,
height: transaction.height, height: transaction.height,
timestamp: blockInfo.timestamp, timestamp: Number(transaction.height) === 0 ? Math.floor(Date.now() / 1000) : blockInfo.timestamp,
confirmations: currentHeight - transaction.height, confirmations: Number(transaction.height) === 0 ? 0 : currentHeight - transaction.height,
}; };
const formattedTx = shepherd.parseTransactionAddresses(_parsedTx, req.query.address, network); const formattedTx = shepherd.parseTransactionAddresses(_parsedTx, req.query.address, network);
@ -149,8 +149,8 @@ module.exports = (shepherd) => {
inputs: 'cant parse', inputs: 'cant parse',
outputs: 'cant parse', outputs: 'cant parse',
height: transaction.height, height: transaction.height,
timestamp: blockInfo.timestamp, timestamp: Number(transaction.height) === 0 ? Math.floor(Date.now() / 1000) : blockInfo.timestamp,
confirmations: currentHeight - transaction.height, confirmations: Number(transaction.height) === 0 ? 0 : currentHeight - transaction.height,
}; };
const formattedTx = shepherd.parseTransactionAddresses(_parsedTx, req.query.address, network); const formattedTx = shepherd.parseTransactionAddresses(_parsedTx, req.query.address, network);
@ -166,7 +166,7 @@ module.exports = (shepherd) => {
outputs: 'cant parse', outputs: 'cant parse',
height: transaction.height, height: transaction.height,
timestamp: 'cant get block info', timestamp: 'cant get block info',
confirmations: currentHeight - transaction.height, confirmations: Number(transaction.height) === 0 ? 0 : currentHeight - transaction.height,
}; };
const formattedTx = shepherd.parseTransactionAddresses(_parsedTx, req.query.address, network); const formattedTx = shepherd.parseTransactionAddresses(_parsedTx, req.query.address, network);
_rawtx.push(formattedTx); _rawtx.push(formattedTx);

Loading…
Cancel
Save