You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The format used by bitcoinheaders.net is changing to use whole bytes
instead of nibles, which is easier to parse. We start using the v2 format
exclusively, which will allow deprecating the previous format.
Fixes#2786
// The first address contains an additional 0x00 prefix
127
-
valtoDrop=if (current.isEmpty) 28else20
128
-
current ++BitVector(address).drop(toDrop)
129
-
}.bytes
130
-
header.length match {
131
-
case80=>Some(BlockHeader.read(header.toArray))
132
-
case _ =>
133
-
log.error("bitcoinheaders.net response did not contain block header (invalid length): {}", response)
134
-
None
135
-
}
136
-
} else {
137
-
log.error("invalid response from bitcoinheaders.net: {}", response)
120
+
// From https://bitcoinheaders.net/:
121
+
// All headers are encoded with an arbitrary one byte prefix (which you must ignore, as it may change in the
122
+
// future), followed by a 0-indexed order byte (as nameservers often reorder responses). Entries are then prefixed
123
+
// by a single version byte (currently version 1) and placed into the remaining bytes of the IPv6 addresses.
124
+
// For example with the genesis block:
125
+
// v2.0.0.bitcoinheaders.net. 604800 IN AAAA 2603:7b12:b27a:c72c:3e67:768f:617f:c81b
126
+
// v2.0.0.bitcoinheaders.net. 604800 IN AAAA 2600:101::
127
+
// v2.0.0.bitcoinheaders.net. 604800 IN AAAA 2601::
128
+
// v2.0.0.bitcoinheaders.net. 604800 IN AAAA 2602::3b:a3ed:fd7a
129
+
// v2.0.0.bitcoinheaders.net. 604800 IN AAAA 2605:ab5f:49ff:ff00:1d1d:ac2b:7c00:0
130
+
// v2.0.0.bitcoinheaders.net. 604800 IN AAAA 2604:c388:8a51:323a:9fb8:aa4b:1e5e:4a29
131
+
// Which decodes to 0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a29ab5f49ffff001d1dac2b7c.
132
+
valdata= addresses
133
+
.filter(_.length >=2)
134
+
.map(_.tail) // the first byte is a prefix that we must ignore
135
+
.sortBy(_.head) // the second byte is a 0-indexed order byte
136
+
.flatMap(_.tail) // the remaining bytes contain the header chunks
137
+
if (data.length <81) {
138
+
log.error("bitcoinheaders.net response did not contain a 1-byte version followed by a block header: {}", ByteVector(data).toHex)
138
139
None
140
+
} elseif (data.head !=0x01) {
141
+
log.error("bitcoinheaders.net response is not using version 1: version={}", data.head)
0 commit comments