openassets-ruby 0.6.5 → 0.6.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9f4f00149febc1e6b4b339fb9a9129befccff7be
4
- data.tar.gz: ef6701a208bd54ed9bfc99f5d2df6ac2299c76b3
3
+ metadata.gz: f1bf5ca70ee3d56eb275492e20de8af986e6da15
4
+ data.tar.gz: 54c38aaafbfeb618ed5ad35510074b6adacea338
5
5
  SHA512:
6
- metadata.gz: 999d13563e91a619f001ec4941077e7825de88735a6ad460389e2956d3fe843ba0b2e0a3577731862cecbbdcfef0eeffc9d67526630ae3b3354a2a348581d831
7
- data.tar.gz: e15ec20eda29fc0d2c01632457c79e8148c28b1af73be73f7a27b931f0695c3273250e02680cf7e18c11bbeb332819558d705bc503201b2d53d86cdf476ab5b5
6
+ metadata.gz: 1a175cb0af22f388f5e372c2df4c532b065d011deae294692a41384e2ae09d1439f600d17e9841a796a531351dc9a4a46219fb4278df99231ce00aa527c51f92
7
+ data.tar.gz: 07ea55a4edd0bab117c3b4cfb2d4cb9242aa2cc1ff101dec7cf840e65264beab53c1acda1608a6a4de6430c26927dabd0c0d60eca73fe1680afc22f63a31de34
@@ -1 +1 @@
1
- ruby-2.4.1
1
+ 2.4.1
@@ -33,9 +33,7 @@ module OpenAssets
33
33
  @metadata ||= ''
34
34
  metadata_length = Bitcoin::Protocol.pack_var_int(@metadata.length).unpack("H*")
35
35
  payload << sort_count(metadata_length[0])
36
- tmp = []
37
- @metadata.bytes{|b| tmp << b.to_s(16)}
38
- payload << tmp.join
36
+ payload << @metadata.bytes.map{|b| sprintf("%02x", b)}.join
39
37
  payload.join
40
38
  end
41
39
 
@@ -127,4 +125,4 @@ module OpenAssets
127
125
  end
128
126
 
129
127
  end
130
- end
128
+ end
@@ -6,28 +6,24 @@ module OpenAssets
6
6
  # The implementation of BlockChain provider using Bitcoin Core.
7
7
  class BitcoinCoreProvider < BlockChainProviderBase
8
8
 
9
- RPC_API = [
10
- :addmultisigaddress, :addnode, :backupwallet, :bumpfee, :createmultisig, :createrawtransaction, :decoderawtransaction,
11
- :decodescript, :dumpprivkey, :dumpwallet, :encryptwallet, :estimatefee, :estimatepriority, :generate, :generatetoaddress,
12
- :getaccountaddress, :getaccount, :getaddednodeinfo, :getaddressesbyaccount, :getbalance, :getbestblockhash,
13
- :getblock, :getblockchaininfo, :getblockcount, :getblockhash, :getblockheader, :getchaintips, :getconnectioncount, :getdifficulty,
14
- :getmempoolancestors, :getmempooldescendants, :getmempoolentry, :clearbanned, :disconnectnode,
15
- :getgenerate, :gethashespersec, :getinfo, :getmempoolinfo, :getmininginfo, :getnettotals, :getnetworkhashps,
16
- :getnetworkinfo, :getnewaddress, :getpeerinfo, :getrawchangeaddress, :getrawmempool, :getrawtransaction,
17
- :getreceivedbyaccount, :getreceivedbyaddress, :gettransaction, :gettxout, :gettxoutproof, :gettxoutsetinfo, :preciousblock, :pruneblockchain,
18
- :getunconfirmedbalance, :getwalletinfo, :importmulti, :getwork, :help, :importaddress, :importprivkey, :importwallet, :importpubkey,
19
- :keypoolrefill, :listaccounts, :listaddressgroupings, :listlockunspent, :listreceivedbyaccount, :listreceivedbyaddress,
20
- :listsinceblock, :listtransactions, :listunspent, :lockunspent, :move, :ping, :prioritisetransaction, :sendfrom,
21
- :sendmany, :sendrawtransaction, :sendtoaddress, :setaccount, :setgenerate, :settxfee, :signmessage, :signrawtransaction,
22
- :stop, :submitblock, :validateaddress, :verifychain, :verifymessage, :verifytxoutproof, :walletlock, :walletpassphrase,
23
- :walletpassphrasechange, :listbanned, :setban, :setnetworkactive, :fundrawtransaction, :estimatesmartfee, :estimatesmartpriority,
24
- :signmessagewithprivkey, :abandontransaction, :addwitnessaddress, :importprunedfunds, :importpubkey, :removeprunedfunds
25
- ]
26
-
27
9
  attr_reader :config
