• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..13-May-2020-

testdata/H03-May-2022-

README.mdH A D13-May-20204 KiB11487

bench_test.goH A D13-May-202019 KiB635491

blockheader.goH A D13-May-20204.8 KiB12954

blockheader_test.goH A D13-May-20206.9 KiB262216

common.goH A D13-May-202017.3 KiB690479

common_test.goH A D13-May-202021.5 KiB760595

doc.goH A D13-May-20207.1 KiB1631

error.goH A D13-May-20201.1 KiB3517

fakemessage_test.goH A D13-May-20201.5 KiB5732

fixedIO_test.goH A D13-May-20202 KiB7845

invvect.goH A D13-May-20202.6 KiB8752

invvect_test.goH A D13-May-20206.1 KiB270204

message.goH A D13-May-202013.2 KiB441276

message_test.goH A D13-May-202014 KiB460334

msgaddr.goH A D13-May-20204.2 KiB14490

msgaddr_test.goH A D13-May-20209.5 KiB321244

msgalert.goH A D13-May-202012.7 KiB408225

msgalert_test.goH A D13-May-202016 KiB476381

msgblock.goH A D13-May-202010.3 KiB291145

msgblock_test.goH A D13-May-202018 KiB590465

msgcfcheckpt.goH A D13-May-20204.9 KiB16593

msgcfheaders.goH A D13-May-20205.3 KiB181106

msgcfilter.goH A D13-May-20203.7 KiB12066

msgfeefilter.goH A D13-May-20202 KiB6535

msgfeefilter_test.goH A D13-May-20205.4 KiB191142

msgfilteradd.goH A D13-May-20202.5 KiB8248

msgfilteradd_test.goH A D13-May-20205.4 KiB188134

msgfilterclear.goH A D13-May-20201.9 KiB6031

msgfilterclear_test.goH A D13-May-20205.4 KiB200148

msgfilterload.goH A D13-May-20204.2 KiB13782

msgfilterload_test.goH A D13-May-20206.7 KiB228168

msggetaddr.goH A D13-May-20201.5 KiB4820

msggetaddr_test.goH A D13-May-20202.8 KiB12796

msggetblocks.goH A D13-May-20204.7 KiB14083

msggetblocks_test.goH A D13-May-202012.1 KiB401304

msggetcfcheckpt.goH A D13-May-20202 KiB6535

msggetcfheaders.goH A D13-May-20202.2 KiB7846

msggetcfilters.goH A D13-May-20202.3 KiB8247

msggetdata.goH A D13-May-20204.4 KiB13475

msggetdata_test.goH A D13-May-20209.2 KiB342259

msggetheaders.goH A D13-May-20204.5 KiB13782

msggetheaders_test.goH A D13-May-202011.9 KiB392297

msgheaders.goH A D13-May-20204.1 KiB13784

msgheaders_test.goH A D13-May-202010.3 KiB360279

msginv.goH A D13-May-20204.7 KiB14276

msginv_test.goH A D13-May-20209.1 KiB343259

msgmempool.goH A D13-May-20201.9 KiB6131

msgmempool_test.goH A D13-May-20201.7 KiB6443

msgmerkleblock.goH A D13-May-20204.6 KiB160111

msgmerkleblock_test.goH A D13-May-202013.2 KiB431327

msgnotfound.goH A D13-May-20203.2 KiB11167

msgnotfound_test.goH A D13-May-20208.9 KiB332253

msgping.goH A D13-May-20202.6 KiB8840

msgping_test.goH A D13-May-20206.7 KiB246186

msgpong.goH A D13-May-20202.4 KiB7939

msgpong_test.goH A D13-May-20207.7 KiB278205

msgreject.goH A D13-May-20205.3 KiB187110

msgreject_test.goH A D13-May-202011.7 KiB390303

msgsendheaders.goH A D13-May-20201.9 KiB6131

msgsendheaders_test.goH A D13-May-20205 KiB194141

msgtx.goH A D13-May-202034.3 KiB1,028539

msgtx_test.goH A D13-May-202032.7 KiB1,022832

msgverack.goH A D13-May-20201.5 KiB4720

msgverack_test.goH A D13-May-20202.7 KiB12696

msgversion.goH A D13-May-20207.7 KiB270160

msgversion_test.goH A D13-May-202018.1 KiB565434

netaddress.goH A D13-May-20204.6 KiB15083

