-
Notifications
You must be signed in to change notification settings - Fork 84
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
[0.5] btc: update btcd to fix critical block parsing failure #1897
Merged
chappjc
merged 2 commits into
decred:release-v0.5
from
chappjc:btc-witness-item-size-fix-0.5
Oct 10, 2022
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
Binary file not shown.
Binary file added
BIN
+96.6 KB
...asset/btc/bitcoin-tx-7393096d97bfee8660f4100ffd61874d62f9a65de9fb6acf740c4c386990ef73.dat
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package main | ||
|
||
import ( | ||
"flag" | ||
"fmt" | ||
"os" | ||
|
||
"github.com/btcsuite/btcd/chaincfg/chainhash" | ||
"github.com/btcsuite/btcd/rpcclient" | ||
) | ||
|
||
var host = flag.String("host", "127.0.0.1:8332", "node RPC host:port") | ||
var user = flag.String("user", "", "node RPC username") | ||
var pass = flag.String("pass", "", "node RPC password") | ||
|
||
func main() { | ||
os.Exit(mainCore()) | ||
} | ||
|
||
func mainCore() int { | ||
flag.Parse() | ||
|
||
client, err := rpcclient.New(&rpcclient.ConnConfig{ | ||
HTTPPostMode: true, | ||
DisableTLS: true, | ||
Host: *host, | ||
User: *user, | ||
Pass: *pass, | ||
}, nil) | ||
if err != nil { | ||
fmt.Fprintf(os.Stderr, "ERROR: Unable to connect to RPC server: %v\n", err) | ||
return 1 | ||
} | ||
defer client.Shutdown() | ||
|
||
infoResult, err := client.GetNetworkInfo() | ||
if err != nil { | ||
fmt.Fprintf(os.Stderr, "ERROR: GetInfo failed: %v\n", err) | ||
return 1 | ||
} | ||
fmt.Printf("Node connection count: %d\n", infoResult.Connections) | ||
|
||
hash, err := client.GetBestBlockHash() | ||
if err != nil { | ||
fmt.Fprintf(os.Stderr, "ERROR: GetBestBlockHash failed: %v\n", err) | ||
return 2 | ||
} | ||
hdr, err := client.GetBlockHeaderVerbose(hash) | ||
if err != nil { | ||
fmt.Fprintf(os.Stderr, "ERROR: GetBestBlockHash failed: %v\n", err) | ||
return 2 | ||
} | ||
fmt.Println(hdr.Height, hash) | ||
|
||
// block with tx with big witness item that fails for old btcd/wire | ||
bigBlockHash, _ := chainhash.NewHashFromStr("0000000000000000000400a35a007e223a7fb8a622dc7b5aa5eaace6824291fb") | ||
msgBlock, err := client.GetBlock(bigBlockHash) | ||
if err != nil { | ||
fmt.Println(err) | ||
return 1 | ||
} | ||
fmt.Println(msgBlock.BlockHash()) | ||
|
||
return 0 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
//go:build !spvlive | ||
|
||
package btc | ||
|
||
import ( | ||
"bytes" | ||
_ "embed" | ||
"testing" | ||
|
||
"github.com/btcsuite/btcd/wire" | ||
) | ||
|
||
//go:embed bitcoin-block-757922.dat | ||
var block757922 []byte | ||
|
||
//go:embed bitcoin-tx-7393096d97bfee8660f4100ffd61874d62f9a65de9fb6acf740c4c386990ef73.dat | ||
var tx7393096d9 []byte | ||
|
||
func TestBigWitness(t *testing.T) { | ||
msgBlock := &wire.MsgBlock{} | ||
err := msgBlock.Deserialize(bytes.NewReader(block757922)) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
wantHash := "0000000000000000000400a35a007e223a7fb8a622dc7b5aa5eaace6824291fb" | ||
if h := msgBlock.BlockHash().String(); h != wantHash { | ||
t.Errorf("got %v, wanted %v", h, wantHash) | ||
} | ||
|
||
msgTx := &wire.MsgTx{} | ||
err = msgTx.Deserialize(bytes.NewReader(tx7393096d9)) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
wantHash = "7393096d97bfee8660f4100ffd61874d62f9a65de9fb6acf740c4c386990ef73" | ||
if h := msgTx.TxHash().String(); h != wantHash { | ||
t.Errorf("got %v, wanted %v", h, wantHash) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,14 +4,14 @@ go 1.17 | |
|
||
require ( | ||
decred.org/dcrwallet/v2 v2.0.8 | ||
github.com/btcsuite/btcd v0.22.0-beta.0.20220413172512-bf64c8bdbbbf | ||
github.com/btcsuite/btcd/btcec/v2 v2.2.0 | ||
github.com/btcsuite/btcd/btcutil v1.1.1 | ||
github.com/btcsuite/btcd/btcutil/psbt v1.1.3 | ||
github.com/btcsuite/btcd v0.23.2 | ||
github.com/btcsuite/btcd/btcec/v2 v2.2.1 | ||
github.com/btcsuite/btcd/btcutil v1.1.2 | ||
github.com/btcsuite/btcd/btcutil/psbt v1.1.5 | ||
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 | ||
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f | ||
github.com/btcsuite/btcwallet v0.14.1-0.20220322205928-94c51d7bdbf9 | ||
github.com/btcsuite/btcwallet/wallet/txauthor v1.2.3 | ||
github.com/btcsuite/btcwallet v0.16.1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. btcwallet review diff, 49 commits forward: btcsuite/btcwallet@94c51d7...v0.16.1 |
||
github.com/btcsuite/btcwallet/wallet/txauthor v1.3.2 | ||
github.com/btcsuite/btcwallet/walletdb v1.4.0 | ||
github.com/btcsuite/btcwallet/wtxmgr v1.5.0 | ||
github.com/davecgh/go-spew v1.1.1 | ||
|
@@ -46,7 +46,7 @@ require ( | |
github.com/jessevdk/go-flags v1.4.1-0.20200711081900-c17162fe8fd7 | ||
github.com/jrick/logrotate v1.0.0 | ||
github.com/lib/pq v1.10.4 | ||
github.com/lightninglabs/neutrino v0.14.1 | ||
github.com/lightninglabs/neutrino v0.14.2 | ||
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e | ||
github.com/tyler-smith/go-bip39 v1.0.1-0.20181017060643-dbb3b84ba2ef | ||
go.etcd.io/bbolt v1.3.7-0.20220130032806-d5db64bdbfde | ||
|
@@ -66,7 +66,7 @@ require ( | |
github.com/aead/siphash v1.0.1 // indirect | ||
github.com/agl/ed25519 v0.0.0-20170116200512-5312a6153412 // indirect | ||
github.com/btcsuite/btcwallet/wallet/txrules v1.2.0 // indirect | ||
github.com/btcsuite/btcwallet/wallet/txsizes v1.1.0 // indirect | ||
github.com/btcsuite/btcwallet/wallet/txsizes v1.2.3 // indirect | ||
github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd // indirect | ||
github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792 // indirect | ||
github.com/cespare/xxhash/v2 v2.1.2 // indirect | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
btcd review diff, 67 commits forward: btcsuite/btcd@bf64c8b...v0.23.2
combined diff: https://github.com/btcsuite/btcd/compare/bf64c8bdbbbf..v0.23.2