Class: Nem::Apostille
- Inherits:
-
Object
- Object
- Nem::Apostille
- Defined in:
- lib/nem/apostille.rb
Constant Summary collapse
- CHECKSUM =
'fe4e5459'.freeze
Instance Attribute Summary collapse
-
#dedicated_keypair ⇒ Object
readonly
Returns the value of attribute dedicated_keypair.
Instance Method Summary collapse
- #apostille_format(transaction_hash) ⇒ Object
-
#initialize(keypair, file, hashing = :sha256, multisig: false, signed: false, network: nil) ⇒ Apostille
constructor
A new instance of Apostille.
- #multisig? ⇒ Boolean
- #signed? ⇒ Boolean
- #transaction ⇒ Object
Constructor Details
#initialize(keypair, file, hashing = :sha256, multisig: false, signed: false, network: nil) ⇒ Apostille
Returns a new instance of Apostille.
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/nem/apostille.rb', line 16 def initialize(keypair, file, hashing = :sha256, multisig: false, signed: false, network: nil) @keypair = keypair @file = file @hashing = hashing @multisig = multisig @signed = signed @network = network || Nem.default_network # TDOD: support multisig apostille raise NotImplementedError, 'Sorry, Not yet multisig apostille' if multisig? end |
Instance Attribute Details
#dedicated_keypair ⇒ Object (readonly)
Returns the value of attribute dedicated_keypair.
9 10 11 |
# File 'lib/nem/apostille.rb', line 9 def dedicated_keypair @dedicated_keypair end |
Instance Method Details
#apostille_format(transaction_hash) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/nem/apostille.rb', line 50 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
32 33 34 |
# File 'lib/nem/apostille.rb', line 32 def multisig? @multisig end |
#signed? ⇒ Boolean
28 29 30 |
# File 'lib/nem/apostille.rb', line 28 def signed? @signed end |
#transaction ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/nem/apostille.rb', line 36 def transaction if signed? @dedicated_keypair = generate_keypair apostille_hash = header << @keypair.sign(calc_hash) dedicated_address = Nem::Unit::Address.from_public_key(@dedicated_keypair.public, @network) else apostille_hash = header << calc_hash dedicated_address = apostille[:sink] end # TDOD: support multisig apostille Nem::Transaction::Transfer.new(dedicated_address, 0, apostille_hash) end |