Skip to content

Commit

Permalink
Merge pull request #860 from ergoplatform/v3.0.6
Browse files Browse the repository at this point in the history
V3.0.6
  • Loading branch information
kushti authored Aug 6, 2019
2 parents a0c881c + 33a3dcb commit cdf4e3b
Show file tree
Hide file tree
Showing 29 changed files with 368 additions and 322 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: scala
# Use container-based infrastructure
sudo: false
sudo: required
branches:
only:
- v2.1
Expand All @@ -9,7 +9,7 @@ branches:
- v2.2-candidate
- sigma454-type-check-on-script-deser
jdk:
- oraclejdk9
- openjdk9
scala:
- 2.12.8
script:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ To run specific Ergo version `<VERSION>` as a service with custom config `/path/
-v /path/on/host/system/to/myergo.conf:/etc/myergo.conf \
ergoplatform/ergo:<VERSION> --<networkId> -c /etc/myergo.conf

Available versions can be found on [Ergo Docker image page](https://hub.docker.com/r/ergoplatform/ergo/tags), for example, `v2.2.0`.
Available versions can be found on [Ergo Docker image page](https://hub.docker.com/r/ergoplatform/ergo/tags), for example, `v3.0.5`.

This will connect to Ergo mainnet or testnet respecting your configuration passed in `myergo.conf` and network flag `--<networkId>`. Every default config value would be overwritten with corresponding value in `myergo.conf`.

Expand Down
4 changes: 2 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import sbt._
lazy val commonSettings = Seq(
organization := "org.ergoplatform",
name := "ergo",
version := "3.0.5",
version := "3.0.6",
scalaVersion := "2.12.8",
resolvers ++= Seq("Sonatype Releases" at "https://oss.sonatype.org/content/repositories/releases/",
"SonaType" at "https://oss.sonatype.org/content/groups/public",
Expand All @@ -14,7 +14,7 @@ lazy val commonSettings = Seq(
licenses := Seq("CC0" -> url("https://creativecommons.org/publicdomain/zero/1.0/legalcode"))
)

val scorexVersion = "6ffeafc8-SNAPSHOT"
val scorexVersion = "3696cb2b-SNAPSHOT"
val sigmaStateVersion = "master-bd486374-SNAPSHOT"
val ergoWalletVersion = "master-d4cf1f7f-SNAPSHOT"

Expand Down
4 changes: 2 additions & 2 deletions lock.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ dependencyOverrides in ThisBuild ++= Seq(
"org.scodec" % "scodec-bits_2.12" % "1.1.6",
"org.scorexfoundation" % "avl-iodb_2.12" % "0.2.15",
"org.scorexfoundation" % "iodb_2.12" % "0.3.2",
"org.scorexfoundation" % "scorex-core_2.12" % "6ffeafc8-SNAPSHOT",
"org.scorexfoundation" % "scorex-core_2.12" % "3696cb2b-SNAPSHOT",
"org.scorexfoundation" % "scorex-util_2.12" % "0.1.4",
"org.scorexfoundation" % "scrypto_2.12" % "2.1.6",
"org.scorexfoundation" % "sigma-api_2.12" % "master-bd486374-SNAPSHOT",
Expand All @@ -87,4 +87,4 @@ dependencyOverrides in ThisBuild ++= Seq(
"org.typelevel" % "spire_2.12" % "0.14.1",
"org.whispersystems" % "curve25519-java" % "0.5.0"
)
// LIBRARY_DEPENDENCIES_HASH 7eb39cd1eb0d27b8c9660e7bf052985508f44d79
// LIBRARY_DEPENDENCIES_HASH b2e823bd88511546c94de8f006cfb7653dde4e01
137 changes: 19 additions & 118 deletions src/main/resources/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,6 @@ components:
type: object
required:
- requests
- fee
properties:
requests:
description: Sequence of transaction requests
Expand All @@ -268,6 +267,11 @@ components:
type: integer
format: int64
example: 1000000
inputsRaw:
description: List of inputs to be used in serialized form
type: array
items:
$ref: '#/components/schemas/SerializedBox'

SourceHolder:
type: object
Expand Down Expand Up @@ -299,11 +303,6 @@ components:
$ref: '#/components/schemas/Asset'
registers:
$ref: '#/components/schemas/Registers'
fee:
description: Optional, default transaction fee from settings will be used if not defined
type: integer
format: int64
example: 1000000

AssetIssueRequest:
description: Request for generation of asset issue transaction
Expand Down Expand Up @@ -2171,11 +2170,20 @@ paths:
post:
security:
- ApiKeyAuth: [api_key]
summary: Generate arbitrary transaction
summary: Generate arbitrary transaction from array of requests.
operationId: walletTransactionGenerate
tags:
- wallet
requestBody:
description: This API method receives a sequence of requests as an input. Each request will produce an output
of the resulting transaction (with fee output created automatically). Currently supported types of requests are
payment and asset issuance requests. An example for a transaction with requests of both kinds is provided below.
Please note that for the payment request "assets" and "registers" fields are not needed.
For asset issuance request, "registers" field is not needed.

You may specify boxes to spend by providing them in "inputsRaw". Please note you need to have strict equality between
input and output total amounts of Ergs in this case. If you want wallet to pick up the boxes,
leave "inputsRaw" empty.
required: true
content:
application/json:
Expand Down Expand Up @@ -2210,6 +2218,7 @@ paths:
tags:
- wallet
requestBody:
description: See description of /wallet/transaction/generate
required: true
content:
application/json:
Expand All @@ -2235,50 +2244,14 @@ paths:
schema:
$ref: '#/components/schemas/ApiError'

/wallet/payment/generate:
post:
security:
- ApiKeyAuth: [api_key]
summary: Generate payment transaction
operationId: walletPaymentTransactionGenerate
tags:
- wallet
requestBody:
required: true
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/PaymentRequest'
responses:
'200':
description: Generated Ergo transaction
content:
application/json:
schema:
$ref: '#/components/schemas/ErgoTransaction'
'400':
description: Bad payment request
content:
application/json:
schema:
$ref: '#/components/schemas/ApiError'
default:
description: Error
content:
application/json:
schema:
$ref: '#/components/schemas/ApiError'

/wallet/payment/send:
post:
security:
- ApiKeyAuth: [api_key]
summary: Generate and send payment transaction
- ApiKeyAuth: [api_key]
summary: Generate and send payment transaction (default fee of 0.001 Erg is used)
operationId: walletPaymentTransactionGenerateAndSend
tags:
- wallet
- wallet
requestBody:
required: true
content:
Expand Down Expand Up @@ -2307,78 +2280,6 @@ paths:
schema:
$ref: '#/components/schemas/ApiError'

/wallet/assets/generate:
post:
security:
- ApiKeyAuth: [api_key]
summary: Generate asset issue transaction
operationId: walletAssetIssueTransactionGenerate
tags:
- wallet
requestBody:
required: true
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/AssetIssueRequest'
responses:
'200':
description: Generated Ergo transaction
content:
application/json:
schema:
$ref: '#/components/schemas/ErgoTransaction'
'400':
description: Bad asset issue request
content:
application/json:
schema:
$ref: '#/components/schemas/ApiError'
default:
description: Error
content:
application/json:
schema:
$ref: '#/components/schemas/ApiError'

/wallet/assets/issue:
post:
security:
- ApiKeyAuth: [api_key]
summary: Generate and send asset issue transaction
operationId: walletAssetIssueTransactionGenerateAndSend
tags:
- wallet
requestBody:
required: true
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/AssetIssueRequest'
responses:
'200':
description: Identifier of an Ergo transaction generated
content:
application/json:
schema:
$ref: '#/components/schemas/TransactionId'
'400':
description: Bad asset issue request
content:
application/json:
schema:
$ref: '#/components/schemas/ApiError'
default:
description: Error
content:
application/json:
schema:
$ref: '#/components/schemas/ApiError'

/mining/candidate:
get:
security:
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/reference.conf
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ ergo {
# Is the node is doing mining
mining = false

# Node will only include transactions to own blocks with lower complexity
maxTransactionComplexity = 100000

# Use external miner, native miner is used if set to `false`
useExternalMiner = true

Expand Down
50 changes: 12 additions & 38 deletions src/main/scala/org/ergoplatform/api/WalletApiRoute.scala
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,8 @@ case class WalletApiRoute(readersHolder: ActorRef, nodeViewActorRef: ActorRef, e
unspentBoxesR ~
boxesR ~
generateTransactionR ~
generatePaymentTransactionR ~
generateAssetIssueTransactionR ~
sendTransactionR ~
sendPaymentTransactionR ~
sendAssetIssueTransactionR ~
sendTransactionR ~
p2shAddressR ~
p2sAddressR ~
initWalletR ~
Expand All @@ -68,13 +65,6 @@ case class WalletApiRoute(readersHolder: ActorRef, nodeViewActorRef: ActorRef, e

private val loadMaxKeys: Int = 100

private val fee: Directive1[Option[Long]] = entity(as[Json]).flatMap { p =>
Try(p.hcursor.downField("fee").as[Long]) match {
case Success(Right(value)) => provide(Some(value))
case _ => provide(None)
}
}

private val source: Directive1[String] = entity(as[Json]).flatMap { p =>
p.hcursor.downField("source").as[String]
.fold(_ => reject, s => provide(s))
Expand Down Expand Up @@ -153,9 +143,9 @@ case class WalletApiRoute(readersHolder: ActorRef, nodeViewActorRef: ActorRef, e
}
}

private def withFee(requests: Seq[TransactionRequest], feeOpt: Option[Long]): Seq[TransactionRequest] = {
private def withFee(requests: Seq[TransactionRequest]): Seq[TransactionRequest] = {
requests :+ PaymentRequest(Pay2SAddress(ergoSettings.chainSettings.monetary.feeProposition),
feeOpt.getOrElse(ergoSettings.walletSettings.defaultTransactionFee), None, None)
ergoSettings.walletSettings.defaultTransactionFee, Seq.empty, Map.empty)
}

private def withWalletOp[T](op: ErgoWalletReader => Future[T])(toRoute: T => Route): Route = {
Expand All @@ -166,15 +156,15 @@ case class WalletApiRoute(readersHolder: ActorRef, nodeViewActorRef: ActorRef, e
withWalletOp(op)(ApiResponse.apply[T])
}

private def generateTransaction(requests: Seq[TransactionRequest]): Route = {
withWalletOp(_.generateTransaction(requests)) {
private def generateTransaction(requests: Seq[TransactionRequest], inputsRaw: Seq[String]): Route = {
withWalletOp(_.generateTransaction(requests, inputsRaw)) {
case Failure(e) => BadRequest(s"Bad request $requests. ${Option(e.getMessage).getOrElse(e.toString)}")
case Success(tx) => ApiResponse(tx)
}
}

private def sendTransaction(requests: Seq[TransactionRequest]): Route = {
withWalletOp(_.generateTransaction(requests)) {
private def sendTransaction(requests: Seq[TransactionRequest], inputsRaw: Seq[String]): Route = {
withWalletOp(_.generateTransaction(requests, inputsRaw)) {
case Failure(e) => BadRequest(s"Bad request $requests. ${Option(e.getMessage).getOrElse(e.toString)}")
case Success(tx) =>
nodeViewActorRef ! LocallyGeneratedTransaction[ErgoTransaction](tx)
Expand All @@ -183,31 +173,15 @@ case class WalletApiRoute(readersHolder: ActorRef, nodeViewActorRef: ActorRef, e
}

def sendTransactionR: Route = (path("transaction" / "send") & post
& entity(as[RequestsHolder]))(holder => sendTransaction(holder.requestsWithFee))
& entity(as[RequestsHolder]))(holder => sendTransaction(holder.withFee, holder.inputsRaw))

def generateTransactionR: Route = (path("transaction" / "generate") & post
& entity(as[RequestsHolder]))(holder => generateTransaction(holder.requestsWithFee))

def generatePaymentTransactionR: Route = (path( "payment" / "generate") & post
& entity(as[Seq[PaymentRequest]]) & fee) { (requests, feeOpt) =>
generateTransaction(withFee(requests, feeOpt))
}
& entity(as[RequestsHolder]))(holder => generateTransaction(holder.withFee, holder.inputsRaw))

def sendPaymentTransactionR: Route = (path("payment" / "send") & post
& entity(as[Seq[PaymentRequest]]) & fee) { (requests, feeOpt) =>
sendTransaction(withFee(requests, feeOpt))
}

def generateAssetIssueTransactionR: Route = (path("assets" / "generate") & post
& entity(as[Seq[AssetIssueRequest]]) & fee) { (requests, feeOpt) =>
generateTransaction(withFee(requests, feeOpt))
}

def sendAssetIssueTransactionR: Route = (path("assets" / "issue") & post
& entity(as[Seq[AssetIssueRequest]]) & fee) { (requests, feeOpt) =>
sendTransaction(withFee(requests, feeOpt))
}

& entity(as[Seq[PaymentRequest]])) { requests =>
sendTransaction(withFee(requests), Seq.empty)
}
def balancesR: Route = (path("balances") & get) {
withWallet(_.confirmedBalances)
}
Expand Down
Loading

0 comments on commit cdf4e3b

Please sign in to comment.