netaddress_test.goH A D13-May-20208.1 KiB279200

protocol.goH A D13-May-20204.8 KiB17986

protocol_test.goH A D13-May-20201.5 KiB6149

README.md

1wire
2====
3
4[![Build Status](http://img.shields.io/travis/btcsuite/btcd.svg)](https://travis-ci.org/btcsuite/btcd)
5[![ISC License](http://img.shields.io/badge/license-ISC-blue.svg)](http://copyfree.org)
6[![GoDoc](https://img.shields.io/badge/godoc-reference-blue.svg)](http://godoc.org/github.com/btcsuite/btcd/wire)
7=======
8
9Package wire implements the bitcoin wire protocol.  A comprehensive suite of
10tests with 100% test coverage is provided to ensure proper functionality.
11
12There is an associated blog post about the release of this package
13[here](https://blog.conformal.com/btcwire-the-bitcoin-wire-protocol-package-from-btcd/).
14
15This package has intentionally been designed so it can be used as a standalone
16package for any projects needing to interface with bitcoin peers at the wire
17protocol level.
18
19## Installation and Updating
20
21```bash
22$ go get -u github.com/btcsuite/btcd/wire
23```
24
25## Bitcoin Message Overview
26
27The bitcoin protocol consists of exchanging messages between peers. Each message
28is preceded by a header which identifies information about it such as which
29bitcoin network it is a part of, its type, how big it is, and a checksum to
30verify validity. All encoding and decoding of message headers is handled by this
31package.
32
33To accomplish this, there is a generic interface for bitcoin messages named
34`Message` which allows messages of any type to be read, written, or passed
35around through channels, functions, etc. In addition, concrete implementations
36of most of the currently supported bitcoin messages are provided. For these
37supported messages, all of the details of marshalling and unmarshalling to and
38from the wire using bitcoin encoding are handled so the caller doesn't have to
39concern themselves with the specifics.
40
41## Reading Messages Example
42
43In order to unmarshal bitcoin messages from the wire, use the `ReadMessage`
44function. It accepts any `io.Reader`, but typically this will be a `net.Conn`
45to a remote node running a bitcoin peer.  Example syntax is:
46
47```Go
48	// Use the most recent protocol version supported by the package and the
49	// main bitcoin network.
50	pver := wire.ProtocolVersion
51	btcnet := wire.MainNet
52
53	// Reads and validates the next bitcoin message from conn using the
54	// protocol version pver and the bitcoin network btcnet.  The returns
55	// are a wire.Message, a []byte which contains the unmarshalled
56	// raw payload, and a possible error.
57	msg, rawPayload, err := wire.ReadMessage(conn, pver, btcnet)
58	if err != nil {
59		// Log and handle the error
60	}
61```
62
63See the package documentation for details on determining the message type.
64
65## Writing Messages Example
66
67In order to marshal bitcoin messages to the wire, use the `WriteMessage`
68function. It accepts any `io.Writer`, but typically this will be a `net.Conn`
69to a remote node running a bitcoin peer. Example syntax to request addresses
70from a remote peer is:
71
72```Go
73	// Use the most recent protocol version supported by the package and the
74	// main bitcoin network.
75	pver := wire.ProtocolVersion
76	btcnet := wire.MainNet
77
78	// Create a new getaddr bitcoin message.
79	msg := wire.NewMsgGetAddr()
80
81	// Writes a bitcoin message msg to conn using the protocol version
82	// pver, and the bitcoin network btcnet.  The return is a possible
83	// error.
84	err := wire.WriteMessage(conn, msg, pver, btcnet)
85	if err != nil {
86		// Log and handle the error
87	}
88```
89
90## GPG Verification Key
91
92All official release tags are signed by Conformal so users can ensure the code
93has not been tampered with and is coming from the btcsuite developers.  To
94verify the signature perform the following:
95
96- Download the public key from the Conformal website at
97  https://opensource.conformal.com/GIT-GPG-KEY-conformal.txt
98
99- Import the public key into your GPG keyring:
100  ```bash
101  gpg --import GIT-GPG-KEY-conformal.txt
102  ```
103
104- Verify the release tag with the following command where `TAG_NAME` is a
105  placeholder for the specific tag:
106  ```bash
107  git tag -v TAG_NAME
108  ```
109
110## License
111
112Package wire is licensed under the [copyfree](http://copyfree.org) ISC
113License.
114