Class: BTC::Asset
- Inherits:
-
Object
- Object
- BTC::Asset
- Defined in:
- lib/btcruby/open_assets/asset.rb
Overview
Implementation of OpenAssets protocol. https://github.com/OpenAssets/open-assets-protocol/blob/master/specification.mediawiki
Instance Attribute Summary collapse
-
#asset_id ⇒ Object
BTC::AssetID instance identifying this asset.
-
#identifier_binary ⇒ Object
Binary 160-bit identifier of the asset (same as
asset_id.hash). -
#output ⇒ Object
Returns the value of attribute output.
-
#script ⇒ Object
Optional attributes, set either by initializer when possible, or externally.
Instance Method Summary collapse
-
#initialize(asset_id: nil, script: nil, output: nil, network: nil) ⇒ Asset
constructor
Initializes assets with one of the following: * script - a BTC::Script instance.
Constructor Details
#initialize(asset_id: nil, script: nil, output: nil, network: nil) ⇒ Asset
Initializes assets with one of the following:
- script - a BTC::Script instance.
- output - a BTC::TransactionOutput instance that issues the asset.
- asset_id - a Base58 identifier of the asset or BTC::AssetID instance.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/btcruby/open_assets/asset.rb', line 20 def initialize(asset_id: nil, script: nil, output: nil, network: nil) if script || output script ||= output.script @output = output @script = script @identifier_binary = BTC::Data.hash160(script.data) @asset_id = AssetID.new(hash: @identifier_binary, network: network) elsif asset_id @asset_id = Address.parse(asset_id) @identifier_binary = @asset_id.hash else raise ArgumentError, "Either asset_id, script or output must be specified." end end |
Instance Attribute Details
#asset_id ⇒ Object
BTC::AssetID instance identifying this asset.
7 8 9 |
# File 'lib/btcruby/open_assets/asset.rb', line 7 def asset_id @asset_id end |
#identifier_binary ⇒ Object
Binary 160-bit identifier of the asset (same as asset_id.hash)
10 11 12 |
# File 'lib/btcruby/open_assets/asset.rb', line 10 def identifier_binary @identifier_binary end |
#output ⇒ Object
Returns the value of attribute output.
14 15 16 |
# File 'lib/btcruby/open_assets/asset.rb', line 14 def output @output end |
#script ⇒ Object
Optional attributes, set either by initializer when possible, or externally.
13 14 15 |
# File 'lib/btcruby/open_assets/asset.rb', line 13 def script @script end |