Class: Sibit::Tx::Input

Inherits:
Object
  • Object
show all
Defined in:
lib/sibit/tx.rb

Overview

Transaction input.

Author

Yegor Bugayenko (yegor256@gmail.com)

Copyright

Copyright (c) 2019-2026 Yegor Bugayenko

License

MIT

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash, index, script, key, value) ⇒ Input

Returns a new instance of Input.



75
76
77
78
79
80
81
82
83
# File 'lib/sibit/tx.rb', line 75

def initialize(hash, index, script, key, value)
  @hash = hash
  @index = index
  @prev_script = script
  @key = key
  @value = value
  @script_sig = ''
  @witness = []
end

Instance Attribute Details

#hashObject (readonly)

Returns the value of attribute hash.



72
73
74
# File 'lib/sibit/tx.rb', line 72

def hash
  @hash
end

#indexObject (readonly)

Returns the value of attribute index.



72
73
74
# File 'lib/sibit/tx.rb', line 72

def index
  @index
end

#keyObject (readonly)

Returns the value of attribute key.



72
73
74
# File 'lib/sibit/tx.rb', line 72

def key
  @key
end

#prev_scriptObject (readonly)

Returns the value of attribute prev_script.



72
73
74
# File 'lib/sibit/tx.rb', line 72

def prev_script
  @prev_script
end

#script_sigObject

Returns the value of attribute script_sig.



73
74
75
# File 'lib/sibit/tx.rb', line 73

def script_sig
  @script_sig
end

#valueObject (readonly)

Returns the value of attribute value.



72
73
74
# File 'lib/sibit/tx.rb', line 72

def value
  @value
end

#witnessObject

Returns the value of attribute witness.



73
74
75
# File 'lib/sibit/tx.rb', line 73

def witness
  @witness
end

Instance Method Details

#prev_outObject



85
86
87
# File 'lib/sibit/tx.rb', line 85

def prev_out
  [@hash].pack('H*')
end

#prev_out_indexObject



89
90
91
# File 'lib/sibit/tx.rb', line 89

def prev_out_index
  @index
end

#segwit?Boolean

Returns:

  • (Boolean)


93
94
95
96
# File 'lib/sibit/tx.rb', line 93

def segwit?
  bytes = [@prev_script].pack('H*').bytes
  bytes.length == 22 && bytes[0].zero? && bytes[1] == 20
end