class OpenAssets::Protocol::AssetDefinitionLoader
Attributes
loader[R]
Public Class Methods
create_pointer_p2sh(url, to)
click to toggle source
create ps2s script which specify asset definition pointer @param url The asset definition url. @param to The open asset address to send the asset to. @return p2sh script.
# File lib/openassets/protocol/asset_definition_loader.rb, line 39 def self.create_pointer_p2sh(url, to) redeem_script = create_pointer_redeem_script(url, to) redeem_script.to_p2sh end
create_pointer_redeem_script(url, to)
click to toggle source
create redeem script of asset definition file using p2sh @param url The asset definition url. @param to The open asset address to send the asset to. @return redeem script.
# File lib/openassets/protocol/asset_definition_loader.rb, line 26 def self.create_pointer_redeem_script(url, to) asset_def = "u=#{url}".bytes.map{|b|b.to_s(16)}.join btc_addr = oa_address_to_address(to) script = Bitcoin::Script.from_string("#{asset_def}") script << Bitcoin::Script::OP_DROP script.chunks = script.chunks + Bitcoin::Script.parse_from_addr(btc_addr).chunks script end
new(url)
click to toggle source
# File lib/openassets/protocol/asset_definition_loader.rb, line 10 def initialize(url) if url.start_with?('http://') || url.start_with?('https://') @loader = HttpAssetDefinitionLoader.new(url) end end
Public Instance Methods
load_definition()
click to toggle source
load Asset Definition File @return loaded asset definition object
# File lib/openassets/protocol/asset_definition_loader.rb, line 18 def load_definition @loader.load if @loader end