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

Rpcbulk #14

Merged
merged 54 commits into from
Feb 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
70a0132
blockchain: remove unknown block version warning
Rjected Aug 27, 2019
efae8e9
Add rpclient implementation of getdescriptorinfo RPC
onyb Aug 24, 2020
7d69fb9
peer: prevent last block height going backwards
Roasbeef Jul 17, 2020
36d4ae0
Fix monetary unit
wakiyamap Aug 14, 2020
7145eef
rpcserver: add parity with bitcoind for validateaddress
onyb Aug 24, 2020
b68c50e
Add getblockfilter JSON-RPC client command
lindlof May 16, 2020
d2c0123
Implement signmessagewithprivkey JSON-RPC command
lindlof May 23, 2020
fffe4a9
rpcclient: Implement importmulti JSON-RPC client command
onyb Aug 24, 2020
90a5c79
Add Dockerfile to build and run btcd on Docker.
legacycode Sep 5, 2019
d13e907
btcd: fix conversion of int to string failing in Go 1.15
federicobond Aug 27, 2020
35194e2
btcjson,wire: fix invalid use of string(x) to convert byte value
federicobond Aug 28, 2020
355472b
Major rework on documentation to make it compatible to readthedocs.org
legacycode Sep 9, 2019
23d149c
Added symlink to index.md for github readme preview.
legacycode Sep 1, 2020
6163444
btcd+netsync: support witness tx and block in notfound msg
yyforyongyu Sep 3, 2020
8facfdd
btcec: set curve name in CurveParams
hallazzang Apr 15, 2020
7cbf956
btcec: add a comment indicating where curve name taken from
hallazzang Jul 18, 2020
ba3fe57
rpcclient: support listtransactions RPC with watchonly argument
onyb Sep 8, 2020
95fea64
blockchain: Remove unnecessary tx hash
kcalvinalvin Jul 13, 2020
3b926ef
btcjson: update ListTransactionsResult for Bitcoin 0.20.0
onyb Sep 6, 2020
bdab8df
chaincfg: Add RegisterHDKeyID func to populate HD key ID pairs
onyb Aug 24, 2020
eb05726
Nullable optional JSON-RPC parameters
lindlof Jun 14, 2020
2547246
GitHub Actions: Enable Go Race detector and code coverage
onyb Aug 24, 2020
9ef973c
Merge pull request #1625 from yyforyongyu/fix-notfound-message
Roasbeef Sep 8, 2020
fff9661
rpc: Add getnodeaddresses JSON-RPC support
lindlof May 31, 2020
6f49f1f
btcjson,rpcclient: add support for PSBT commands to rpcclient
federicobond Apr 30, 2020
5ae1f21
Added ListSinceBlockMinConfWatchOnly method.
nalcheg Sep 8, 2020
ff59bbc
wire: add proper types for flag field and improve docs
onyb Sep 13, 2020
42782bb
removed unnecessary GOMAXPROCS function calls
ipriver Sep 7, 2020
c693bd8
rpcclient: add deriveaddresses RPC command
onyb Sep 13, 2020
297c612
ci: add go 1.15 to tests
jakesylvestre Sep 17, 2020
e5521de
sample-btcd.conf: fix typo
Tristyn Sep 17, 2020
f402416
btcjson: add test for null params in searchrawtransactions
onyb Sep 17, 2020
6daaf73
GetBlockTemplate RPC client implementation (#1629)
elliottminns Sep 21, 2020
ac3f235
rpcclient: implement getaddressinfo command
onyb Sep 15, 2020
1340513
Fix link to using bootstrap.dat
friedger Sep 23, 2020
e9a51e8
rpcclient: implement getwalletinfo command
onyb Sep 20, 2020
40ae935
Merge pull request #1621 from xplorfin/go1.15
Roasbeef Oct 2, 2020
0bf42f4
rpcserver: add txid to getblocktemplate response
onyb Sep 21, 2020
584c382
rpc: add signrawtransactionwithwallet interface
henryperson Apr 11, 2020
6519c04
rpcclient: implement gettxoutsetinfo command
onyb Sep 28, 2020
6adfc07
Unmarshal hashes/second as float in GetMiningInfoResult
DavidMazary Oct 4, 2020
1d75e0a
rpcclient: add more wallet commands
torkelrogstad Oct 6, 2020
5e56ca0
btcjson: add new JSON-RPC errors and document them
onyb Oct 8, 2020
535f255
rpcclient: implement createwallet with functional options
onyb Oct 9, 2020
f070f7f
rpcclient: fix documentation typos
armandooj Nov 3, 2020
9250064
integration: allow setting custom btcd exe path
guggero Nov 11, 2020
93cc7f3
integration: allow overwriting address generator
guggero Nov 11, 2020
65d2b7a
integration: allow specifying connection behavior
guggero Nov 11, 2020
9fd26cf
integration/rpctest: randomizes port in rpctest.New to reduce collisions
lsharir Nov 10, 2020
9e8bb3e
btcjson+rpcserverhelp: restore bitcoind compatibility
guggero Nov 12, 2020
e9c7a5a
Merge pull request #1659 from guggero/itest-fixes
Roasbeef Nov 14, 2020
0886f1e
simplify s[:] to s where s is a slice
quasilyte Sep 13, 2018
610bb55
rpcclient: add ExtraHeaders in ConnConfig
10gic Nov 20, 2020
8c63cc3
Add Batch JSON-RPC support (rpc client & server)
jakesylvestre Dec 6, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
go: [1.13, 1.14]
go: [1.14, 1.15]
steps:
- name: Set up Go
uses: actions/setup-go@v2
Expand All @@ -25,3 +25,8 @@ jobs:
GO111MODULE: "on"
run: |
sh ./goclean.sh

- name: Send coverage
uses: shogo82148/actions-goveralls@v1
with:
path-to-profile: profile.cov
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,7 @@ _cgo_export.*
_testmain.go

*.exe

# Code coverage files
profile.tmp
profile.cov
40 changes: 40 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# This Dockerfile builds btcd from source and creates a small (55 MB) docker container based on alpine linux.
#
# Clone this repository and run the following command to build and tag a fresh btcd amd64 container:
#
# docker build . -t yourregistry/btcd
#
# You can use the following command to buid an arm64v8 container:
#
# docker build . -t yourregistry/btcd --build-arg ARCH=arm64v8
#
# For more information how to use this docker image visit:
# https://github.com/btcsuite/btcd/tree/master/docs
#
# 8333 Mainnet Bitcoin peer-to-peer port
# 8334 Mainet RPC port

ARG ARCH=amd64

FROM golang:1.14-alpine3.12 AS build-container

ARG ARCH
ENV GO111MODULE=on

ADD . /app
WORKDIR /app
RUN set -ex \
&& if [ "${ARCH}" = "amd64" ]; then export GOARCH=amd64; fi \
&& if [ "${ARCH}" = "arm64v8" ]; then export GOARCH=arm64; fi \
&& echo "Compiling for $GOARCH" \
&& go install -v . ./cmd/...

FROM $ARCH/alpine:3.12

COPY --from=build-container /go/bin /bin

VOLUME ["/root/.btcd"]

EXPOSE 8333 8334

ENTRYPOINT ["btcd"]
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ btcd
====

[![Build Status](https://github.com/btcsuite/btcd/workflows/Build%20and%20Test/badge.svg)](https://github.com/btcsuite/btcd/actions)
[![Coverage Status](https://coveralls.io/repos/github/btcsuite/btcd/badge.svg?branch=master)](https://coveralls.io/github/btcsuite/btcd?branch=master)
[![ISC License](https://img.shields.io/badge/license-ISC-blue.svg)](http://copyfree.org)
[![GoDoc](https://img.shields.io/badge/godoc-reference-blue.svg)](https://godoc.org/github.com/btcsuite/btcd)

Expand All @@ -26,7 +27,7 @@ transactions based on miner requirements ("standard" transactions).

One key difference between btcd and Bitcoin Core is that btcd does *NOT* include
wallet functionality and this was a very intentional design decision. See the
blog entry [here](https://blog.conformal.com/btcd-not-your-moms-bitcoin-daemon)
blog entry [here](https://web.archive.org/web/20171125143919/https://blog.conformal.com/btcd-not-your-moms-bitcoin-daemon)
for more details. This means you can't actually make or receive payments
directly with btcd. That functionality is provided by the
[btcwallet](https://github.com/btcsuite/btcwallet) and
Expand All @@ -35,7 +36,7 @@ which are both under active development.

## Requirements

[Go](http://golang.org) 1.12 or newer.
[Go](http://golang.org) 1.14 or newer.

## Installation

Expand Down
15 changes: 2 additions & 13 deletions blockchain/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,7 @@ type BlockChain struct {
//
// unknownRulesWarned refers to warnings due to unknown rules being
// activated.
//
// unknownVersionsWarned refers to warnings due to unknown versions
// being mined.
unknownRulesWarned bool
unknownVersionsWarned bool
unknownRulesWarned bool

// The notifications field stores a slice of callbacks to be executed on
// certain blockchain events.
Expand Down Expand Up @@ -574,20 +570,13 @@ func (b *BlockChain) connectBlock(node *blockNode, block *btcutil.Block,
"spent transaction out information")
}

// No warnings about unknown rules or versions until the chain is
// current.
// No warnings about unknown rules until the chain is current.
if b.isCurrent() {
// Warn if any unknown new rules are either about to activate or
// have already been activated.
if err := b.warnUnknownRuleActivations(node); err != nil {
return err
}

// Warn if a high enough percentage of the last blocks have
// unexpected versions.
if err := b.warnUnknownVersions(node); err != nil {
return err
}
}

// Write any block status changes to DB before updating best state.
Expand Down
4 changes: 2 additions & 2 deletions blockchain/chainio.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func dbFetchVersion(dbTx database.Tx, key []byte) uint32 {
return 0
}

return byteOrder.Uint32(serialized[:])
return byteOrder.Uint32(serialized)
}

// dbPutVersion uses an existing database transaction to update the provided
Expand Down Expand Up @@ -943,7 +943,7 @@ func serializeBestChainState(state bestChainState) []byte {
byteOrder.PutUint32(serializedData[offset:], workSumBytesLen)
offset += 4
copy(serializedData[offset:], workSumBytes)
return serializedData[:]
return serializedData
}

// deserializeBestChainState deserializes the passed serialized best chain
Expand Down
3 changes: 0 additions & 3 deletions blockchain/scriptval_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package blockchain

import (
"fmt"
"runtime"
"testing"

"github.com/btcsuite/btcd/txscript"
Expand All @@ -15,8 +14,6 @@ import (
// TestCheckBlockScripts ensures that validating the all of the scripts in a
// known-good block doesn't return an error.
func TestCheckBlockScripts(t *testing.T) {
runtime.GOMAXPROCS(runtime.NumCPU())

testBlockNum := 277647
blockDataFile := fmt.Sprintf("%d.dat.bz2", testBlockNum)
blocks, err := loadBlocks(blockDataFile)
Expand Down
10 changes: 2 additions & 8 deletions blockchain/thresholdstate.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ func (b *BlockChain) deploymentState(prevNode *blockNode, deploymentID uint32) (

// initThresholdCaches initializes the threshold state caches for each warning
// bit and defined deployment and provides warnings if the chain is current per
// the warnUnknownVersions and warnUnknownRuleActivations functions.
// the warnUnknownRuleActivations function.
func (b *BlockChain) initThresholdCaches() error {
// Initialize the warning and deployment caches by calculating the
// threshold state for each of them. This will ensure the caches are
Expand All @@ -335,15 +335,9 @@ func (b *BlockChain) initThresholdCaches() error {
}
}

// No warnings about unknown rules or versions until the chain is
// current.
// No warnings about unknown rules until the chain is current.
if b.isCurrent() {
// Warn if a high enough percentage of the last blocks have
// unexpected versions.
bestNode := b.bestChain.Tip()
if err := b.warnUnknownVersions(bestNode); err != nil {
return err
}

// Warn if any unknown new rules are either about to activate or
// have already been activated.
Expand Down
3 changes: 1 addition & 2 deletions blockchain/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,6 @@ func CheckTransactionInputs(tx *btcutil.Tx, txHeight int32, utxoView *UtxoViewpo
return 0, nil
}

txHash := tx.Hash()
var totalSatoshiIn int64
for txInIndex, txIn := range tx.MsgTx().TxIn {
// Ensure the referenced input transaction is available.
Expand Down Expand Up @@ -954,7 +953,7 @@ func CheckTransactionInputs(tx *btcutil.Tx, txHeight int32, utxoView *UtxoViewpo
if totalSatoshiIn < totalSatoshiOut {
str := fmt.Sprintf("total value of all transaction inputs for "+
"transaction %v is %v which is less than the amount "+
"spent of %v", txHash, totalSatoshiIn, totalSatoshiOut)
"spent of %v", tx.Hash(), totalSatoshiIn, totalSatoshiOut)
return 0, ruleError(ErrSpendTooHigh, str)
}

Expand Down
44 changes: 0 additions & 44 deletions blockchain/versionbits.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,6 @@ const (
// vbNumBits is the total number of bits available for use with the
// version bits scheme.
vbNumBits = 29

// unknownVerNumToCheck is the number of previous blocks to consider
// when checking for a threshold of unknown block versions for the
// purposes of warning the user.
unknownVerNumToCheck = 100

// unknownVerWarnNum is the threshold of previous blocks that have an
// unknown version to use for the purposes of warning the user.
unknownVerWarnNum = unknownVerNumToCheck / 2
)

// bitConditionChecker provides a thresholdConditionChecker which can be used to
Expand Down Expand Up @@ -264,38 +255,3 @@ func (b *BlockChain) warnUnknownRuleActivations(node *blockNode) error {

return nil
}

// warnUnknownVersions logs a warning if a high enough percentage of the last
// blocks have unexpected versions.
//
// This function MUST be called with the chain state lock held (for writes)
func (b *BlockChain) warnUnknownVersions(node *blockNode) error {
// Nothing to do if already warned.
if b.unknownVersionsWarned {
return nil
}

// Warn if enough previous blocks have unexpected versions.
numUpgraded := uint32(0)
for i := uint32(0); i < unknownVerNumToCheck && node != nil; i++ {
expectedVersion, err := b.calcNextBlockVersion(node.parent)
if err != nil {
return err
}
if expectedVersion > vbLegacyBlockVersion &&
(node.version & ^expectedVersion) != 0 {

numUpgraded++
}

node = node.parent
}
if numUpgraded > unknownVerWarnNum {
log.Warn("Unknown block versions are being mined, so new " +
"rules might be in effect. Are you running the " +
"latest version of the software?")
b.unknownVersionsWarned = true
}

return nil
}
3 changes: 0 additions & 3 deletions btcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,9 +297,6 @@ func loadBlockDB() (database.DB, error) {
}

func main() {
// Use all processor cores.
runtime.GOMAXPROCS(runtime.NumCPU())

// Block and transaction processing can cause bursty allocations. This
// limits the garbage collector from excessively overallocating during
// bursts. This value was arrived at with the help of profiling live
Expand Down
2 changes: 2 additions & 0 deletions btcec/btcec.go
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,8 @@ func initS256() {
secp256k1.Gx = fromHex("79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798")
secp256k1.Gy = fromHex("483ADA7726A3C4655DA4FBFC0E1108A8FD17B448A68554199C47D08FFB10D4B8")
secp256k1.BitSize = 256
// Curve name taken from https://safecurves.cr.yp.to/.
secp256k1.Name = "secp256k1"
secp256k1.q = new(big.Int).Div(new(big.Int).Add(secp256k1.P,
big.NewInt(1)), big.NewInt(4))
secp256k1.H = 1
Expand Down
4 changes: 2 additions & 2 deletions btcjson/btcdextcmds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ func TestBtcdExtCmds(t *testing.T) {
for i, test := range tests {
// Marshal the command as created by the new static command
// creation function.
marshalled, err := btcjson.MarshalCmd(testID, test.staticCmd())
marshalled, err := btcjson.MarshalCmd(btcjson.RpcVersion1, testID, test.staticCmd())
if err != nil {
t.Errorf("MarshalCmd #%d (%s) unexpected error: %v", i,
test.name, err)
Expand All @@ -235,7 +235,7 @@ func TestBtcdExtCmds(t *testing.T) {

// Marshal the command as created by the generic new command
// creation function.
marshalled, err = btcjson.MarshalCmd(testID, cmd)
marshalled, err = btcjson.MarshalCmd(btcjson.RpcVersion1, testID, cmd)
if err != nil {
t.Errorf("MarshalCmd #%d (%s) unexpected error: %v", i,
test.name, err)
Expand Down
4 changes: 2 additions & 2 deletions btcjson/btcwalletextcmds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func TestBtcWalletExtCmds(t *testing.T) {
for i, test := range tests {
// Marshal the command as created by the new static command
// creation function.
marshalled, err := btcjson.MarshalCmd(testID, test.staticCmd())
marshalled, err := btcjson.MarshalCmd(btcjson.RpcVersion1, testID, test.staticCmd())
if err != nil {
t.Errorf("MarshalCmd #%d (%s) unexpected error: %v", i,
test.name, err)
Expand All @@ -169,7 +169,7 @@ func TestBtcWalletExtCmds(t *testing.T) {

// Marshal the command as created by the generic new command
// creation function.
marshalled, err = btcjson.MarshalCmd(testID, cmd)
marshalled, err = btcjson.MarshalCmd(btcjson.RpcVersion1, testID, cmd)
if err != nil {
t.Errorf("MarshalCmd #%d (%s) unexpected error: %v", i,
test.name, err)
Expand Down
Loading