Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bbupdate rebase #10

Open
wants to merge 112 commits into
base: bbupdate
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
112 commits
Select commit Hold shift + click to select a range
707ac28
Bump Groestlcoin backend version to 2.19.1
gruve-p May 11, 2020
bad9f99
eth-like backends listen on localhost instead *
testi3123 May 16, 2020
3ebe99e
Add support for DigiByte Testnet (#432)
ac0uk May 19, 2020
b957ed6
Add fiat rate(monacoin)
wakiyamap May 15, 2020
dd2dc6b
Add sentToSelf to BalanceHistory
martinboehm May 19, 2020
e60c320
Allow parameters value, gasPrice and gas to be passed to ETH estimateFee
martinboehm May 20, 2020
ff607bc
Check ERC20 contract balance if no transactions were done for address
martinboehm May 21, 2020
01d8e48
Unconfirmed eth balance not being updated #408
martinboehm May 21, 2020
76324be
Modify logging
martinboehm May 21, 2020
bc001ce
Make logs cleaner by not logging public API errors in websocket
martinboehm May 22, 2020
0a3ea6e
Send websocket notification on new tx for input addresses
martinboehm May 24, 2020
3be3bb5
Regenerate registry of ports
martinboehm May 24, 2020
dd79642
Suppress logging of MQ errors
martinboehm May 24, 2020
994567a
Add fee value to unspent transactions balance
martinboehm May 26, 2020
7d6c616
zec (+testnet): Bump backend 2.1.2->3.0.0
May 29, 2020
5350027
btc (+testnet): Bump backend 0.19.0.1->0.20.0
Jun 3, 2020
eb4e10a
Bump Blockbook version to 0.3.4
martinboehm Jun 12, 2020
abb6453
Fix dash testnet config #447
martinboehm Jun 22, 2020
30149e5
ltc (+testnet): Bump backend 0.17.1->0.18.1
Dehumanizer77 Jun 29, 2020
92ae205
etc: Bump backend 1.11.2->1.11.7
Dehumanizer77 Jun 29, 2020
22145d0
bump Qtum 0.19.1
icodeface Jun 22, 2020
83616bc
Fix integration tests script
martinboehm Jun 30, 2020
07ac3c8
bcash (+testnet): Bump backend 0.21.0 -> 0.21.10
Jul 7, 2020
af5e8f1
Bump Ravencoin backend to 4.2.1.0
Scotty0448 Jul 10, 2020
7919486
bgold: 0.15.2->0.17.2
1000101 Jul 11, 2020
17c9080
Include eth transactions in unknown status into balance history
martinboehm Jul 30, 2020
ab285c6
Increase max size of reorg of ETC to 10000 blocks
martinboehm Aug 6, 2020
a530f56
btc(+testnet): 0.20.0->0.20.1
1000101 Aug 19, 2020
2fb1e77
etc: 1.11.7->1.11.12
1000101 Aug 19, 2020
79907e7
Update Zcoin transaction parser and bump binary version (#466)
thebevrishot Aug 20, 2020
be73064
eth(+testnet): 1.9.13->1.9.19
1000101 Aug 19, 2020
f99406e
zec(+testnet): 3.0.0->3.1.0
1000101 Aug 19, 2020
e66fa79
btg: 0.17.2->0.17.3
1000101 Aug 19, 2020
0f4eadd
nix: add trivial shell.nix for development
prusnak Aug 20, 2020
a83cb76
Update build documentation
braydonf Aug 20, 2020
7b70ee0
Add blockchaincfg.json to .gitignore
braydonf Aug 20, 2020
81ce876
nix: add dependencies to shell.nix
prusnak Aug 21, 2020
52cbc71
eth(+testnet): 1.9.19->1.9.20
1000101 Aug 25, 2020
a8ee6ae
bch(+testnet): 0.21.10->0.22.0
1000101 Aug 25, 2020
72486c6
Bump Groestlcoin backend version to 2.20.1
gruve-p Aug 22, 2020
bea6b62
Add fiat rates for Groestlcoin
gruve-p Aug 26, 2020
a199317
Go ethereum v1.9.20 (#482) issue #481
martinboehm Sep 3, 2020
7f1cf09
zec (+testnet): 3.1.0 -> 4.0.0
1000101 Sep 7, 2020
dcf77a5
Bump Koto to 4.0.0
wo01 Sep 14, 2020
b05346b
eth (+testnet): 1.9.20 -> 1.9.21
1000101 Sep 9, 2020
4832205
etc: 1.11.12 -> 1.11.15
Oct 6, 2020
e666e7c
Bump Ritocoin backend to 2.4.2.0
Scotty0448 Oct 14, 2020
ec79702
Bump DeepOnion Version to v2.2
nezero Nov 5, 2020
214d014
Ignore DeepOnion QT
nezero Nov 5, 2020
3d9954b
Improve locking and add panic handlers to websocket functionality
martinboehm Oct 29, 2020
fc25200
Fix ineffassign errors
martinboehm Nov 12, 2020
5534372
[Zcash] Expose zcash consensus info (#508)
hewigovens Nov 12, 2020
3369295
bch(+testnet): 0.22.0 -> 0.22.6 (switch to BCHN) (#511)
prusnak Nov 16, 2020
c915f35
bch(+testnet): 0.22.6 -> 22.1.0 (switch to Bitcoin Cash Node)
prusnak Nov 16, 2020
5e7d0e9
etc: 1.11.15 → 1.11.18
Dehumanizer77 Nov 16, 2020
bc00945
dash (+testnet): 0.15.0.0 → 0.16.0.1
Dehumanizer77 Nov 16, 2020
2b786c9
eth (+testnet): 1.9.21 → 1.9.24
Dehumanizer77 Nov 16, 2020
6274f4b
zcash (+testnet): 4.0.0 → 4.1.0
Dehumanizer77 Nov 16, 2020
3ccfd18
zcash (+testnet): 4.1.0 → 4.1.1
Dehumanizer77 Nov 20, 2020
786047f
Updating the API docs so it shows more information about the web sock…
martin-key Dec 3, 2020
576b8b5
Upgrade to go 1.15.6, rocksdb 6.13.3 and other dependecies
martinboehm Nov 12, 2020
579b42c
Stop using mod vendor in Blockbook build
martinboehm Nov 13, 2020
24a783b
Move websocket connection close out of channel close mutex
martinboehm Nov 15, 2020
636167c
Store to txcache old eth transactions without status
martinboehm Nov 18, 2020
248de3c
Detect fork in connectBlocks loop
martinboehm Nov 25, 2020
69d13e0
Fix ETH Ropsten: websocket: read limit exceeded #490
martinboehm Nov 25, 2020
fc267ed
Return for mempool transactions coinSpecificData #522
martinboehm Nov 27, 2020
da1c0d7
Unify error handling of GetTransactionSpecific #395
martinboehm Nov 28, 2020
c0c2dc4
You have to link against libdl on Linux
CryptoManiac Jun 17, 2020
00352cb
Merge branch 'docs' of https://github.com/braydonf/blockbook into bra…
martinboehm Dec 4, 2020
f094ee5
Merge branch 'braydonf-docs'
martinboehm Dec 4, 2020
96e8329
Update documentation #483
martinboehm Dec 4, 2020
d12e655
bump Qtum 0.20.1
Dec 5, 2020
316a8e8
Begin filecoin implementation
cpacia May 18, 2020
dceabf4
Add filecoin.json
cpacia May 18, 2020
247a015
Second pass rpc
cpacia May 25, 2020
c65bca2
Update filecoinrpc
cpacia Jun 2, 2020
b59a0bc
Filecoin chain sync wired up
cpacia Jun 11, 2020
e9a3393
Update GetBlockHash method
cpacia Jun 15, 2020
e6b4666
Use hashes of tipset key
cpacia Jun 16, 2020
0db6c66
Fix bug getting block header
cpacia Jun 18, 2020
55a32b1
Check if next block exists in GetBlockHeader
cpacia Jun 18, 2020
0143654
Use bchain not found error
cpacia Jun 19, 2020
b0a25a3
Switch to bitcoin chain type
cpacia Jun 20, 2020
ccee364
Fix GetBlockInfo
cpacia Jun 20, 2020
c83a84e
Fix saving block hashes at tip
cpacia Jun 23, 2020
c9b6455
Update mempool functionality
cpacia Jun 25, 2020
1b7c3b5
Change up GetAddrDescFromAddress
hoffmabc Jun 25, 2020
7275894
Add EthereumTypeGetBalance
hoffmabc Jun 25, 2020
92b81e7
Make server ip a config param
cpacia Jun 26, 2020
c8c5e84
Make block hash 39 bytes
cpacia Jun 26, 2020
2203418
Fix for updated filecoin version
hoffmabc Jun 27, 2020
c7ebed0
Update lotus version
hoffmabc Jun 27, 2020
a0eb446
Retry chain and mpool subscriptions on closed channel
cpacia Jun 30, 2020
7272513
Switch to 38 bytes len txid
cpacia Jul 14, 2020
af08eda
Save tx height in badger db
cpacia Jul 16, 2020
c1c547c
Correctly save input txid
cpacia Jul 16, 2020
8ab7ea9
Save tx hex in transaction
cpacia Jul 16, 2020
2e56f7e
Save blocktime in badger db
cpacia Jul 16, 2020
8ff26d8
Fix blocktime
cpacia Jul 16, 2020
8acec70
Set CoinSpecifcData in txs
cpacia Jul 20, 2020
0f3b081
Fix filecoin confirmations
cpacia Jul 20, 2020
94c3970
Update filecoin dep
cpacia Jul 27, 2020
a8749c4
Fix filecoin mismatched txid
cpacia Jul 29, 2020
04abaff
Update powergate and blockbook libs
cpacia Oct 13, 2020
d958f18
Upate go.mod file
cpacia Oct 16, 2020
ef52310
Save nil tipsets when new blocks arrive
cpacia Nov 9, 2020
97107c4
Add extra logging
cpacia Nov 25, 2020
d5bf70c
Fix for double transactions
hoffmabc Aug 4, 2020
7751737
Add formatting to errors
szollo Nov 11, 2020
bc0f098
Make sure db is synced prior to calling getblockhash
cpacia Dec 1, 2020
b111db3
Merge branch 'bbupdate' into bbupdate-rebase
hoffmabc Dec 14, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ debug*
docker/blockbook
build/pkg-defs
build/blockbook
build/blockchaincfg.json
build/ldb
build/sst_dump
build/*.deb
Expand Down
17 changes: 8 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,35 @@ BIN_IMAGE = blockbook-build
DEB_IMAGE = blockbook-build-deb
PACKAGER = $(shell id -u):$(shell id -g)
NO_CACHE = false
UPDATE_VENDOR = 1
ARGS ?=

TARGETS=$(subst .json,, $(shell ls configs/coins))

.PHONY: build build-debug test deb

build: .bin-image
docker run -t --rm -e PACKAGER=$(PACKAGER) -e UPDATE_VENDOR=$(UPDATE_VENDOR) -v "$(CURDIR):/src" -v "$(CURDIR)/build:/out" $(BIN_IMAGE) make build ARGS="$(ARGS)"
docker run -t --rm -e PACKAGER=$(PACKAGER) -v "$(CURDIR):/src" -v "$(CURDIR)/build:/out" $(BIN_IMAGE) make build ARGS="$(ARGS)"

build-debug: .bin-image
docker run -t --rm -e PACKAGER=$(PACKAGER) -e UPDATE_VENDOR=$(UPDATE_VENDOR) -v "$(CURDIR):/src" -v "$(CURDIR)/build:/out" $(BIN_IMAGE) make build-debug ARGS="$(ARGS)"
docker run -t --rm -e PACKAGER=$(PACKAGER) -v "$(CURDIR):/src" -v "$(CURDIR)/build:/out" $(BIN_IMAGE) make build-debug ARGS="$(ARGS)"

test: .bin-image
docker run -t --rm -e PACKAGER=$(PACKAGER) -e UPDATE_VENDOR=$(UPDATE_VENDOR) -v "$(CURDIR):/src" --network="host" $(BIN_IMAGE) make test ARGS="$(ARGS)"
docker run -t --rm -e PACKAGER=$(PACKAGER) -v "$(CURDIR):/src" --network="host" $(BIN_IMAGE) make test ARGS="$(ARGS)"

test-integration: .bin-image
docker run -t --rm -e PACKAGER=$(PACKAGER) -e UPDATE_VENDOR=$(UPDATE_VENDOR) -v "$(CURDIR):/src" --network="host" $(BIN_IMAGE) make test-integration ARGS="$(ARGS)"
docker run -t --rm -e PACKAGER=$(PACKAGER) -v "$(CURDIR):/src" --network="host" $(BIN_IMAGE) make test-integration ARGS="$(ARGS)"

test-all: .bin-image
docker run -t --rm -e PACKAGER=$(PACKAGER) -e UPDATE_VENDOR=$(UPDATE_VENDOR) -v "$(CURDIR):/src" --network="host" $(BIN_IMAGE) make test-all ARGS="$(ARGS)"
docker run -t --rm -e PACKAGER=$(PACKAGER) -v "$(CURDIR):/src" --network="host" $(BIN_IMAGE) make test-all ARGS="$(ARGS)"

deb-backend-%: .deb-image
docker run -t --rm -e PACKAGER=$(PACKAGER) -e UPDATE_VENDOR=$(UPDATE_VENDOR) -v "$(CURDIR):/src" -v "$(CURDIR)/build:/out" $(DEB_IMAGE) /build/build-deb.sh backend $* $(ARGS)
docker run -t --rm -e PACKAGER=$(PACKAGER) -v "$(CURDIR):/src" -v "$(CURDIR)/build:/out" $(DEB_IMAGE) /build/build-deb.sh backend $* $(ARGS)

deb-blockbook-%: .deb-image
docker run -t --rm -e PACKAGER=$(PACKAGER) -e UPDATE_VENDOR=$(UPDATE_VENDOR) -v "$(CURDIR):/src" -v "$(CURDIR)/build:/out" $(DEB_IMAGE) /build/build-deb.sh blockbook $* $(ARGS)
docker run -t --rm -e PACKAGER=$(PACKAGER) -v "$(CURDIR):/src" -v "$(CURDIR)/build:/out" $(DEB_IMAGE) /build/build-deb.sh blockbook $* $(ARGS)

deb-%: .deb-image
docker run -t --rm -e PACKAGER=$(PACKAGER) -e UPDATE_VENDOR=$(UPDATE_VENDOR) -v "$(CURDIR):/src" -v "$(CURDIR)/build:/out" $(DEB_IMAGE) /build/build-deb.sh all $* $(ARGS)
docker run -t --rm -e PACKAGER=$(PACKAGER) -v "$(CURDIR):/src" -v "$(CURDIR)/build:/out" $(DEB_IMAGE) /build/build-deb.sh all $* $(ARGS)

deb-blockbook-all: clean-deb $(addprefix deb-blockbook-, $(TARGETS))

Expand Down
28 changes: 14 additions & 14 deletions api/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,7 @@ type Tx struct {
FeesSat *Amount `json:"fees,omitempty"`
Hex string `json:"hex,omitempty"`
Rbf bool `json:"rbf,omitempty"`
CoinSpecificData interface{} `json:"-"`
CoinSpecificJSON json.RawMessage `json:"-"`
CoinSpecificData json.RawMessage `json:"coinSpecificData,omitempty"`
TokenTransfers []TokenTransfer `json:"tokenTransfers,omitempty"`
EthereumSpecific *EthereumSpecific `json:"ethereumSpecific,omitempty"`
}
Expand Down Expand Up @@ -424,18 +423,19 @@ type BlockbookInfo struct {

// BackendInfo is used to get information about blockchain
type BackendInfo struct {
BackendError string `json:"error,omitempty"`
Chain string `json:"chain,omitempty"`
Blocks int `json:"blocks,omitempty"`
Headers int `json:"headers,omitempty"`
BestBlockHash string `json:"bestBlockHash,omitempty"`
Difficulty string `json:"difficulty,omitempty"`
SizeOnDisk int64 `json:"sizeOnDisk,omitempty"`
Version string `json:"version,omitempty"`
Subversion string `json:"subversion,omitempty"`
ProtocolVersion string `json:"protocolVersion,omitempty"`
Timeoffset float64 `json:"timeOffset,omitempty"`
Warnings string `json:"warnings,omitempty"`
BackendError string `json:"error,omitempty"`
Chain string `json:"chain,omitempty"`
Blocks int `json:"blocks,omitempty"`
Headers int `json:"headers,omitempty"`
BestBlockHash string `json:"bestBlockHash,omitempty"`
Difficulty string `json:"difficulty,omitempty"`
SizeOnDisk int64 `json:"sizeOnDisk,omitempty"`
Version string `json:"version,omitempty"`
Subversion string `json:"subversion,omitempty"`
ProtocolVersion string `json:"protocolVersion,omitempty"`
Timeoffset float64 `json:"timeOffset,omitempty"`
Warnings string `json:"warnings,omitempty"`
Consensus interface{} `json:"consensus,omitempty"`
}

// SystemInfo contains information about the running blockbook and backend instance
Expand Down
140 changes: 134 additions & 6 deletions api/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,8 @@ func (w *Worker) GetTransactionFromBchainTx(bchainTx *bchain.Tx, height int, spe
// for now do not return size, we would have to compute vsize of segwit transactions
// size:=len(bchainTx.Hex) / 2
var sj json.RawMessage
if specificJSON {
// return CoinSpecificData for all mempool transactions or if requested
if specificJSON || bchainTx.Confirmations == 0 {
sj, err = w.chain.GetTransactionSpecific(bchainTx)
if err != nil {
return nil, err
Expand All @@ -299,14 +300,140 @@ func (w *Worker) GetTransactionFromBchainTx(bchainTx *bchain.Tx, height int, spe
Rbf: rbf,
Vin: vins,
Vout: vouts,
CoinSpecificData: bchainTx.CoinSpecificData,
CoinSpecificJSON: sj,
CoinSpecificData: sj,
TokenTransfers: tokens,
EthereumSpecific: ethSpecific,
}
return r, nil
}

// GetTransactionFromMempoolTx converts bchain.MempoolTx to Tx, with limited amount of data
// it is not doing any request to backend or to db
func (w *Worker) GetTransactionFromMempoolTx(mempoolTx *bchain.MempoolTx) (*Tx, error) {
var err error
var valInSat, valOutSat, feesSat big.Int
var pValInSat *big.Int
var tokens []TokenTransfer
var ethSpecific *EthereumSpecific
vins := make([]Vin, len(mempoolTx.Vin))
rbf := false
for i := range mempoolTx.Vin {
bchainVin := &mempoolTx.Vin[i]
vin := &vins[i]
vin.Txid = bchainVin.Txid
vin.N = i
vin.Vout = bchainVin.Vout
vin.Sequence = int64(bchainVin.Sequence)
// detect explicit Replace-by-Fee transactions as defined by BIP125
if bchainVin.Sequence < 0xffffffff-1 {
rbf = true
}
vin.Hex = bchainVin.ScriptSig.Hex
vin.Coinbase = bchainVin.Coinbase
if w.chainType == bchain.ChainBitcoinType {
// bchainVin.Txid=="" is coinbase transaction
if bchainVin.Txid != "" {
vin.ValueSat = (*Amount)(&bchainVin.ValueSat)
vin.AddrDesc = bchainVin.AddrDesc
vin.Addresses, vin.IsAddress, _ = w.chainParser.GetAddressesFromAddrDesc(vin.AddrDesc)
if vin.ValueSat != nil {
valInSat.Add(&valInSat, (*big.Int)(vin.ValueSat))
}
}
} else if w.chainType == bchain.ChainEthereumType {
if len(bchainVin.Addresses) > 0 {
vin.AddrDesc, err = w.chainParser.GetAddrDescFromAddress(bchainVin.Addresses[0])
if err != nil {
glog.Errorf("GetAddrDescFromAddress error %v, tx %v, bchainVin %v", err, mempoolTx.Txid, bchainVin)
}
vin.Addresses = bchainVin.Addresses
vin.IsAddress = true
}
}
}
vouts := make([]Vout, len(mempoolTx.Vout))
for i := range mempoolTx.Vout {
bchainVout := &mempoolTx.Vout[i]
vout := &vouts[i]
vout.N = i
vout.ValueSat = (*Amount)(&bchainVout.ValueSat)
valOutSat.Add(&valOutSat, &bchainVout.ValueSat)
vout.Hex = bchainVout.ScriptPubKey.Hex
vout.AddrDesc, vout.Addresses, vout.IsAddress, err = w.getAddressesFromVout(bchainVout)
if err != nil {
glog.V(2).Infof("getAddressesFromVout error %v, %v, output %v", err, mempoolTx.Txid, bchainVout.N)
}
}
if w.chainType == bchain.ChainBitcoinType {
// for coinbase transactions valIn is 0
feesSat.Sub(&valInSat, &valOutSat)
if feesSat.Sign() == -1 {
feesSat.SetUint64(0)
}
pValInSat = &valInSat
} else if w.chainType == bchain.ChainEthereumType {
if len(mempoolTx.Vout) > 0 {
valOutSat = mempoolTx.Vout[0].ValueSat
}
tokens = w.getTokensFromErc20(mempoolTx.Erc20)
ethTxData := eth.GetEthereumTxDataFromSpecificData(mempoolTx.CoinSpecificData)
ethSpecific = &EthereumSpecific{
GasLimit: ethTxData.GasLimit,
GasPrice: (*Amount)(ethTxData.GasPrice),
GasUsed: ethTxData.GasUsed,
Nonce: ethTxData.Nonce,
Status: ethTxData.Status,
Data: ethTxData.Data,
}
}
r := &Tx{
Blocktime: mempoolTx.Blocktime,
FeesSat: (*Amount)(&feesSat),
Locktime: mempoolTx.LockTime,
Txid: mempoolTx.Txid,
ValueInSat: (*Amount)(pValInSat),
ValueOutSat: (*Amount)(&valOutSat),
Version: mempoolTx.Version,
Hex: mempoolTx.Hex,
Rbf: rbf,
Vin: vins,
Vout: vouts,
TokenTransfers: tokens,
EthereumSpecific: ethSpecific,
}
return r, nil
}

func (w *Worker) getTokensFromErc20(erc20 []bchain.Erc20Transfer) []TokenTransfer {
tokens := make([]TokenTransfer, len(erc20))
for i := range erc20 {
e := &erc20[i]
cd, err := w.chainParser.GetAddrDescFromAddress(e.Contract)
if err != nil {
glog.Errorf("GetAddrDescFromAddress error %v, contract %v", err, e.Contract)
continue
}
erc20c, err := w.chain.EthereumTypeGetErc20ContractInfo(cd)
if err != nil {
glog.Errorf("GetErc20ContractInfo error %v, contract %v", err, e.Contract)
}
if erc20c == nil {
erc20c = &bchain.Erc20Contract{Name: e.Contract}
}
tokens[i] = TokenTransfer{
Type: ERC20TokenType,
Token: e.Contract,
From: e.From,
To: e.To,
Decimals: erc20c.Decimals,
Value: (*Amount)(&e.Tokens),
Name: erc20c.Name,
Symbol: erc20c.Symbol,
}
}
return tokens
}

// GetTransactionFromMempoolTx converts bchain.MempoolTx to Tx, with limited amount of data
// it is not doing any request to backend or to db
func (w *Worker) GetTransactionFromMempoolTx(mempoolTx *bchain.MempoolTx) (*Tx, error) {
Expand Down Expand Up @@ -758,7 +885,7 @@ func (w *Worker) txFromTxid(txid string, bestheight uint32, option AccountDetail
if ta == nil {
glog.Warning("DB inconsistency: tx ", txid, ": not found in txAddresses")
// as fallback, get tx from backend
tx, err = w.GetTransaction(txid, false, true)
tx, err = w.GetTransaction(txid, false, false)
if err != nil {
return nil, errors.Annotatef(err, "GetTransaction %v", txid)
}
Expand All @@ -777,7 +904,7 @@ func (w *Worker) txFromTxid(txid string, bestheight uint32, option AccountDetail
tx = w.txFromTxAddress(txid, ta, blockInfo, bestheight)
}
} else {
tx, err = w.GetTransaction(txid, false, true)
tx, err = w.GetTransaction(txid, false, false)
if err != nil {
return nil, errors.Annotatef(err, "GetTransaction %v", txid)
}
Expand Down Expand Up @@ -866,7 +993,7 @@ func (w *Worker) GetAddress(address string, page int, txsOnPage int, option Acco
return nil, errors.Annotatef(err, "getAddressTxids %v true", addrDesc)
}
for _, txid := range txm {
tx, err := w.GetTransaction(txid, false, false)
tx, err := w.GetTransaction(txid, false, true)
// mempool transaction may fail
if err != nil || tx == nil {
glog.Warning("GetTransaction in mempool: ", err)
Expand Down Expand Up @@ -1777,6 +1904,7 @@ func (w *Worker) GetSystemInfo(internal bool) (*SystemInfo, error) {
Timeoffset: ci.Timeoffset,
Version: ci.Version,
Warnings: ci.Warnings,
Consensus: ci.Consensus,
}
glog.Info("GetSystemInfo finished in ", time.Since(start))
return &SystemInfo{blockbookInfo, backendInfo}, nil
Expand Down
2 changes: 1 addition & 1 deletion api/xpub.go
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ func (w *Worker) GetXpubAddress(xpub string, page int, txsOnPage int, option Acc
// the same tx can have multiple addresses from the same xpub, get it from backend it only once
tx, foundTx := txmMap[txid.txid]
if !foundTx {
tx, err = w.GetTransaction(txid.txid, false, false)
tx, err = w.GetTransaction(txid.txid, false, true)
// mempool transaction may fail
if err != nil || tx == nil {
glog.Warning("GetTransaction in mempool: ", err)
Expand Down
17 changes: 14 additions & 3 deletions bchain/coins/eth/ethparser.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,14 @@ func (p *EthereumParser) PackTx(tx *bchain.Tx, height uint32, blockTime int64) (
if pt.Receipt.GasUsed, err = hexDecodeBig(r.Receipt.GasUsed); err != nil {
return nil, errors.Annotatef(err, "GasUsed %v", r.Receipt.GasUsed)
}
if pt.Receipt.Status, err = hexDecodeBig(r.Receipt.Status); err != nil {
return nil, errors.Annotatef(err, "Status %v", r.Receipt.Status)
if r.Receipt.Status != "" {
if pt.Receipt.Status, err = hexDecodeBig(r.Receipt.Status); err != nil {
return nil, errors.Annotatef(err, "Status %v", r.Receipt.Status)
}
} else {
// unknown status, use 'U' as status bytes
// there is a potential for conflict with value 0x55 but this is not used by any chain at this moment
pt.Receipt.Status = []byte{'U'}
}
ptLogs := make([]*ProtoCompleteTransaction_ReceiptType_LogType, len(r.Receipt.Logs))
for i, l := range r.Receipt.Logs {
Expand Down Expand Up @@ -379,9 +385,14 @@ func (p *EthereumParser) UnpackTx(buf []byte) (*bchain.Tx, uint32, error) {
Topics: topics,
}
}
status := ""
// handle a special value []byte{'U'} as unknown state
if len(pt.Receipt.Status) != 1 || pt.Receipt.Status[0] != 'U' {
status = hexEncodeBig(pt.Receipt.Status)
}
rr = &rpcReceipt{
GasUsed: hexEncodeBig(pt.Receipt.GasUsed),
Status: hexEncodeBig(pt.Receipt.Status),
Status: status,
Logs: logs,
}
}
Expand Down