diff --git a/server/app/com/xsn/explorer/data/anorm/dao/TransactionOutputPostgresDAO.scala b/server/app/com/xsn/explorer/data/anorm/dao/TransactionOutputPostgresDAO.scala index 95616ae..9bb3526 100644 --- a/server/app/com/xsn/explorer/data/anorm/dao/TransactionOutputPostgresDAO.scala +++ b/server/app/com/xsn/explorer/data/anorm/dao/TransactionOutputPostgresDAO.scala @@ -15,7 +15,7 @@ class TransactionOutputPostgresDAO { def getUnspentOutputs(address: Address)(implicit conn: Connection): List[Transaction.Output] = { SQL( """ - |SELECT txid, index, value, address, hex_script, tpos_owner_address, tpos_merchant_address + |SELECT txid, index, value, address, hex_script |FROM transaction_outputs |WHERE address = {address} AND | spent_on IS NULL AND @@ -39,17 +39,15 @@ class TransactionOutputPostgresDAO { 'index -> output.index: NamedParameter, 'value -> output.value: NamedParameter, 'address -> output.address.string: NamedParameter, - 'hex_script -> output.script.string: NamedParameter, - 'tpos_owner_address -> output.tposOwnerAddress.map(_.string): NamedParameter, - 'tpos_merchant_address -> output.tposMerchantAddress.map(_.string): NamedParameter) + 'hex_script -> output.script.string: NamedParameter) } val batch = BatchSql( """ |INSERT INTO transaction_outputs - | (txid, index, value, address, hex_script, tpos_owner_address, tpos_merchant_address) + | (txid, index, value, address, hex_script) |VALUES - | ({txid}, {index}, {value}, {address}, {hex_script}, {tpos_owner_address}, {tpos_merchant_address}) + | ({txid}, {index}, {value}, {address}, {hex_script}) """.stripMargin, params.head, params.tail: _* @@ -69,7 +67,7 @@ class TransactionOutputPostgresDAO { """ |DELETE FROM transaction_outputs |WHERE txid = {txid} - |RETURNING txid, index, hex_script, value, address, tpos_owner_address, tpos_merchant_address + |RETURNING txid, index, hex_script, value, address """.stripMargin ).on( 'txid -> txid.string @@ -81,7 +79,7 @@ class TransactionOutputPostgresDAO { def getOutputs(txid: TransactionId)(implicit conn: Connection): List[Transaction.Output] = { SQL( """ - |SELECT txid, index, hex_script, value, address, tpos_owner_address, tpos_merchant_address + |SELECT txid, index, hex_script, value, address |FROM transaction_outputs |WHERE txid = {txid} """.stripMargin @@ -93,7 +91,7 @@ class TransactionOutputPostgresDAO { def getOutputs(txid: TransactionId, address: Address)(implicit conn: Connection): List[Transaction.Output] = { SQL( """ - |SELECT txid, index, hex_script, value, address, tpos_owner_address, tpos_merchant_address + |SELECT txid, index, hex_script, value, address |FROM transaction_outputs |WHERE txid = {txid} AND | address = {address} diff --git a/server/app/com/xsn/explorer/data/anorm/parsers/TransactionParsers.scala b/server/app/com/xsn/explorer/data/anorm/parsers/TransactionParsers.scala index 0bca7e0..eb61758 100644 --- a/server/app/com/xsn/explorer/data/anorm/parsers/TransactionParsers.scala +++ b/server/app/com/xsn/explorer/data/anorm/parsers/TransactionParsers.scala @@ -17,9 +17,6 @@ object TransactionParsers { val parseValue = get[BigDecimal]("value") val parseHexScript = parseHexString("hex_script") - val parseTposOwnerAddress = parseAddress("tpos_owner_address") - val parseTposMerchantAddress = parseAddress("tpos_merchant_address") - val parseTransaction = (parseTransactionId() ~ parseBlockhash() ~ parseTime ~ parseSize).map { case txid ~ blockhash ~ time ~ size => Transaction(txid, blockhash, time, size) } @@ -46,12 +43,10 @@ object TransactionParsers { parseIndex ~ parseValue ~ parseAddress() ~ - parseHexScript ~ - parseTposOwnerAddress.? ~ - parseTposMerchantAddress.?).map { + parseHexScript).map { - case txid ~ index ~ value ~ address ~ script ~ tposOwnerAddress ~ tposMerchantAddress => - Transaction.Output(txid, index, value, address, script, tposOwnerAddress, tposMerchantAddress) + case txid ~ index ~ value ~ address ~ script => + Transaction.Output(txid, index, value, address, script) } val parseAddressTransactionDetails = (parseAddress() ~ parseTransactionId() ~ parseSent ~ parseReceived ~ parseTime).map { diff --git a/server/app/com/xsn/explorer/models/persisted/Transaction.scala b/server/app/com/xsn/explorer/models/persisted/Transaction.scala index 55d95be..4f61b41 100644 --- a/server/app/com/xsn/explorer/models/persisted/Transaction.scala +++ b/server/app/com/xsn/explorer/models/persisted/Transaction.scala @@ -27,9 +27,7 @@ object Transaction { index: Int, value: BigDecimal, address: Address, - script: HexString, - tposOwnerAddress: Option[Address], - tposMerchantAddress: Option[Address]) + script: HexString) case class HasIO( transaction: Transaction, @@ -63,7 +61,6 @@ object Transaction { } val outputs = tx.vout.flatMap { vout => - val contract = vout.scriptPubKey.flatMap(_.getTPoSContractDetails) val scriptMaybe = vout.scriptPubKey.map(_.hex) for { address <- vout.address @@ -73,9 +70,7 @@ object Transaction { vout.n, vout.value, address, - script, - tposOwnerAddress = contract.map(_.owner), - tposMerchantAddress = contract.map(_.merchant)) + script) } val transaction = Transaction( diff --git a/server/test/com/xsn/explorer/data/TransactionPostgresDataHandlerSpec.scala b/server/test/com/xsn/explorer/data/TransactionPostgresDataHandlerSpec.scala index 8eacec7..86b1c33 100644 --- a/server/test/com/xsn/explorer/data/TransactionPostgresDataHandlerSpec.scala +++ b/server/test/com/xsn/explorer/data/TransactionPostgresDataHandlerSpec.scala @@ -80,9 +80,7 @@ class TransactionPostgresDataHandlerSpec extends PostgresDataHandlerSpec with Be txid = createTransactionId("67aa0bd8b9297ca6ee25a1e5c2e3a8dbbcc1e20eab76b6d1bdf9d69f8a5356b8"), index = 0, value = BigDecimal(76500000), - script = HexString.from("2103e8c52f2c5155771492907095753a43ce776e1fa7c5e769a67a9f3db4467ec029ac").get, - tposMerchantAddress = None, - tposOwnerAddress = None + script = HexString.from("2103e8c52f2c5155771492907095753a43ce776e1fa7c5e769a67a9f3db4467ec029ac").get ) val result = dataHandler.getUnspentOutputs(expected.address).get @@ -201,14 +199,13 @@ class TransactionPostgresDataHandlerSpec extends PostgresDataHandlerSpec with Be ) val outputs = List( - Transaction.Output(randomTransactionId, 0, BigDecimal(50), randomAddress, randomHexString(), None, None), + Transaction.Output(randomTransactionId, 0, BigDecimal(50), randomAddress, randomHexString()), Transaction.Output( randomTransactionId, 1, BigDecimal(250), randomAddress, - HexString.from("00").get, - None, None) + HexString.from("00").get) ) val transactions = List.fill(4)(randomTransactionId).zip(List(321L, 320L, 319L, 319L)).map { case (txid, time) => @@ -299,14 +296,13 @@ class TransactionPostgresDataHandlerSpec extends PostgresDataHandlerSpec with Be val newTxid = randomTransactionId val outputs = List( - Transaction.Output(newTxid, 0, BigDecimal(50), randomAddress, randomHexString(), None, None), + Transaction.Output(newTxid, 0, BigDecimal(50), randomAddress, randomHexString()), Transaction.Output( newTxid, 1, BigDecimal(250), randomAddress, - randomHexString(), - None, None) + randomHexString()) ) val transaction = Transaction.HasIO( diff --git a/server/test/com/xsn/explorer/helpers/DataGenerator.scala b/server/test/com/xsn/explorer/helpers/DataGenerator.scala index 279e399..3803ea2 100644 --- a/server/test/com/xsn/explorer/helpers/DataGenerator.scala +++ b/server/test/com/xsn/explorer/helpers/DataGenerator.scala @@ -70,8 +70,7 @@ trait DataGenerator { index = nextInt(100), value = nextInt(1000000), address = randomAddress, - script = randomHexString(8), - None, None) + script = randomHexString(8)) } def randomOutputs(n: Int = nextInt(5) + 1) : List[Transaction.Output] = { diff --git a/server/test/controllers/AddressesControllerSpec.scala b/server/test/controllers/AddressesControllerSpec.scala index b9e2e5e..d4bb4b9 100644 --- a/server/test/controllers/AddressesControllerSpec.scala +++ b/server/test/controllers/AddressesControllerSpec.scala @@ -31,18 +31,14 @@ class AddressesControllerSpec extends MyAPISpec { index = 0, value = BigDecimal("1500000000000").fromSatoshis, script = HexString.from("76a914285b6f1ccacea0059ff5393cb4eb2f0569e2b3e988ac").get, - txid = createTransactionId("ea837f2011974b6a1a2fa077dc33684932c514a4ec6febc10e1a19ebe1336539"), - tposMerchantAddress = None, - tposOwnerAddress = None + txid = createTransactionId("ea837f2011974b6a1a2fa077dc33684932c514a4ec6febc10e1a19ebe1336539") ), Transaction.Output( address = createAddress("XeNEPsgeWqNbrEGEN5vqv4wYcC3qQrqNyp"), index = 3, value = BigDecimal("2250000000").fromSatoshis, script = HexString.from("76a914285b6f1ccacea0059ff5393cb4eb2f0569e2b3e988ac").get, - txid = createTransactionId("96a06b802d1c15818a42aa9b46dd2e236cde746000d35f74d3eb940ab9d5694d"), - tposMerchantAddress = None, - tposOwnerAddress = None + txid = createTransactionId("96a06b802d1c15818a42aa9b46dd2e236cde746000d35f74d3eb940ab9d5694d") ) )