tapyrus 0.3.8 → 0.4.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/.github/workflows/ruby.yml +2 -2
- data/.ruby-version +1 -1
- data/README.md +43 -2
- data/lib/tapyrus/ext_key.rb +8 -4
- data/lib/tapyrus/key.rb +1 -1
- data/lib/tapyrus/key_path.rb +17 -13
- data/lib/tapyrus/message/fee_filter.rb +2 -2
- data/lib/tapyrus/message/header_and_short_ids.rb +4 -4
- data/lib/tapyrus/message/inventory.rb +1 -1
- data/lib/tapyrus/message/network_addr.rb +2 -2
- data/lib/tapyrus/message/ping.rb +2 -2
- data/lib/tapyrus/message/pong.rb +2 -2
- data/lib/tapyrus/message/send_cmpct.rb +2 -2
- data/lib/tapyrus/message/version.rb +3 -3
- data/lib/tapyrus/mnemonic.rb +9 -4
- data/lib/tapyrus/pstt/input.rb +422 -0
- data/lib/tapyrus/pstt/key_origin_info.rb +63 -0
- data/lib/tapyrus/pstt/output.rb +129 -0
- data/lib/tapyrus/pstt/proprietary.rb +54 -0
- data/lib/tapyrus/pstt/tx.rb +658 -0
- data/lib/tapyrus/pstt.rb +335 -0
- data/lib/tapyrus/rpc.rb +0 -2
- data/lib/tapyrus/script/script.rb +14 -4
- data/lib/tapyrus/secp256k1/rfc6979.rb +6 -3
- data/lib/tapyrus/tip0020.rb +341 -0
- data/lib/tapyrus/tx.rb +6 -2
- data/lib/tapyrus/tx_out.rb +2 -2
- data/lib/tapyrus/util.rb +3 -3
- data/lib/tapyrus/version.rb +1 -1
- data/lib/tapyrus/wallet/account.rb +2 -2
- data/lib/tapyrus/wallet/db.rb +3 -3
- data/lib/tapyrus/wallet/master_key.rb +2 -2
- data/lib/tapyrus.rb +3 -3
- data/tapyrusrb.gemspec +0 -4
- metadata +10 -81
- data/exe/tapyrusrb-cli +0 -5
- data/exe/tapyrusrbd +0 -42
- data/lib/tapyrus/network/connection.rb +0 -70
- data/lib/tapyrus/network/message_handler.rb +0 -244
- data/lib/tapyrus/network/peer.rb +0 -210
- data/lib/tapyrus/network/peer_discovery.rb +0 -43
- data/lib/tapyrus/network/pool.rb +0 -135
- data/lib/tapyrus/network.rb +0 -11
- data/lib/tapyrus/node/cli.rb +0 -114
- data/lib/tapyrus/node/configuration.rb +0 -36
- data/lib/tapyrus/node/spv.rb +0 -78
- data/lib/tapyrus/node.rb +0 -7
- data/lib/tapyrus/rpc/http_server.rb +0 -64
- data/lib/tapyrus/rpc/request_handler.rb +0 -146
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
module Tapyrus
|
|
2
|
-
module RPC
|
|
3
|
-
# RPC server's request handler.
|
|
4
|
-
module RequestHandler
|
|
5
|
-
# Returns an object containing various state info regarding blockchain processing.
|
|
6
|
-
def getblockchaininfo
|
|
7
|
-
h = {}
|
|
8
|
-
h[:chain] = Tapyrus.chain_params.network
|
|
9
|
-
best_block = node.chain.latest_block
|
|
10
|
-
h[:headers] = best_block.height
|
|
11
|
-
h[:bestblockhash] = best_block.header.block_id
|
|
12
|
-
h[:mediantime] = node.chain.mtp(best_block.block_hash)
|
|
13
|
-
h
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
# shutdown node
|
|
17
|
-
def stop
|
|
18
|
-
node.shutdown
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
# get block header information.
|
|
22
|
-
# @param [String] block_id block hash(big endian)
|
|
23
|
-
def getblockheader(block_id, verbose)
|
|
24
|
-
block_hash = block_id.rhex
|
|
25
|
-
entry = node.chain.find_entry_by_hash(block_hash)
|
|
26
|
-
raise ArgumentError.new("Block not found") unless entry
|
|
27
|
-
if verbose
|
|
28
|
-
{
|
|
29
|
-
hash: block_id,
|
|
30
|
-
height: entry.height,
|
|
31
|
-
features: entry.header.features,
|
|
32
|
-
featuresHex: entry.header.features.to_even_length_hex.ljust(8, "0"),
|
|
33
|
-
merkleroot: entry.header.merkle_root.rhex,
|
|
34
|
-
immutablemerkleroot: entry.header.im_merkle_root.rhex,
|
|
35
|
-
time: entry.header.time,
|
|
36
|
-
mediantime: node.chain.mtp(block_hash),
|
|
37
|
-
xfield_type: entry.header.x_field_type,
|
|
38
|
-
xfield: entry.header.x_field,
|
|
39
|
-
proof: entry.header.proof,
|
|
40
|
-
previousblockhash: entry.prev_hash.rhex,
|
|
41
|
-
nextblockhash: node.chain.next_hash(block_hash).rhex
|
|
42
|
-
}
|
|
43
|
-
else
|
|
44
|
-
entry.header.to_hex
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
# Returns connected peer information.
|
|
49
|
-
def getpeerinfo
|
|
50
|
-
node.pool.peers.map do |peer|
|
|
51
|
-
local_addr = "#{peer.remote_version.remote_addr.ip}:18333"
|
|
52
|
-
{
|
|
53
|
-
id: peer.id,
|
|
54
|
-
addr: "#{peer.host}:#{peer.port}",
|
|
55
|
-
addrlocal: local_addr,
|
|
56
|
-
services: peer.remote_version.services.to_even_length_hex.rjust(16, "0"),
|
|
57
|
-
relaytxes: peer.remote_version.relay,
|
|
58
|
-
lastsend: peer.last_send,
|
|
59
|
-
lastrecv: peer.last_recv,
|
|
60
|
-
bytessent: peer.bytes_sent,
|
|
61
|
-
bytesrecv: peer.bytes_recv,
|
|
62
|
-
conntime: peer.conn_time,
|
|
63
|
-
pingtime: peer.ping_time,
|
|
64
|
-
minping: peer.min_ping,
|
|
65
|
-
version: peer.remote_version.version,
|
|
66
|
-
subver: peer.remote_version.user_agent,
|
|
67
|
-
inbound: !peer.outbound?,
|
|
68
|
-
startingheight: peer.remote_version.start_height,
|
|
69
|
-
best_hash: peer.best_hash,
|
|
70
|
-
best_height: peer.best_height
|
|
71
|
-
}
|
|
72
|
-
end
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
# broadcast transaction
|
|
76
|
-
def sendrawtransaction(hex_tx)
|
|
77
|
-
tx = Tapyrus::Tx.parse_from_payload(hex_tx.htb)
|
|
78
|
-
|
|
79
|
-
# TODO check wether tx is valid
|
|
80
|
-
node.broadcast(tx)
|
|
81
|
-
tx.txid
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
# decode tx data.
|
|
85
|
-
def decoderawtransaction(hex_tx)
|
|
86
|
-
begin
|
|
87
|
-
Tapyrus::Tx.parse_from_payload(hex_tx.htb).to_h
|
|
88
|
-
rescue Exception
|
|
89
|
-
raise ArgumentError.new("TX decode failed")
|
|
90
|
-
end
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
# decode script data.
|
|
94
|
-
def decodescript(hex_script)
|
|
95
|
-
begin
|
|
96
|
-
script = Tapyrus::Script.parse_from_payload(hex_script.htb)
|
|
97
|
-
h = script.to_h
|
|
98
|
-
h.delete(:hex)
|
|
99
|
-
h[:p2sh] = script.to_p2sh.to_addr unless script.p2sh?
|
|
100
|
-
h
|
|
101
|
-
rescue Exception
|
|
102
|
-
raise ArgumentError.new("Script decode failed")
|
|
103
|
-
end
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
# wallet api
|
|
107
|
-
|
|
108
|
-
# create wallet
|
|
109
|
-
def createwallet(wallet_id = 1, wallet_path_prefix = Tapyrus::Wallet::Base.default_path_prefix)
|
|
110
|
-
wallet = Tapyrus::Wallet::Base.create(wallet_id, wallet_path_prefix)
|
|
111
|
-
node.wallet = wallet unless node.wallet
|
|
112
|
-
{ wallet_id: wallet.wallet_id, mnemonic: wallet.master_key.mnemonic }
|
|
113
|
-
end
|
|
114
|
-
|
|
115
|
-
# get wallet list.
|
|
116
|
-
def listwallets(wallet_path_prefix = Tapyrus::Wallet::Base.default_path_prefix)
|
|
117
|
-
Tapyrus::Wallet::Base.wallet_paths(wallet_path_prefix)
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
# get current wallet information.
|
|
121
|
-
def getwalletinfo
|
|
122
|
-
node.wallet ? node.wallet.to_h : {}
|
|
123
|
-
end
|
|
124
|
-
|
|
125
|
-
# get the list of current Wallet accounts.
|
|
126
|
-
def listaccounts
|
|
127
|
-
return {} unless node.wallet
|
|
128
|
-
accounts = {}
|
|
129
|
-
node.wallet.accounts.each { |a| accounts[a.name] = node.wallet.get_balance(a) }
|
|
130
|
-
accounts
|
|
131
|
-
end
|
|
132
|
-
|
|
133
|
-
# encrypt wallet.
|
|
134
|
-
def encryptwallet(passphrase)
|
|
135
|
-
return nil unless node.wallet
|
|
136
|
-
node.wallet.encrypt(passphrase)
|
|
137
|
-
"The wallet 'wallet_id: #{node.wallet.wallet_id}' has been encrypted."
|
|
138
|
-
end
|
|
139
|
-
|
|
140
|
-
# create new tapyrus address for receiving payments.
|
|
141
|
-
def getnewaddress(account_name)
|
|
142
|
-
node.wallet.generate_new_address(account_name)
|
|
143
|
-
end
|
|
144
|
-
end
|
|
145
|
-
end
|
|
146
|
-
end
|