Class: Nis::Apostille

Inherits:
Object
  • Object
show all
Defined in:
lib/nis/apostille.rb

Constant Summary collapse

CHECKSUM =
'fe4e5459'.freeze

Instance Method Summary collapse

Constructor Details

#initialize(keypair, file, hashing = :sha256, multisig: false, private: false, network: :testnet) ⇒ Apostille

Returns a new instance of Apostille.

Parameters:

  • keypair (Nis::Keypair)
  • file (string)
    • The file

  • hashing (symbol) (defaults to: :sha256)
    • An hashing type (md5, sha1, sha256, sha3-256, sha3-512)

  • multisig (boolean) (defaults to: false)
    • true if transaction is multisig, false otherwise

  • private (boolean) (defaults to: false)
    • true if apostille is private / transferable / updateable, false if public



14
15
16
17
18
19
20
21
# File 'lib/nis/apostille.rb', line 14

def initialize(keypair, file, hashing = :sha256, multisig: false, private: false, network: :testnet)
  @keypair = keypair
  @file = file
  @hashing = hashing
  @multisig = multisig
  @private = private
  @network = network
end

Instance Method Details

#apostille_format(transaction_hash) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
# File 'lib/nis/apostille.rb', line 42

def apostille_format(transaction_hash)
  ext = File.extname(@file.path)
  name = File.basename(@file.path, ext)
  date = Date.today.strftime('%Y-%m-%d')
  '%s -- Apostille TX %s -- Date %s%s' % [
    name,
    transaction_hash,
    date,
    ext
  ]
end

#multisig?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/nis/apostille.rb', line 27

def multisig?
  @multisig
end

#private?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/nis/apostille.rb', line 23

def private?
  @private
end

#transactionObject



31
32
33
34
35
36
37
38
39
40
# File 'lib/nis/apostille.rb', line 31

def transaction
  if private?
    raise 'Not implemented private apostille.'
  else
    dedicated_address = apostille[:sink]
    apostille_hash = calc_hash
  end

  Nis::Transaction::Transfer.new(dedicated_address, 0, apostille_hash)
end