Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dpp 0.25 (WIP) #72

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import org.jlleitschuh.gradle.ktlint.reporter.ReporterType

buildscript {
ext.kotlin_version = '1.4.32'
ext.dashpay_version = '0.24-SNAPSHOT'
ext.dpp_version = '0.24-SNAPSHOT'
ext.dapi_client_version = '0.24-SNAPSHOT'
ext.dashpay_version = '0.25-SNAPSHOT'
ext.dpp_version = '0.25-SNAPSHOT'
ext.dapi_client_version = '0.25-SNAPSHOT'
ext.dashj_version = '19.1-CJ-SNAPSHOT'
repositories {
mavenCentral()
Expand Down
1 change: 1 addition & 0 deletions platform-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ dependencies {
implementation "org.dashj.platform:dpp:$dpp_version"
implementation "org.dashj.platform:dapi-client:$dapi_client_version"
implementation "org.dashj:dashj-core:$dashj_version"
implementation 'org.dashj:manual:0.25-SNAPSHOT'

implementation 'io.grpc:grpc-okhttp:1.54.0' // CURRENT_GRPC_VERSION
implementation 'io.grpc:grpc-protobuf-lite:1.54.0' // CURRENT_GRPC_VERSION
Expand Down
Binary file not shown.
Binary file added platform-core/src/main/jniLibs/libdashjbls.dylib
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ import org.bitcoinj.core.ECKey
import org.bitcoinj.core.Transaction
import org.bitcoinj.evolution.CreditFundingTransaction
import org.bitcoinj.quorums.InstantSendLock
import org.dashj.dpp.DPP
import org.dashj.platform.dapiclient.errors.NotFoundException
import org.dashj.platform.dpp.identifier.Identifier
import org.dashj.platform.dpp.identity.ChainAssetLockProof
import org.dashj.platform.dpp.identity.Identity
import org.dashj.platform.dpp.identity.IdentityPublicKey
import org.dashj.platform.dpp.identity.InstantAssetLockProof
import org.dashj.platform.dpp.toHex
import org.slf4j.Logger
import org.slf4j.LoggerFactory

Expand Down Expand Up @@ -94,6 +96,10 @@ class Identities(val platform: Platform) {

identityCreateTransition.signByPrivateKey(assetLockPrivateKey)

println("ST valid: ${DPP.validateIdentityCreateTransition(identityCreateTransition.toObject())}")
println("ST serialized ${DPP.serializeIdentityCreateTransition(identityCreateTransition.toObject()).toHex()}")
println("ST signable ${DPP.signableBytesIdentityCreateTransition(identityCreateTransition.toObject()).toHex()}}")

platform.broadcastStateTransition(identityCreateTransition)

// get the identity from Platform since it cannot be recreated from the transition with the balance, etc
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
package org.dashj.platform.sdk.platform

import org.bitcoinj.core.ECKey
import java.util.Date
import org.bitcoinj.core.Transaction
import org.bitcoinj.wallet.DerivationPathFactory
import org.bitcoinj.wallet.DeterministicKeyChain
import org.bitcoinj.wallet.DeterministicSeed
import org.bitcoinj.wallet.KeyChainGroup
import org.bitcoinj.wallet.Wallet
import org.bitcoinj.wallet.*
import org.bitcoinj.wallet.authentication.AuthenticationGroupExtension
import org.dashj.platform.dapiclient.model.DocumentQuery
import org.dashj.platform.dpp.statetransition.StateTransitionFactory
import org.dashj.platform.dpp.toHex
import org.dashj.platform.dpp.util.Converters
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import java.util.EnumSet

class IdentitiesTest : PlatformNetwork() {

Expand All @@ -31,7 +30,7 @@ class IdentitiesTest : PlatformNetwork() {

@Test
fun getIdentitiesTest() {
val pubKeyHash = wallet.blockchainIdentityKeyChain.getKey(0, true).pubKeyHash
val pubKeyHash = authenticationGroupExtension.identityKeyChain.getKey(0, true).pubKeyHash
val results = platform.identities.getByPublicKeyHash(pubKeyHash)

println(results!!.toJSON())
Expand All @@ -58,7 +57,9 @@ class IdentitiesTest : PlatformNetwork() {
)
.build()
)
wallet.initializeAuthenticationKeyChains(wallet.keyChainSeed, null)
val authenticationGroupExtension = AuthenticationGroupExtension(wallet)
authenticationGroupExtension.addKeyChains(wallet.params, wallet.keyChainSeed, EnumSet.of(AuthenticationKeyChain.KeyChainType.BLOCKCHAIN_IDENTITY_FUNDING))
wallet.addExtension(authenticationGroupExtension)

val stateTransactionMap =
Converters.fromHex("01000000a4647479706502697369676e6174757265584120c487a717e287581b498e6ce57a3fb8aaa243a890a971aef629b49607175a81317375cff370c285372e671713dbd508f6971cc65fea9be52b39ca1fb2ce5f837d6a7075626c69634b65797381a56269640064646174615821027ab03b55f24c3b5b66c2cc51f7efa0b97514b18eedb8dd3eccccfb276de5e2d564747970650067707572706f7365006d73656375726974794c6576656c006e61737365744c6f636b50726f6f66a46474797065006b696e7374616e744c6f636b58a501ed8bf70f95d1597fd3c911316c7719cded75bdce56870734ae0523065c633a4a00000000041d6353b4703d808ea1ac60fcc29b8b482a95829d84da39d909936cf14c470390bbcb7159e4a33e34d5e4e1e3f1ad6aaeb88d9b9fd2e406505b6d3a3b2197ab1bebe88d37964f55527581ee2193be0a085a12a5a2d6c94299594203ad2988bf5efd1b8e34f18a98580796668828117b27900dab84b48beaeac978ab4cf06f776b6f7574707574496e646578006b7472616e73616374696f6e58de0100000001ed8bf70f95d1597fd3c911316c7719cded75bdce56870734ae0523065c633a4a000000006a47304402206a57dda1bf6c66aca4d25959ff2a4450759496bfb0ce01d141a6ef09e4b8e5e90220322cd9ea02c9df5020e57f4224fb9fe856e266fe69576cb447bd75412201b98a0121032499905a363913995b704b4739e1e5a56944e9f6eb9a1ae2edc20daced90f6f4ffffffff0240420f0000000000166a1402b2cc99befd641784030f761e956cf290978af9fc858b3b000000001976a91478ce5f54af0929691c48b59bf526aa625d10b59988ac00000000")
Expand All @@ -67,9 +68,9 @@ class IdentitiesTest : PlatformNetwork() {

println(stateTransition)

val verified = stateTransition.verifySignatureByPublicKey(wallet.blockchainIdentityKeyChain.watchingKey)
val key = wallet.blockchainIdentityFundingKeyChain.freshAuthenticationKey(false)
val verified2 = stateTransition.verifySignatureByPublicKey(key)
val verified = stateTransition.verifySignatureByPublicKey(authenticationGroupExtension.identityKeyChain.getKey(0, true) as ECKey)
val key = authenticationGroupExtension.identityFundingKeyChain.freshAuthenticationKey()
val verified2 = stateTransition.verifySignatureByPublicKey(key as ECKey)

println("verification: $verified, $verified2")
val oldSignature = stateTransition.signature
Expand All @@ -78,7 +79,7 @@ class IdentitiesTest : PlatformNetwork() {
println("new sig - funding: ${stateTransition.signature!!.toHex()}")
println("old sig - original: ${oldSignature!!.toHex()}")

stateTransition.signByPrivateKey(wallet.blockchainIdentityKeyChain.watchingKey)
stateTransition.signByPrivateKey(authenticationGroupExtension.identityKeyChain.getKey(0, true) as ECKey)
println("new sig - identity: ${stateTransition.signature!!.toHex()}")
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
package org.dashj.platform.sdk.platform
import java.util.Date
import org.bitcoinj.params.OuzoDevNetParams
import org.bitcoinj.wallet.DerivationPathFactory
import org.bitcoinj.wallet.DeterministicKeyChain
import org.bitcoinj.wallet.DeterministicSeed
import org.bitcoinj.wallet.KeyChainGroup
import org.bitcoinj.wallet.Wallet
import org.bitcoinj.wallet.*
import org.bitcoinj.wallet.authentication.AuthenticationGroupExtension
import org.junit.jupiter.api.AfterEach
import java.util.*

open class PlatformNetwork {

Expand All @@ -16,6 +13,7 @@ open class PlatformNetwork {
val seed: String

val wallet: Wallet
val authenticationGroupExtension: AuthenticationGroupExtension

init {
when {
Expand Down Expand Up @@ -48,7 +46,9 @@ open class PlatformNetwork {
)
.build()
)
wallet.initializeAuthenticationKeyChains(wallet.keyChainSeed, null)
authenticationGroupExtension = AuthenticationGroupExtension(wallet)
authenticationGroupExtension.addKeyChains(wallet.params, wallet.keyChainSeed, EnumSet.of(AuthenticationKeyChain.KeyChainType.BLOCKCHAIN_IDENTITY_FUNDING))
wallet.addExtension(authenticationGroupExtension)
}

@AfterEach
Expand Down
5 changes: 3 additions & 2 deletions tools/src/main/java/org/dashj/platform/tools/WalletTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
import org.bitcoinj.evolution.SimplifiedMasternodeList;
import org.bitcoinj.evolution.SimplifiedMasternodeListEntry;
import org.bitcoinj.net.discovery.ThreeMethodPeerDiscovery;
import org.bitcoinj.params.AbsintheDevNetParams;
import org.bitcoinj.params.BinTangDevNetParams;
import org.bitcoinj.params.MainNetParams;
import org.bitcoinj.params.RegTestParams;
Expand Down Expand Up @@ -408,8 +409,8 @@ public static void main(String[] args) throws Exception {
chainFileName = new File("mainnet.spvchain");
break;
case DEVNET:
params = BinTangDevNetParams.get();
chainFileName = new File("bintang-devnet.spvchain");
params = AbsintheDevNetParams.get();
chainFileName = new File("absinthe.spvchain");
break;
case TEST:
params = TestNet3Params.get();
Expand Down