bitcoinrb 0.3.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/.travis.yml +5 -3
- data/README.md +17 -6
- data/bitcoinrb.gemspec +7 -7
- data/exe/bitcoinrbd +5 -0
- data/lib/bitcoin.rb +34 -11
- data/lib/bitcoin/bip85_entropy.rb +111 -0
- data/lib/bitcoin/block_filter.rb +14 -0
- data/lib/bitcoin/block_header.rb +2 -0
- data/lib/bitcoin/chain_params.rb +9 -8
- data/lib/bitcoin/chainparams/regtest.yml +1 -1
- data/lib/bitcoin/chainparams/signet.yml +39 -0
- data/lib/bitcoin/chainparams/testnet.yml +1 -1
- data/lib/bitcoin/constants.rb +45 -12
- data/lib/bitcoin/descriptor.rb +1 -1
- data/lib/bitcoin/errors.rb +19 -0
- data/lib/bitcoin/ext.rb +5 -0
- data/lib/bitcoin/ext/ecdsa.rb +31 -0
- data/lib/bitcoin/ext/json_parser.rb +46 -0
- data/lib/bitcoin/ext_key.rb +50 -19
- data/lib/bitcoin/key.rb +46 -29
- data/lib/bitcoin/key_path.rb +12 -5
- data/lib/bitcoin/message.rb +7 -0
- data/lib/bitcoin/message/base.rb +1 -0
- data/lib/bitcoin/message/cf_parser.rb +16 -0
- data/lib/bitcoin/message/cfcheckpt.rb +36 -0
- data/lib/bitcoin/message/cfheaders.rb +40 -0
- data/lib/bitcoin/message/cfilter.rb +35 -0
- data/lib/bitcoin/message/fee_filter.rb +1 -1
- data/lib/bitcoin/message/filter_load.rb +3 -3
- data/lib/bitcoin/message/get_cfcheckpt.rb +29 -0
- data/lib/bitcoin/message/get_cfheaders.rb +24 -0
- data/lib/bitcoin/message/get_cfilters.rb +25 -0
- data/lib/bitcoin/message/header_and_short_ids.rb +1 -1
- data/lib/bitcoin/message/inventory.rb +1 -1
- data/lib/bitcoin/message/merkle_block.rb +1 -1
- data/lib/bitcoin/message/network_addr.rb +3 -3
- data/lib/bitcoin/message/ping.rb +1 -1
- data/lib/bitcoin/message/pong.rb +1 -1
- data/lib/bitcoin/message/send_cmpct.rb +2 -2
- data/lib/bitcoin/message/version.rb +7 -0
- data/lib/bitcoin/mnemonic.rb +7 -7
- data/lib/bitcoin/network/peer.rb +9 -4
- data/lib/bitcoin/network/peer_discovery.rb +1 -1
- data/lib/bitcoin/node/cli.rb +14 -10
- data/lib/bitcoin/node/configuration.rb +3 -1
- data/lib/bitcoin/node/spv.rb +9 -1
- data/lib/bitcoin/opcodes.rb +14 -1
- data/lib/bitcoin/out_point.rb +7 -0
- data/lib/bitcoin/payment_code.rb +92 -0
- data/lib/bitcoin/psbt/hd_key_path.rb +1 -1
- data/lib/bitcoin/psbt/input.rb +8 -17
- data/lib/bitcoin/psbt/output.rb +1 -1
- data/lib/bitcoin/psbt/tx.rb +11 -16
- data/lib/bitcoin/rpc/bitcoin_core_client.rb +22 -12
- data/lib/bitcoin/rpc/request_handler.rb +2 -2
- data/lib/bitcoin/script/script.rb +68 -28
- data/lib/bitcoin/script/script_error.rb +27 -1
- data/lib/bitcoin/script/script_interpreter.rb +164 -67
- data/lib/bitcoin/script/tx_checker.rb +64 -14
- data/lib/bitcoin/secp256k1.rb +1 -0
- data/lib/bitcoin/secp256k1/native.rb +138 -25
- data/lib/bitcoin/secp256k1/rfc6979.rb +43 -0
- data/lib/bitcoin/secp256k1/ruby.rb +82 -54
- data/lib/bitcoin/sighash_generator.rb +156 -0
- data/lib/bitcoin/slip39/sss.rb +5 -2
- data/lib/bitcoin/store.rb +2 -1
- data/lib/bitcoin/store/chain_entry.rb +1 -0
- data/lib/bitcoin/store/db/level_db.rb +2 -2
- data/lib/bitcoin/store/utxo_db.rb +226 -0
- data/lib/bitcoin/tx.rb +17 -88
- data/lib/bitcoin/tx_in.rb +4 -5
- data/lib/bitcoin/tx_out.rb +2 -3
- data/lib/bitcoin/util.rb +43 -6
- data/lib/bitcoin/version.rb +1 -1
- data/lib/bitcoin/wallet.rb +1 -0
- data/lib/bitcoin/wallet/account.rb +2 -1
- data/lib/bitcoin/wallet/base.rb +3 -3
- data/lib/bitcoin/wallet/db.rb +1 -1
- data/lib/bitcoin/wallet/master_key.rb +1 -0
- data/lib/bitcoin/wallet/utxo.rb +37 -0
- metadata +50 -32
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa485194b6a1f5ea2ba0a4ed3355cae8cc8cdd4252475a78dc811ec54a93dfa4
|
4
|
+
data.tar.gz: 5c2c91ab2041b88e0ada77a1099df5e4d564f2d1da0a2963e3ff1beec0b63172
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c84550004b92167af33a7832c69cafeb44e24a98d491865976194614eed2ea6c831f5ac47a716ec989d1f759786741a26cb81fa6b5da33850a2e2b4dc0fa331b
|
7
|
+
data.tar.gz: fb8bdfea37eb452b565f826cb2a12c56865fd80410376f0d444cddf339a1e4eb423988ef617a1dc84b573bb114db3ddae89ae49f60afd882349e92169bac6031
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
ruby-3.0.0
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -9,14 +9,17 @@ NOTE: Bitcoinrb work in progress, and there is a possibility of incompatible cha
|
|
9
9
|
|
10
10
|
Bitcoinrb supports following feature:
|
11
11
|
|
12
|
-
* Bitcoin script interpreter(including [BIP-65](https://github.com/bitcoin/bips/blob/master/bip-0065.mediawiki), [BIP-68](https://github.com/bitcoin/bips/blob/master/bip-0068.mediawiki), [BIP-112](https://github.com/bitcoin/bips/blob/master/bip-0112.mediawiki))
|
13
|
-
* De/serialization of Bitcoin protocol network messages
|
14
|
-
* De/serialization of blocks and transactions
|
12
|
+
* [Bitcoin script interpreter](https://github.com/chaintope/bitcoinrb/wiki/Script)(including [BIP-65](https://github.com/bitcoin/bips/blob/master/bip-0065.mediawiki), [BIP-68](https://github.com/bitcoin/bips/blob/master/bip-0068.mediawiki), [BIP-112](https://github.com/bitcoin/bips/blob/master/bip-0112.mediawiki))
|
13
|
+
* [De/serialization of Bitcoin protocol network messages](https://github.com/chaintope/bitcoinrb/wiki/P2P-Message)
|
14
|
+
* De/serialization of blocks and [transactions](https://github.com/chaintope/bitcoinrb/wiki/Transaction)
|
15
15
|
* Key generation and verification for ECDSA, including [BIP-32](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki) and [BIP-39](https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki) supports.
|
16
16
|
* ECDSA signature(RFC6979 -Deterministic ECDSA, LOW-S, LOW-R support)
|
17
17
|
* Segwit support (parsing segwit payload, Bech32 address, sign for segwit tx, [BIP-141](https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki), [BIP-143](https://github.com/bitcoin/bips/blob/master/bip-0143.mediawiki), [BIP-144](https://github.com/bitcoin/bips/blob/master/bip-0144.mediawiki))
|
18
18
|
* [BIP-173](https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki) Bech32 address support
|
19
19
|
* [BIP-174](https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki) PSBT(Partially Signed Bitcoin Transaction) support
|
20
|
+
* [BIP-85](https://github.com/bitcoin/bips/blob/master/bip-0085.mediawiki) Deterministic Entropy From BIP32 Keychains support by `Bitcoin::BIP85Entropy` class.
|
21
|
+
* Schnorr signature([BIP-340](https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki))
|
22
|
+
* Taproot consensus([BIP-341](https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki) and [BIP-342](https://github.com/bitcoin/bips/blob/master/bip-0342.mediawiki))
|
20
23
|
* [WIP] SPV node
|
21
24
|
* [WIP] 0ff-chain protocol
|
22
25
|
|
@@ -36,10 +39,10 @@ If you use node features, please install level DB as follows.
|
|
36
39
|
|
37
40
|
$ brew install leveldb
|
38
41
|
|
39
|
-
and put `leveldb-
|
42
|
+
and put `leveldb-native` in your Gemfile and run bundle install.
|
40
43
|
|
41
|
-
```
|
42
|
-
gem leveldb-
|
44
|
+
```ruby
|
45
|
+
gem 'leveldb-native'
|
43
46
|
```
|
44
47
|
|
45
48
|
## Installation
|
@@ -92,6 +95,14 @@ Bitcoin.chain_params = :regtest
|
|
92
95
|
|
93
96
|
This parameter is described in https://github.com/chaintope/bitcoinrb/blob/master/lib/bitcoin/chainparams/regtest.yml.
|
94
97
|
|
98
|
+
* default signet
|
99
|
+
|
100
|
+
```ruby
|
101
|
+
Bitcoin.chain_params = :signet
|
102
|
+
```
|
103
|
+
|
104
|
+
This parameter is described in https://github.com/chaintope/bitcoinrb/blob/master/lib/bitcoin/chainparams/signet.yml.
|
105
|
+
|
95
106
|
## Contributing
|
96
107
|
|
97
108
|
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/bitcoinrb. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
data/bitcoinrb.gemspec
CHANGED
@@ -10,8 +10,8 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.authors = ["azuchi"]
|
11
11
|
spec.email = ["azuchi@chaintope.com"]
|
12
12
|
|
13
|
-
spec.summary = %q{
|
14
|
-
spec.description = %q{
|
13
|
+
spec.summary = %q{The implementation of Bitcoin Protocol for Ruby.}
|
14
|
+
spec.description = %q{The implementation of Bitcoin Protocol for Ruby.}
|
15
15
|
spec.homepage = 'https://github.com/chaintope/bitcoinrb'
|
16
16
|
spec.license = "MIT"
|
17
17
|
|
@@ -29,19 +29,19 @@ Gem::Specification.new do |spec|
|
|
29
29
|
spec.add_runtime_dependency 'ffi'
|
30
30
|
spec.add_runtime_dependency 'leb128', '~> 1.0.0'
|
31
31
|
spec.add_runtime_dependency 'eventmachine_httpserver'
|
32
|
-
spec.add_runtime_dependency 'rest-client'
|
33
32
|
spec.add_runtime_dependency 'iniparse'
|
34
33
|
spec.add_runtime_dependency 'siphash'
|
35
34
|
spec.add_runtime_dependency 'protobuf', '3.8.5'
|
36
|
-
spec.add_runtime_dependency '
|
37
|
-
spec.add_runtime_dependency '
|
35
|
+
spec.add_runtime_dependency 'json_pure', '>= 2.3.1'
|
36
|
+
spec.add_runtime_dependency 'bip-schnorr', '>= 0.3.2'
|
38
37
|
|
39
38
|
# for options
|
40
|
-
spec.add_development_dependency 'leveldb-
|
39
|
+
spec.add_development_dependency 'leveldb-native'
|
41
40
|
|
42
41
|
spec.add_development_dependency 'bundler'
|
43
|
-
spec.add_development_dependency 'rake', '
|
42
|
+
spec.add_development_dependency 'rake', '>= 12.3.3'
|
44
43
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
45
44
|
spec.add_development_dependency 'timecop'
|
45
|
+
spec.add_development_dependency 'webmock', '>= 3.11.1'
|
46
46
|
|
47
47
|
end
|
data/exe/bitcoinrbd
CHANGED
data/lib/bitcoin.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
|
4
4
|
require 'bitcoin/version'
|
5
5
|
require 'eventmachine'
|
6
|
-
require '
|
6
|
+
require 'schnorr'
|
7
7
|
require 'securerandom'
|
8
8
|
require 'json'
|
9
9
|
require 'bech32'
|
@@ -14,6 +14,7 @@ require_relative 'openassets'
|
|
14
14
|
|
15
15
|
module Bitcoin
|
16
16
|
|
17
|
+
autoload :Ext, 'bitcoin/ext'
|
17
18
|
autoload :Util, 'bitcoin/util'
|
18
19
|
autoload :ChainParams, 'bitcoin/chain_params'
|
19
20
|
autoload :Message, 'bitcoin/message'
|
@@ -54,8 +55,14 @@ module Bitcoin
|
|
54
55
|
autoload :KeyPath, 'bitcoin/key_path'
|
55
56
|
autoload :Descriptor, 'bitcoin/descriptor'
|
56
57
|
autoload :SLIP39, 'bitcoin/slip39'
|
58
|
+
autoload :Aezeed, 'bitcoin/aezeed'
|
59
|
+
autoload :PaymentCode, 'bitcoin/payment_code'
|
60
|
+
autoload :BIP85Entropy, 'bitcoin/bip85_entropy'
|
61
|
+
autoload :Errors, 'bitcoin/errors'
|
62
|
+
autoload :SigHashGenerator, 'bitcoin/sighash_generator'
|
57
63
|
|
58
64
|
require_relative 'bitcoin/constants'
|
65
|
+
require_relative 'bitcoin/ext/ecdsa'
|
59
66
|
|
60
67
|
extend Util
|
61
68
|
|
@@ -63,7 +70,7 @@ module Bitcoin
|
|
63
70
|
|
64
71
|
# set bitcoin network chain params
|
65
72
|
def self.chain_params=(name)
|
66
|
-
raise "chain params for #{name} is not defined." unless %i(mainnet testnet regtest).include?(name.to_sym)
|
73
|
+
raise "chain params for #{name} is not defined." unless %i(mainnet testnet regtest signet).include?(name.to_sym)
|
67
74
|
@current_chain = nil
|
68
75
|
@chain_param = name.to_sym
|
69
76
|
end
|
@@ -78,6 +85,8 @@ module Bitcoin
|
|
78
85
|
@current_chain = Bitcoin::ChainParams.testnet
|
79
86
|
when :regtest
|
80
87
|
@current_chain = Bitcoin::ChainParams.regtest
|
88
|
+
when :signet
|
89
|
+
@current_chain = Bitcoin::ChainParams.signet
|
81
90
|
end
|
82
91
|
@current_chain
|
83
92
|
end
|
@@ -104,7 +113,7 @@ module Bitcoin
|
|
104
113
|
class ::String
|
105
114
|
# binary convert to hex string
|
106
115
|
def bth
|
107
|
-
|
116
|
+
unpack1('H*')
|
108
117
|
end
|
109
118
|
|
110
119
|
# hex string convert to binary
|
@@ -161,6 +170,27 @@ module Bitcoin
|
|
161
170
|
self[offset..-1]
|
162
171
|
end
|
163
172
|
|
173
|
+
def valid_pushdata_length?
|
174
|
+
buf = StringIO.new(self)
|
175
|
+
opcode = buf.read(1).ord
|
176
|
+
offset = 1
|
177
|
+
return false if buf.eof?
|
178
|
+
len = case opcode
|
179
|
+
when Bitcoin::Opcodes::OP_PUSHDATA1
|
180
|
+
offset += 1
|
181
|
+
buf.read(1).unpack1('C')
|
182
|
+
when Bitcoin::Opcodes::OP_PUSHDATA2
|
183
|
+
offset += 2
|
184
|
+
buf.read(2).unpack1('v')
|
185
|
+
when Bitcoin::Opcodes::OP_PUSHDATA4
|
186
|
+
offset += 4
|
187
|
+
buf.read(4).unpack1('V')
|
188
|
+
else
|
189
|
+
opcode
|
190
|
+
end
|
191
|
+
self.bytesize == len + offset
|
192
|
+
end
|
193
|
+
|
164
194
|
# whether value is hex or not hex
|
165
195
|
# @return [Boolean] return true if data is hex
|
166
196
|
def valid_hex?
|
@@ -188,7 +218,7 @@ module Bitcoin
|
|
188
218
|
if value.is_a?(Array)
|
189
219
|
result.update(key => value.map{|v|v.to_h})
|
190
220
|
else
|
191
|
-
result.update(key => value)
|
221
|
+
result.update(key => value.class.to_s.start_with?("Bitcoin::") ? value.to_h : value)
|
192
222
|
end
|
193
223
|
end
|
194
224
|
end
|
@@ -215,11 +245,4 @@ module Bitcoin
|
|
215
245
|
end
|
216
246
|
end
|
217
247
|
|
218
|
-
class ::ECDSA::Signature
|
219
|
-
# convert signature to der string.
|
220
|
-
def to_der
|
221
|
-
ECDSA::Format::SignatureDerString.encode(self)
|
222
|
-
end
|
223
|
-
end
|
224
|
-
|
225
248
|
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
module Bitcoin
|
2
|
+
|
3
|
+
# Deterministic Entropy From BIP32 Keychains
|
4
|
+
# https://github.com/bitcoin/bips/blob/master/bip-0085.mediawiki
|
5
|
+
class BIP85Entropy
|
6
|
+
|
7
|
+
BIP85_PATH = 83696968 + HARDENED_THRESHOLD
|
8
|
+
|
9
|
+
include Bitcoin::KeyPath
|
10
|
+
|
11
|
+
attr_reader :root_key #hex format
|
12
|
+
|
13
|
+
# Import root key.
|
14
|
+
# @param [String] base58 master bip32 root key.
|
15
|
+
# @return [Bitcoin::BIP85Entropy]
|
16
|
+
def self.from_base58(base58)
|
17
|
+
key = Bitcoin::ExtKey.from_base58(base58)
|
18
|
+
self.new(key)
|
19
|
+
end
|
20
|
+
|
21
|
+
# derive entropy
|
22
|
+
# @param [String] path derive path.
|
23
|
+
# @return [Tuple(String, Object)] a tuple of entropy with hex format and results depending the application.
|
24
|
+
def derive(path)
|
25
|
+
raise ArgumentError, "Invalid BIP85 path format." unless path.start_with?("m/83696968'")
|
26
|
+
derived_key = root_key
|
27
|
+
parse_key_path(path).each{|num| derived_key = derived_key.derive(num)}
|
28
|
+
derived_key = derived_key.priv
|
29
|
+
entropy = Bitcoin.hmac_sha512("bip-entropy-from-k", derived_key.htb).bth
|
30
|
+
app_no = path.split('/')[2]
|
31
|
+
case app_no
|
32
|
+
when "39'"
|
33
|
+
bip39_entropy(path, entropy)
|
34
|
+
when "2'"
|
35
|
+
hd_seed_entropy(entropy)
|
36
|
+
when "32'"
|
37
|
+
xprv_entropy(entropy)
|
38
|
+
else
|
39
|
+
[entropy, entropy]
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def initialize(root_key)
|
46
|
+
@root_key = root_key
|
47
|
+
end
|
48
|
+
|
49
|
+
# derive BIP39 entropy.
|
50
|
+
def bip39_entropy(path, entropy)
|
51
|
+
params = path.split('/')
|
52
|
+
word_len = params[4]
|
53
|
+
language = code_to_language(params[3])
|
54
|
+
entropy = case word_len
|
55
|
+
when "12'"
|
56
|
+
entropy[0...32]
|
57
|
+
when "18'"
|
58
|
+
entropy[0...48]
|
59
|
+
when "24'"
|
60
|
+
entropy[0...64]
|
61
|
+
else
|
62
|
+
raise ArgumentError, "Word length #{word_len} does not supported."
|
63
|
+
end
|
64
|
+
mnemonic = Bitcoin::Mnemonic.new(language)
|
65
|
+
[entropy, mnemonic.to_mnemonic(entropy)]
|
66
|
+
end
|
67
|
+
|
68
|
+
# derive HD-Seed WIF entropy.
|
69
|
+
def hd_seed_entropy(entropy)
|
70
|
+
result = entropy[0...64]
|
71
|
+
[result, Bitcoin::Key.new(priv_key: result).to_wif]
|
72
|
+
end
|
73
|
+
|
74
|
+
# derive xprv entropy
|
75
|
+
def xprv_entropy(entropy)
|
76
|
+
chaincode = entropy[0...64]
|
77
|
+
private_key = Bitcoin::Key.new(priv_key: entropy[64..-1])
|
78
|
+
ext_key = Bitcoin::ExtKey.new
|
79
|
+
ext_key.key = private_key
|
80
|
+
ext_key.chain_code = chaincode.htb
|
81
|
+
ext_key.depth = 0
|
82
|
+
ext_key.number = 0
|
83
|
+
ext_key.parent_fingerprint = Bitcoin::ExtKey::MASTER_FINGERPRINT
|
84
|
+
[entropy, ext_key.to_base58]
|
85
|
+
end
|
86
|
+
|
87
|
+
# convert language code to language string.
|
88
|
+
def code_to_language(code)
|
89
|
+
case code
|
90
|
+
when "0'"
|
91
|
+
"english"
|
92
|
+
when "1'"
|
93
|
+
"japanese"
|
94
|
+
when "3'"
|
95
|
+
"spanish"
|
96
|
+
when "4'"
|
97
|
+
"chinese_simplified"
|
98
|
+
when "5'"
|
99
|
+
"chinese_traditional"
|
100
|
+
when "6'"
|
101
|
+
"french"
|
102
|
+
when "7'"
|
103
|
+
"italian"
|
104
|
+
else
|
105
|
+
raise ArgumentError, "bitcoinrb does not support language: #{code}"
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
end
|
110
|
+
|
111
|
+
end
|
data/lib/bitcoin/block_filter.rb
CHANGED
@@ -43,6 +43,20 @@ module Bitcoin
|
|
43
43
|
BlockFilter.new(filter_type, filter, block.block_hash)
|
44
44
|
end
|
45
45
|
|
46
|
+
# Decode Block Filter from encoded filter
|
47
|
+
# @param [Integer] filter_type filter type.
|
48
|
+
# @param [String] block_hash block hash with hex format. not little endian.
|
49
|
+
# @param [String] encoded encoded_filter with hex format.
|
50
|
+
# @return [Bitcoin::BlockFilter] block filter object.
|
51
|
+
def self.decode(filter_type, block_hash, encoded)
|
52
|
+
filter = case filter_type
|
53
|
+
when TYPE[:basic]
|
54
|
+
GCSFilter.new(block_hash.htb[0...16], BASIC_FILTER_P, BASIC_FILTER_M, encoded_filter: encoded)
|
55
|
+
else
|
56
|
+
raise "unknown filter type: #{filter_type}."
|
57
|
+
end
|
58
|
+
BlockFilter.new(filter_type, filter, block_hash)
|
59
|
+
end
|
46
60
|
|
47
61
|
# calculate filter hash.
|
48
62
|
# @return [String] this filter hash with hex format.
|
data/lib/bitcoin/block_header.rb
CHANGED
data/lib/bitcoin/chain_params.rb
CHANGED
@@ -36,9 +36,6 @@ module Bitcoin
|
|
36
36
|
|
37
37
|
attr_accessor :dust_relay_fee
|
38
38
|
|
39
|
-
# fork coin id.
|
40
|
-
attr_accessor :fork_id
|
41
|
-
|
42
39
|
# mainnet genesis
|
43
40
|
def self.mainnet
|
44
41
|
init('mainnet')
|
@@ -54,6 +51,11 @@ module Bitcoin
|
|
54
51
|
init('regtest')
|
55
52
|
end
|
56
53
|
|
54
|
+
# signet genesis
|
55
|
+
def self.signet
|
56
|
+
init('signet')
|
57
|
+
end
|
58
|
+
|
57
59
|
def mainnet?
|
58
60
|
network == 'mainnet'
|
59
61
|
end
|
@@ -66,6 +68,10 @@ module Bitcoin
|
|
66
68
|
network == 'regtest'
|
67
69
|
end
|
68
70
|
|
71
|
+
def signet?
|
72
|
+
network == 'signet'
|
73
|
+
end
|
74
|
+
|
69
75
|
def genesis_block
|
70
76
|
header = Bitcoin::BlockHeader.new(
|
71
77
|
genesis['version'], genesis['prev_hash'].rhex, genesis['merkle_root'].rhex,
|
@@ -73,11 +79,6 @@ module Bitcoin
|
|
73
79
|
Bitcoin::Block.new(header)
|
74
80
|
end
|
75
81
|
|
76
|
-
# whether fork coin.
|
77
|
-
def fork_chain?
|
78
|
-
!fork_id.nil?
|
79
|
-
end
|
80
|
-
|
81
82
|
def self.init(name)
|
82
83
|
i = YAML.load(File.open("#{__dir__}/chainparams/#{name}.yml"))
|
83
84
|
i.dust_relay_fee ||= Bitcoin::DUST_RELAY_TX_FEE
|
@@ -9,7 +9,7 @@ privkey_version: "ef"
|
|
9
9
|
extended_privkey_version: "04358394"
|
10
10
|
extended_pubkey_version: "043587cf"
|
11
11
|
bip49_pubkey_p2wpkh_p2sh_version: "044a5262"
|
12
|
-
bip49_pubkey_p2wsh_p2sh_version: "
|
12
|
+
bip49_pubkey_p2wsh_p2sh_version: "024289ef"
|
13
13
|
bip49_privkey_p2wpkh_p2sh_version: "044a4e28"
|
14
14
|
bip49_privkey_p2wsh_p2sh_version: "024285b5"
|
15
15
|
bip84_pubkey_p2wpkh_version: "045f1cf6"
|
@@ -0,0 +1,39 @@
|
|
1
|
+
--- !ruby/object:Bitcoin::ChainParams
|
2
|
+
network: "signet"
|
3
|
+
magic_head: "0a03cf40"
|
4
|
+
message_magic: "Bitcoin Signed Message:\n"
|
5
|
+
address_version: "6f"
|
6
|
+
p2sh_version: "c4"
|
7
|
+
bech32_hrp: 'tb'
|
8
|
+
privkey_version: "ef"
|
9
|
+
extended_privkey_version: "04358394"
|
10
|
+
extended_pubkey_version: "043587cf"
|
11
|
+
bip49_pubkey_p2wpkh_p2sh_version: "044a5262"
|
12
|
+
bip49_pubkey_p2wsh_p2sh_version: "024289ef"
|
13
|
+
bip49_privkey_p2wpkh_p2sh_version: "044a4e28"
|
14
|
+
bip49_privkey_p2wsh_p2sh_version: "024285b5"
|
15
|
+
bip84_pubkey_p2wpkh_version: "045f1cf6"
|
16
|
+
bip84_pubkey_p2wsh_version: "02575483"
|
17
|
+
bip84_privkey_p2wpkh_version: "045f18bc"
|
18
|
+
bip84_privkey_p2wsh_version: "02575048"
|
19
|
+
default_port: 38333
|
20
|
+
protocol_version: 70013
|
21
|
+
retarget_interval: 2016
|
22
|
+
retarget_time: 1209600 # 2 weeks
|
23
|
+
target_spacing: 600 # block interval
|
24
|
+
max_money: 21000000
|
25
|
+
bip34_height: 227931
|
26
|
+
genesis_hash: "00000008819873e925422c1ff0f99f7cc9bbb232af63a077a480a3633bee1ef6"
|
27
|
+
proof_of_work_limit: 0x1d00ffff
|
28
|
+
dns_seeds:
|
29
|
+
- "178.128.221.177"
|
30
|
+
- "2a01:7c8:d005:390::5"
|
31
|
+
genesis:
|
32
|
+
hash: "00000008819873e925422c1ff0f99f7cc9bbb232af63a077a480a3633bee1ef6"
|
33
|
+
merkle_root: "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"
|
34
|
+
time: 1598918400
|
35
|
+
nonce: 52613770
|
36
|
+
bits: 0x1e0377ae
|
37
|
+
version: 1
|
38
|
+
prev_hash: "0000000000000000000000000000000000000000000000000000000000000000"
|
39
|
+
bip44_coin_type: 1
|