28
10
 
29
11
  def initialize(config)
30
12
  @config = config
13
+
14
+ commands = request(:help).split("\n").inject([]) do |memo_ary, line|
15
+ if !line.empty? && !line.start_with?('==')
16
+ memo_ary << line.split(' ').first.to_sym
17
+ end
18
+ memo_ary
19
+ end
20
+ BitcoinCoreProvider.class_eval do
21
+ commands.each do |command|
22
+ define_method(command) do |*params|
23
+ request(command, *params)
24
+ end
25
+ end
26
+ end
31
27
  end
32
28
 
33
29
  # Get an array of unspent transaction outputs belonging to this wallet.
@@ -35,7 +31,7 @@ module OpenAssets
35
31
  # @param [Integer] min The minimum number of confirmations the transaction containing an output must have in order to be returned. Default is 1.
36
32
  # @param [Integer] max The maximum number of confirmations the transaction containing an output may have in order to be returned. Default is 9999999.
37
33
  def list_unspent(addresses = [], min = 1 , max = 9999999)
38
- request('listunspent', min, max, addresses)
34
+ listunspent(min, max, addresses)
39
35
  end
40
36
 
41
37
  # Get raw transaction.
@@ -44,7 +40,7 @@ module OpenAssets
44
40
  # @return [String] (if verbose=0)—the serialized transaction. (if verbose=1)—the decoded transaction. (if transaction not found)—nil.
45
41
  def get_transaction(transaction_hash, verbose = 0)
46
42
  begin
47
- request('getrawtransaction', transaction_hash, verbose)
43
+ getrawtransaction(transaction_hash, verbose)
48
44
  rescue OpenAssets::Provider::ApiError => e
49
45
  nil
50
46
  end
@@ -54,7 +50,7 @@ module OpenAssets
54
50
  # @param [String] tx The serialized format transaction.
55
51
  # @return [Bitcoin::Protocol::Tx] The signed transaction.
56
52
  def sign_transaction(tx)
57
- signed_tx = request('signrawtransaction', tx)
53
+ signed_tx = signrawtransaction(tx)
58
54
  raise OpenAssets::Error, 'Could not sign the transaction.' unless signed_tx['complete']
59
55
  Bitcoin::Protocol::Tx.new(signed_tx['hex'].htb)
60
56
  end
@@ -63,18 +59,13 @@ module OpenAssets
63
59
  # @param [String] tx The serialized format transaction.
64
60
  # @return [String] The TXID or error message.
65
61
  def send_transaction(tx)
66
- request('sendrawtransaction', tx)
62
+ sendrawtransaction(tx)
67
63
  end
68
64
 
69
65
  # Adds an address or pubkey script to the wallet without the associated private key, allowing you to watch for transactions affecting that address or pubkey script without being able to spend any of its outputs.
70
66
  # @param [String] address Either a P2PKH or P2SH address encoded in base58check, or a pubkey script encoded as hex.
71
67
  def import_address(address)
72
- request('importaddress', address)
73
- end
74
-
75
- def method_missing(method, *params)
76
- super unless RPC_API.include?(method)
77
- request(method, *params)
68
+ importaddress(address)
78
69
  end
79
70
 
80
71
  private
@@ -1,3 +1,3 @@
1
1
  module OpenAssets
2
- VERSION = '0.6.5'
2
+ VERSION = '0.6.6'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openassets-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.5
4
+ version: 0.6.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - azuchi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-07-06 00:00:00.000000000 Z
11
+ date: 2017-11-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bitcoin-ruby
@@ -239,7 +239,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
239
239
  version: '0'
240
240
  requirements: []
241
241
  rubyforge_project:
242
- rubygems_version: 2.6.11
242
+ rubygems_version: 2.6.13
243
243
  signing_key:
244
244
  specification_version: 4
245
245
  summary: The implementation of the Open Assets Protocol for Ruby.