-
Notifications
You must be signed in to change notification settings - Fork 420
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1064 from wavesplatform/node-496-proof-based-crea…
…te-alias-tx Node 496 proof based create alias tx
- Loading branch information
Showing
27 changed files
with
345 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 0 additions & 16 deletions
16
src/main/scala/scorex/api/http/alias/CreateAliasRequest.scala
This file was deleted.
Oops, something went wrong.
16 changes: 16 additions & 0 deletions
16
src/main/scala/scorex/api/http/alias/CreateAliasV1Request.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package scorex.api.http.alias | ||
|
||
import io.swagger.annotations.ApiModelProperty | ||
import play.api.libs.json.{Format, Json} | ||
|
||
case class CreateAliasV1Request(@ApiModelProperty(value = "Base58 encoded sender public key", required = true) | ||
sender: String, | ||
@ApiModelProperty(value = "Alias", required = true) | ||
alias: String, | ||
@ApiModelProperty(required = true) | ||
fee: Long, | ||
timestamp: Option[Long] = None) | ||
|
||
object CreateAliasV1Request { | ||
implicit val aliasV1RequestFormat: Format[CreateAliasV1Request] = Json.format | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/scala/scorex/api/http/alias/CreateAliasV2Request.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package scorex.api.http.alias | ||
|
||
import io.swagger.annotations.ApiModelProperty | ||
import play.api.libs.json.{Format, Json} | ||
|
||
case class CreateAliasV2Request(@ApiModelProperty(required = true) | ||
version: Byte, | ||
@ApiModelProperty(value = "Base58 encoded sender public key", required = true) | ||
sender: String, | ||
@ApiModelProperty(value = "Alias", required = true) | ||
alias: String, | ||
@ApiModelProperty(required = true) | ||
fee: Long, | ||
timestamp: Option[Long] = None) | ||
|
||
object CreateAliasV2Request { | ||
implicit val aliasV2RequestFormat: Format[CreateAliasV2Request] = Json.format | ||
} |
32 changes: 0 additions & 32 deletions
32
src/main/scala/scorex/api/http/alias/SignedCreateAliasRequest.scala
This file was deleted.
Oops, something went wrong.
32 changes: 32 additions & 0 deletions
32
src/main/scala/scorex/api/http/alias/SignedCreateAliasV1Request.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package scorex.api.http.alias | ||
|
||
import io.swagger.annotations.ApiModelProperty | ||
import play.api.libs.json.{Format, Json} | ||
import scorex.account.{Alias, PublicKeyAccount} | ||
import scorex.api.http.BroadcastRequest | ||
import scorex.transaction.TransactionParsers.SignatureStringLength | ||
import scorex.transaction.{CreateAliasTransactionV1, ValidationError} | ||
|
||
case class SignedCreateAliasV1Request(@ApiModelProperty(value = "Base58 encoded sender public key", required = true) | ||
senderPublicKey: String, | ||
@ApiModelProperty(required = true) | ||
fee: Long, | ||
@ApiModelProperty(value = "Alias", required = true) | ||
alias: String, | ||
@ApiModelProperty(required = true) | ||
timestamp: Long, | ||
@ApiModelProperty(required = true) | ||
signature: String) | ||
extends BroadcastRequest { | ||
def toTx: Either[ValidationError, CreateAliasTransactionV1] = | ||
for { | ||
_sender <- PublicKeyAccount.fromBase58String(senderPublicKey) | ||
_signature <- parseBase58(signature, "invalid.signature", SignatureStringLength) | ||
_alias <- Alias.buildWithCurrentNetworkByte(alias) | ||
_t <- CreateAliasTransactionV1.create(_sender, _alias, fee, timestamp, _signature) | ||
} yield _t | ||
} | ||
|
||
object SignedCreateAliasV1Request { | ||
implicit val broadcastAliasV1RequestReadsFormat: Format[SignedCreateAliasV1Request] = Json.format | ||
} |
35 changes: 35 additions & 0 deletions
35
src/main/scala/scorex/api/http/alias/SignedCreateAliasV2Request.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package scorex.api.http.alias | ||
|
||
import io.swagger.annotations.ApiModelProperty | ||
import play.api.libs.json.{Format, Json} | ||
import scorex.account.{Alias, PublicKeyAccount} | ||
import scorex.api.http.BroadcastRequest | ||
import scorex.transaction.{CreateAliasTransaction, CreateAliasTransactionV2, Proofs, ValidationError} | ||
import cats.implicits._ | ||
|
||
case class SignedCreateAliasV2Request(@ApiModelProperty(required = true) | ||
version: Byte, | ||
@ApiModelProperty(value = "Base58 encoded sender public key", required = true) | ||
senderPublicKey: String, | ||
@ApiModelProperty(required = true) | ||
fee: Long, | ||
@ApiModelProperty(value = "Alias", required = true) | ||
alias: String, | ||
@ApiModelProperty(required = true) | ||
timestamp: Long, | ||
@ApiModelProperty(required = true) | ||
proofs: List[String]) | ||
extends BroadcastRequest { | ||
def toTx: Either[ValidationError, CreateAliasTransaction] = | ||
for { | ||
_sender <- PublicKeyAccount.fromBase58String(senderPublicKey) | ||
_proofBytes <- proofs.traverse(s => parseBase58(s, "invalid proof", Proofs.MaxProofStringSize)) | ||
_proofs <- Proofs.create(_proofBytes) | ||
_alias <- Alias.buildWithCurrentNetworkByte(alias) | ||
_t <- CreateAliasTransactionV2.create(version, _sender, _alias, fee, timestamp, _proofs) | ||
} yield _t | ||
} | ||
|
||
object SignedCreateAliasV2Request { | ||
implicit val broadcastAliasV2RequestReadsFormat: Format[SignedCreateAliasV2Request] = Json.format | ||
} |
Oops, something went wrong.