Skip to content

Commit

Permalink
fix: dao withdraw tx fee bug
Browse files Browse the repository at this point in the history
  • Loading branch information
shaojunda committed Aug 16, 2019
1 parent d727d22 commit 8c94b6e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/utils/ckb_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,11 @@ def self.normal_tx_fee(ckb_transaction)

def self.dao_withdraw_tx_fee(ckb_transaction)
dao_cells = ckb_transaction.inputs.dao
dao_reward = dao_cells.reduce(0) { |memo, dao_cell| memo + CkbSync::Api.instance.calculate_dao_maximum_withdraw(dao_cell).to_i }
dao_reward =
dao_cells.reduce(0) do |memo, dao_cell|
out_point = CKB::Types::OutPoint.new(cell: CKB::Types::CellOutPoint.new(tx_hash: dao_cell.tx_hash, index: dao_cell.cell_index))
memo + CkbSync::Api.instance.calculate_dao_maximum_withdraw(out_point, dao_cell.block.block_hash).to_i
end
ckb_transaction.inputs.sum(:capacity) + dao_reward - ckb_transaction.outputs.sum(:capacity)
end
end

0 comments on commit 8c94b6e

Please sign in to comment.