coin-op 0.4.4 → 0.4.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 763ee324d095d2518ed75c63c176c03bc3c2cf8e
4
- data.tar.gz: b6eec07e082b37b2cadb269bd741713aad1be530
3
+ metadata.gz: ddcac303efc3cea02f7d42a2a2a7a9c89d16c292
4
+ data.tar.gz: 9a14fbb3178a73eeb5379fa486d6551c3c57835a
5
5
  SHA512:
6
- metadata.gz: 241a753e6a272af37c651c303bf96aa239b725b232a68381e9221e98577d05a21901f8a8ac4f1e01a02b556a2117c19ba907a7e0b480f3ac1f69b2b16b873cb5
7
- data.tar.gz: 0c823fc19951647daa65312e0f5af73395594bb52461c5f09dc432a716b9789de484cc5168fb8159308e1d0bc104109506edb1d347b413753cb2d6760da56bc2
6
+ metadata.gz: b7f368cf4336f909d61a54cad255936c9c8cc5b95bef6ffbdd6025df699b18d7bad1c6e25e2900a05a49df1586a2ed230260a5e1d9c8612d6dd52150ef9db041
7
+ data.tar.gz: bc80f5346aa7d29608cb3d115188be258cf01e7b0d21b80b8a8d55a77a79fd636c44cd6d90b24ad9e070f25d1f2a3835af5901efcbe2b4ecb264a1937411cc87
Binary file
data.tar.gz.sig CHANGED
@@ -1 +1 @@
1
- ,��JH�?:~=\tU] ��R0�\ $ӡ^����P����s��L�bg �\��ٖ����S�i��{��!j��w?-Oe"QTsǍdtMT��U3L1�`�H����/bl�C�Ӣ�����5U�%ym��z|~��68i��w��C2�A���[��t�Z�������M�ؾ�%���dr�m �ۥ�ĿH�
1
+ RhGok'Y����%�{V4$aa��81�[�
@@ -6,7 +6,7 @@ module CoinOp::Bit
6
6
  include CoinOp::Encodings
7
7
 
8
8
  attr_reader :native, :output, :binary_sig_hash,
9
- :signatures, :sig_hash, :script_sig, :index
9
+ :signatures, :sig_hash, :script_sig, :index, :sequence
10
10
 
11
11
  # Takes a Hash containing these fields:
12
12
  #
@@ -16,6 +16,8 @@ module CoinOp::Bit
16
16
  #
17
17
  # Optionally:
18
18
  #
19
+ # * :sequence - an integer used to modify the behavior of lock_time
20
+ # defaults to 0xFFFFFFFF (lock_time disabled)
19
21
  # * script_sig_asm - the string form of the scriptSig for this input
20
22
  #
21
23
  def initialize(options={})
@@ -23,7 +25,6 @@ module CoinOp::Bit
23
25
  options.values_at :transaction, :index, :output, :network
24
26
 
25
27
  script_sig_asm = options[:script_sig_asm]
26
-
27
28
  unless @output.is_a? Output
28
29
  @output = Output.new(@output, network: @network)
29
30
  end
@@ -36,6 +37,11 @@ module CoinOp::Bit
36
37
  @native.prev_out = decode_hex(@output.transaction_hash).reverse
37
38
  @native.prev_out_index = @output.index
38
39
 
40
+ if options[:sequence]
41
+ @sequence = options[:sequence].to_i
42
+ @native.sequence = int_to_byte_array(@sequence, endianness: :little)
43
+ end
44
+
39
45
  if script_sig_asm
40
46
  self.script_sig = Bitcoin::Script.binary_from_string(script_sig_asm)
41
47
  end
@@ -63,10 +69,10 @@ module CoinOp::Bit
63
69
 
64
70
  def to_json(*a)
65
71
  {
66
- :output => self.output,
67
- :signatures => self.signatures.map {|b| hex(b) },
68
- :sig_hash => self.sig_hash || "",
69
- :script_sig => self.script_sig || ""
72
+ output: self.output,
73
+ signatures: self.signatures.map {|b| hex(b) },
74
+ sig_hash: self.sig_hash || "",
75
+ script_sig: self.script_sig || ""
70
76
  }.to_json(*a)
71
77
  end
72
78
 
@@ -80,16 +86,16 @@ module CoinOp::Bit
80
86
 
81
87
  def initialize(binary_hash, index)
82
88
  @output = {
83
- # the binary hash is the result of
89
+ # the binary hash is the result of
84
90
  # [tx.hash].pack("H*").reverse
85
- :transaction_hash => hex(binary_hash.reverse),
86
- :index => index,
91
+ transaction_hash: hex(binary_hash.reverse),
92
+ index: index
87
93
  }
88
94
  end
89
95
 
90
96
  def to_json(*a)
91
97
  {
92
- :output => @output,
98
+ output: @output
93
99
  }.to_json(*a)
94
100
  end
95
101
 
@@ -98,5 +104,3 @@ module CoinOp::Bit
98
104
 
99
105
 
100
106
  end
101
-
102
-
@@ -17,9 +17,10 @@ module CoinOp::Bit
17
17
  data.values_at :version, :lock_time, :fee, :inputs, :outputs, :confirmations
18
18
 
19
19
  transaction = self.new(
20
- :fee => fee,
21
- :version => version, :lock_time => lock_time,
22
- :confirmations => confirmations,
20
+ fee: fee,
21
+ version: version,
22
+ lock_time: lock_time,
23
+ confirmations: confirmations,
23
24
  network: network
24
25
  )
25
26
 
@@ -93,15 +94,16 @@ module CoinOp::Bit
93
94
  end
94
95
 
95
96
 
96
- attr_reader :native, :inputs, :outputs, :confirmations
97
+ attr_reader :native, :inputs, :outputs, :confirmations, :lock_time, :version
97
98
 
98
99
  # A new Transaction contains no inputs or outputs; these can be added with
99
100
  # #add_input and #add_output.
100
- # FIXME: version and locktime options are ignored here.
101
101
  def initialize(options={})
102
102
  @native = Bitcoin::Protocol::Tx.new
103
103
  @inputs = []
104
104
  @outputs = []
105
+ @lock_time = @native.lock_time = (options[:lock_time] || 0)
106
+ @version = @native.ver = (options[:version] || 1)
105
107
  @network = options[:network]
106
108
  @fee_override = options[:fee]
107
109
  @confirmations = options[:confirmations]
@@ -224,13 +226,13 @@ module CoinOp::Bit
224
226
  # Typically used only by #to_json.
225
227
  def to_hash
226
228
  {
227
- :confirmations => self.confirmations.nil? ? 0 : self.confirmations,
228
- :version => self.version,
229
- :lock_time => self.lock_time,
230
- :hash => self.hex_hash,
231
- :fee => self.fee,
232
- :inputs => self.inputs,
233
- :outputs => self.outputs
229
+ confirmations: self.confirmations.nil? ? 0 : self.confirmations,
230
+ version: self.version,
231
+ lock_time: self.lock_time,
232
+ hash: self.hex_hash,
233
+ fee: self.fee,
234
+ inputs: self.inputs,
235
+ outputs: self.outputs
234
236
  }
235
237
  end
236
238
 
@@ -361,13 +363,12 @@ module CoinOp::Bit
361
363
  # Takes a bitcoin address and optional metadata Hash.
362
364
  def add_change(address, metadata={})
363
365
  add_output(
364
- :value => change_value,
365
- :address => address,
366
- :metadata => {:memo => "change"}.merge(metadata)
366
+ value: change_value,
367
+ address: address,
368
+ metadata: {memo: "change"}.merge(metadata)
367
369
  )
368
370
  end
369
371
 
370
372
  end
371
373
 
372
374
  end
373
-
@@ -22,7 +22,14 @@ module CoinOp
22
22
  self.decode_hex(::Bitcoin.decode_base58(string))
23
23
  end
24
24
 
25
+ def int_to_byte_array(i, endianness: :little)
26
+ arr = i.to_s(16).scan(/../).map { |x| x.hex.chr }
27
+ if endianness = :little
28
+ arr.reverse.join
29
+ else
30
+ arr.join
31
+ end
32
+ end
25
33
  end
26
34
 
27
35
  end
28
-
@@ -1,3 +1,3 @@
1
1
  module CoinOp
2
- VERSION = "0.4.4"
2
+ VERSION = "0.4.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coin-op
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.4
4
+ version: 0.4.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew King
@@ -32,7 +32,7 @@ cert_chain:
32
32
  tdc4VS7IlSRxlZ3dBOgiigy9GXpJ+7F831AqjxL39EPwdr7RguTNz+pi//RKaT/U
33
33
  IlpVB+Xfk0vQdP7iYfjGxDzUf0FACMjsR95waJmadKW1Iy6STw2hwPhYIQz1Hu1A
34
34
  -----END CERTIFICATE-----
35
- date: 2015-07-22 00:00:00.000000000 Z
35
+ date: 2015-08-07 00:00:00.000000000 Z
36
36
  dependencies:
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: bitcoin-ruby
@@ -197,3 +197,4 @@ signing_key:
197
197
  specification_version: 4
198
198
  summary: Crypto currency classes in Ruby
199
199
  test_files: []
200
+ has_rdoc:
metadata.gz.sig CHANGED
Binary file