diff --git a/server/app/com/xsn/explorer/models/persisted/Transaction.scala b/server/app/com/xsn/explorer/models/persisted/Transaction.scala index 514c125..a4a1ff3 100644 --- a/server/app/com/xsn/explorer/models/persisted/Transaction.scala +++ b/server/app/com/xsn/explorer/models/persisted/Transaction.scala @@ -89,7 +89,7 @@ object Transaction { val outputs = tx.vout.flatMap { vout => for { - addresses <- vout.addresses + addresses <- vout.addresses if vout.value > 0 script <- vout.scriptPubKey.map(_.hex) } yield Output( tx.id, diff --git a/server/test/com/xsn/explorer/models/persisted/TransactionSpec.scala b/server/test/com/xsn/explorer/models/persisted/TransactionSpec.scala index e18adbc..7ffe58f 100644 --- a/server/test/com/xsn/explorer/models/persisted/TransactionSpec.scala +++ b/server/test/com/xsn/explorer/models/persisted/TransactionSpec.scala @@ -63,6 +63,35 @@ class TransactionSpec extends WordSpec { result.outputs must be(List(expected)) } + "discard outputs with 0 value" in { + val address = DataGenerator.randomAddress + val hex = HexString.from("00").get + val script = ScriptPubKey( + "nulldata", + "", + hex, + List(address)) + + val vout = List( + rpc.TransactionVOUT(0, 1, Some(script)), + rpc.TransactionVOUT(10, 2, Some(script)), + ) + + val tx = rpc.Transaction[rpc.TransactionVIN.HasValues]( + id = DataGenerator.randomTransactionId, + size = Size(200), + blockhash = DataGenerator.randomBlockhash, + time = 10L, + blocktime = 10L, + confirmations = Confirmations(10), + vin = List.empty, + vout = vout) + + val expected = Transaction.Output(tx.id, 2, 10, address, hex) + val (result, _) = persisted.Transaction.fromRPC(tx) + result.outputs must be(List(expected)) + } + "extract the possible TPoS contracts" in { val address = DataGenerator.randomAddress val addressHex = DatatypeConverter.printHexBinary(address.string.getBytes)