Add handling of unknown inputs in api.GetTransaction
This commit is contained in:
parent
4bd43c5f47
commit
f109513464
@ -154,20 +154,24 @@ func (w *Worker) GetTransactionFromBchainTx(bchainTx *bchain.Tx, height uint32,
|
|||||||
return nil, errors.Annotatef(err, "GetTxAddresses %v", bchainVin.Txid)
|
return nil, errors.Annotatef(err, "GetTxAddresses %v", bchainVin.Txid)
|
||||||
}
|
}
|
||||||
if tas == nil {
|
if tas == nil {
|
||||||
// mempool transactions are not in TxAddresses but confirmed should be there, log a problem
|
|
||||||
if bchainTx.Confirmations > 0 {
|
|
||||||
glog.Warning("DB inconsistency: tx ", bchainVin.Txid, ": not found in txAddresses")
|
|
||||||
}
|
|
||||||
// try to load from backend
|
// try to load from backend
|
||||||
otx, _, err := w.txCache.GetTransaction(bchainVin.Txid)
|
otx, _, err := w.txCache.GetTransaction(bchainVin.Txid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == bchain.ErrTxNotFound {
|
if err == bchain.ErrTxNotFound {
|
||||||
// try to get AddrDesc using coin specific handling and continue processing the tx
|
// try to get AddrDesc using coin specific handling and continue processing the tx
|
||||||
vin.AddrDesc = w.chainParser.GetAddrDescForUnknownInput(bchainTx, i)
|
vin.AddrDesc = w.chainParser.GetAddrDescForUnknownInput(bchainTx, i)
|
||||||
|
vin.Addresses, vin.Searchable, err = w.chainParser.GetAddressesFromAddrDesc(vin.AddrDesc)
|
||||||
|
if err != nil {
|
||||||
|
glog.Warning("GetAddressesFromAddrDesc tx ", bchainVin.Txid, ", addrDesc ", vin.AddrDesc, ": ", err)
|
||||||
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
return nil, errors.Annotatef(err, "txCache.GetTransaction %v", bchainVin.Txid)
|
return nil, errors.Annotatef(err, "txCache.GetTransaction %v", bchainVin.Txid)
|
||||||
}
|
}
|
||||||
|
// mempool transactions are not in TxAddresses but confirmed should be there, log a problem
|
||||||
|
if bchainTx.Confirmations > 0 {
|
||||||
|
glog.Warning("DB inconsistency: tx ", bchainVin.Txid, ": not found in txAddresses")
|
||||||
|
}
|
||||||
if len(otx.Vout) > int(vin.Vout) {
|
if len(otx.Vout) > int(vin.Vout) {
|
||||||
vout := &otx.Vout[vin.Vout]
|
vout := &otx.Vout[vin.Vout]
|
||||||
vin.ValueSat = (*Amount)(&vout.ValueSat)
|
vin.ValueSat = (*Amount)(&vout.ValueSat)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user