Class: ArkEcosystem::Crypto::Deserialisers::MultiPayment
- Defined in:
- lib/arkecosystem/crypto/deserialisers/multi_payment.rb
Overview
The deserialiser for multi payment transactions.
Instance Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from ArkEcosystem::Crypto::Deserialisers::Base
Instance Method Details
#deserialise ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/arkecosystem/crypto/deserialisers/multi_payment.rb', line 6 def deserialise @transaction[:asset] = { amount: 0, payments: [] } total = @binary.unpack("C#{@asset_offset / 2}Q<").last & 0xff offset = @asset_offset / 2 + 1 i = 0 while i < total recipient_id = @binary.unpack("H#{(offset + 1) * 2}H42").last payment = { amount: @binary.unpack("C#{@asset_offset / 2}Q<").last, recipient_id: BTC::Base58.base58check_from_data([recipient_id].pack('H*')) } @transaction[:asset][:payments].push(payment) offset += 22 i += 1 end products.each { |item| @transaction[:amount] += item[:amount] } ArkEcosystem::Crypto::Crypto.parse_signatures(@serialised, @transaction, offset * 2) end |