Class: ArkEcosystem::Crypto::Transactions::Deserializers::MultiPayment
- Defined in:
- lib/arkecosystem/crypto/transactions/deserializers/multi_payment.rb
Overview
The deserializer for multi payment transactions.
Instance Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from ArkEcosystem::Crypto::Transactions::Deserializers::Base
Instance Method Details
#deserialize ⇒ Object
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 35 |
# File 'lib/arkecosystem/crypto/transactions/deserializers/multi_payment.rb', line 7 def deserialize @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] } @transaction.parse_signatures(@serialized, offset * 2) end |