Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
5d514d9
chore: set v1.7.2-SNAPSHOT
HashEngineering Jan 27, 2025
69a2bd3
feat: add TxMetadata protobuf as new data format
HashEngineering Jan 27, 2025
3c5810f
feat: add wallet-utils data contract
HashEngineering Jan 27, 2025
7362d3d
fix: improve error handling in fetch documents
HashEngineering Jan 27, 2025
b590753
feat: update TxMetadata to use protobuf storage
HashEngineering Feb 4, 2025
4176624
tests: Add and modify TxMetadata tests
HashEngineering Feb 4, 2025
b2f5a97
feat: add and update TxMetadata examples
HashEngineering Feb 4, 2025
b922d77
feat: add RegisteredNamesWithBalance example
HashEngineering Feb 4, 2025
29d7618
chore: remove commented code from result.i
HashEngineering Feb 4, 2025
c2a6020
chore: update Cargo.lock
HashEngineering Mar 19, 2025
c66b9aa
Merge branch 'main' of https://github.com/HashEngineering/kotlin-plat…
HashEngineering Mar 19, 2025
a19feeb
Merge branch 'main' of https://github.com/HashEngineering/kotlin-plat…
HashEngineering Jun 6, 2025
5325fcb
fix: build.gradle swig command line fix
HashEngineering Jun 20, 2025
9f05f37
Merge branch 'platform-2' of https://github.com/HashEngineering/kotli…
HashEngineering Jun 20, 2025
9a24687
Merge branch 'platform-2' of https://github.com/HashEngineering/kotli…
HashEngineering Jul 3, 2025
bc2010c
fix: sdk version related fixes
HashEngineering Jul 4, 2025
149c339
chore: update version to 2.0.0-TX-SNAPSHOT
HashEngineering Jul 4, 2025
b5e505e
fix: add progress tracking to publishTxMetaData
HashEngineering Jul 4, 2025
68bf870
tests: add more tests for DataContractTest
HashEngineering Jul 4, 2025
6c3d28c
chore: update clone.h and ignore.i
HashEngineering Jul 4, 2025
b35c9cd
chore: update Cargo.lock
HashEngineering Jul 4, 2025
24c4ca4
tests: remove obsolete tests
HashEngineering Jul 4, 2025
e53e4a5
tests: remove obsolete tests
HashEngineering Jul 4, 2025
9965ca9
tests: remove obsolete tests
HashEngineering Jul 4, 2025
04bd06b
Merge branch 'main' of https://github.com/HashEngineering/kotlin-plat…
HashEngineering Oct 8, 2025
8229fc3
feat: match to txmetadata spec
HashEngineering Oct 20, 2025
ba3b391
feat: improve DisplayIdentityKeys.kt
HashEngineering Oct 20, 2025
2579d9a
tests: update DataContractTest
HashEngineering Oct 20, 2025
6a714ae
tests: add tests for creatinging txmetadata objects
HashEngineering Oct 20, 2025
62d56d4
fix: align with txmetadata specification
HashEngineering Oct 23, 2025
08ff507
tests: add CreateTxMetadataTest.kt
HashEngineering Oct 23, 2025
102b200
fix: display all contested resources
HashEngineering Oct 23, 2025
46fd025
fix: resolve some issues with RegisteredNamesWithBalance
HashEngineering Oct 23, 2025
5ee49e9
chore update Cargo.lock files
HashEngineering Oct 23, 2025
dc20aec
chore: CBOR handling fix
HashEngineering Nov 3, 2025
d9739e7
chore: check for empty array
HashEngineering Nov 3, 2025
17bd342
Merge branch 'main' into feat/improve-txmetadata
HashEngineering Nov 3, 2025
b43ab11
fix: align with txmetadataspec (path)
HashEngineering Nov 3, 2025
9fdae81
fix: add valid seed to PlatformNetwork.kt
HashEngineering Nov 3, 2025
53679cc
fix: update txmetadata derivation path, two ways
HashEngineering Nov 3, 2025
436c5a3
fix: allow individual documents to fail decryption
HashEngineering Nov 3, 2025
53fd75e
chore: remove duplicate version set
HashEngineering Nov 3, 2025
29dfa72
Merge branch 'main' into feat/improve-txmetadata
HashEngineering Nov 5, 2025
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Build the android libraries to publish to Maven Central

### Use in other projects
```groovy
dppVersion = "1.7.1"
dppVersion = "1.7.2-SNAPSHOT"
dependencies {
implementation "org.dashj.platform:dash-sdk-java:$dppVersion"
implementation "org.dashj.platform:dash-sdk-kotlin:$dppVersion" // dpp
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
buildscript {
ext.version = '1.7.1'
ext.version = '1.7.2-SNAPSHOT'
ext.kotlin_version = '1.8.22'
ext.dashj_version = '21.1.0'
repositories {
Expand Down
7 changes: 0 additions & 7 deletions dash-sdk-java/src/main/swig/generics/result.i
Original file line number Diff line number Diff line change
Expand Up @@ -233,25 +233,18 @@
if ($1->ok != NULL) {
jobject elementObj = nullptr;
if (strcmp(#RETURN_TYPE, "String") == 0) {
// printf("string item\n");
// printf("string item: %s\n", $1->ok);
elementObj = jenv->NewStringUTF((const char *)$1->ok);
} else if (strcmp(#RETURN_TYPE, "Integer") == 0) {
//printf("int item\n");
//printf("int item: %d\n", *$1->ok);
jclass integerClass = (jenv)->FindClass("java/lang/Integer");
jmethodID constructor = (jenv)->GetMethodID(integerClass, "<init>", "(I)V");
elementObj = (jenv)->NewObject(integerClass, constructor, (int)(long)*$1->ok); // ok is a pointer, but acts as a value
} else if (strcmp(#RETURN_TYPE, "Long") == 0) {
//printf("long item\n");
//printf("long item: %lld\n", $1->ok);
jclass integerClass = (jenv)->FindClass("java/lang/Long");
jmethodID constructor = (jenv)->GetMethodID(integerClass, "<init>", "(J)V");
elementObj = (jenv)->NewObject(integerClass, constructor, (long)*$1->ok); // ok is a pointer, but acts as a value
} else {
printf("invalid? item\n");
}
printf("ok value is assigned, now create result\n");
jmethodID midSuccess = jenv->GetStaticMethodID(resultClass, "Ok", "(Ljava/lang/Object;)Lorg/dashj/platform/sdk/base/Result;");
$result = jenv->CallStaticObjectMethod(resultClass, midSuccess, elementObj);
} else {
Expand Down
7 changes: 5 additions & 2 deletions dpp/src/main/java/org/dashj/platform/dapiclient/SystemIds.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@

package org.dashj.platform.dapiclient

import org.bitcoinj.core.Sha256Hash
import org.dashj.platform.dpp.identifier.Identifier

object SystemIds {
val dpnsOwnerId = Identifier.from("4EfA9Jrvv3nnCFdSf7fad59851iiTRZ6Wcu6YVJ4iSeF")
val dpnsOwnerId = Identifier.from(Sha256Hash.ZERO_HASH)
val dpnsDataContractId = Identifier.from("GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec")
val dashpayOwnerId = Identifier.from("5PhRFRrWZc5Mj8NqtpHNXCmmEQkcZE8akyDkKhsUVD4k")
val dashpayOwnerId = Identifier.from(Sha256Hash.ZERO_HASH)
val dashpayDataContractId = Identifier.from("Bwr4WHCPz5rFVAD87RqTs3izo4zpzwsEdKPWUT1NS1C7")
val walletUtilsOwnerId = Identifier.from(Sha256Hash.ZERO_HASH)
val walletUtilsDataContractId = Identifier.from("7CSFGeF4WNzgDmx94zwvHkYaG3Dx4XEe5LFsFgJswLbm")
}
81 changes: 61 additions & 20 deletions dpp/src/main/java/org/dashj/platform/dashpay/BlockchainIdentity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import org.bitcoinj.wallet.authentication.AuthenticationGroupExtension
import org.bouncycastle.crypto.params.KeyParameter
import org.dashj.platform.wallet.TxMetadata
import org.dashj.platform.contracts.wallet.TxMetadataDocument
import org.dashj.platform.contracts.wallet.TxMetadataItem
import org.dashj.platform.wallet.TxMetadataItem
import org.dashj.platform.dapiclient.MaxRetriesReachedException
import org.dashj.platform.dapiclient.model.DocumentQuery
import org.dashj.platform.dashpay.callback.*
Expand All @@ -66,6 +66,7 @@ import org.dashj.platform.dpp.util.Converters
import org.dashj.platform.sdk.*
import org.dashj.platform.sdk.platform.Names
import org.dashj.platform.sdk.platform.Platform
import org.dashj.platform.wallet.WalletUtils.TxMetadataBatch
import org.slf4j.LoggerFactory
import java.math.BigInteger
import java.util.concurrent.ExecutionException
Expand Down Expand Up @@ -2248,18 +2249,26 @@ class BlockchainIdentity {
return "assetlocktx=$txid&pk=$wif&du=${currentUsername!!}&islock=${cftx.confidence.instantSendlock.toStringHex()}"
}

// Transaction Metadata Methods
@Throws(KeyCrypterException::class)
fun publishTxMetaData(txMetadataItems: List<TxMetadataItem>, keyParameter: KeyParameter?) {
if (!platform.hasApp("dashwallet")) {
return
fun createTxMetadata(txMetadataItems: List<TxMetadataItem>, keyParameter: KeyParameter?, encryptionKeyIndex: Int, version: Int): List<Document> {
if (!platform.hasApp("wallet-utils")) {
return arrayListOf()
}
val keyIndex = 1
val encryptionKeyIndex = 0
val encryptionKey = privateKeyAtPath(keyIndex, TxMetadataDocument.childNumber, encryptionKeyIndex, KeyType.ECDSA_SECP256K1, keyParameter)
val encryptionIdentityPublicKey = identity!!.getFirstPublicKey(Purpose.ENCRYPTION, SecurityLevel.MEDIUM)
?: identity!!.getFirstPublicKey(Purpose.AUTHENTICATION, SecurityLevel.HIGH)
?: error("can't find a authentication public key with HIGH security level or encryption key")
val keyIndex = encryptionIdentityPublicKey.id
val encryptionKey = privateKeyAtPath(
keyIndex,
TxMetadataDocument.childNumber,
encryptionKeyIndex,
KeyType.ECDSA_SECP256K1,
keyParameter
)

var lastItem: TxMetadataItem? = null
var currentIndex = 0
val result = arrayListOf<Document>()
log.info("publish ${txMetadataItems.size} by breaking it up into pieces")
while (currentIndex < txMetadataItems.size) {
var estimatedDocSize = 0
Expand All @@ -2280,27 +2289,48 @@ class BlockchainIdentity {
}

log.info("publishing ${currentMetadataItems.size} items of ${txMetadataItems.size}")
val metadataBytes = Cbor.encode(currentMetadataItems.map { it.toObject() })
val txMetadata = TxMetadata(platform)
val metadataBytes = txMetadata.getBuffer(TxMetadataDocument.VERSION_PROTOBUF, currentMetadataItems)//Cbor.encode(currentMetadataItems.map { it.toObject() })

// encrypt data
val cipher = KeyCrypterAESCBC()
val aesKey = cipher.deriveKey(encryptionKey)
val encryptedData = cipher.encrypt(metadataBytes, aesKey)

TxMetadata(platform).create(
val allEncryptedData = ByteArray(1 + encryptedData.initialisationVector.size + encryptedData.encryptedBytes.size)
allEncryptedData[0] = version.toByte()
encryptedData.initialisationVector.copyInto(allEncryptedData, 1)
encryptedData.encryptedBytes.copyInto(allEncryptedData, encryptedData.initialisationVector.size + 1)
val txMetadataDocument = txMetadata.createDocument(
keyIndex,
encryptionKeyIndex,
encryptedData.initialisationVector.plus(encryptedData.encryptedBytes),
allEncryptedData,
identity!!,
KeyIndexPurpose.AUTHENTICATION.ordinal,
WalletSignerCallback(wallet!!, keyParameter)
)
result.add(txMetadataDocument)
currentMetadataItems.clear()
}
return result
}

// Transaction Metadata Methods
@Throws(KeyCrypterException::class)
fun publishTxMetaData(txMetadataItems: List<TxMetadataItem>, keyParameter: KeyParameter?, encryptionKeyIndex: Int, version: Int) {
if (!platform.hasApp("wallet-utils")) {
return
}
val documentsToPublish = createTxMetadata(txMetadataItems, keyParameter, encryptionKeyIndex, version)
val txMetadata = TxMetadata(platform)
documentsToPublish.forEach { txMetadataDocument ->
txMetadata.publish(
txMetadataDocument,
identity!!,
WalletSignerCallback(wallet!!, keyParameter)
)
}
}

fun getTxMetaData(createdAfter: Long = -1, keyParameter: KeyParameter?): Map<TxMetadataDocument, List<TxMetadataItem>> {
if (!platform.hasApp("dashwallet")) {
if (!platform.hasApp("wallet-utils")) {
return hashMapOf()
}
val documents = TxMetadata(platform).get(uniqueIdentifier, createdAfter)
Expand All @@ -2315,6 +2345,7 @@ class BlockchainIdentity {

@Throws(KeyCrypterException::class)
fun decryptTxMetadata(txMetadataDocument: TxMetadataDocument, keyParameter: KeyParameter?): List<TxMetadataItem> {
checkArgument(wallet!!.isEncrypted == (keyParameter != null), "isEncrypted must match keyParameter")
val cipher = KeyCrypterAESCBC()
val encryptionKey = privateKeyAtPath(
txMetadataDocument.keyIndex,
Expand All @@ -2324,17 +2355,27 @@ class BlockchainIdentity {
keyParameter
)
val aesKeyParameter = cipher.deriveKey(encryptionKey)

val version = txMetadataDocument.encryptedMetadata[0].toInt()
// now decrypt
val encryptedData = EncryptedData(
txMetadataDocument.encryptedMetadata.copyOfRange(0, 16),
txMetadataDocument.encryptedMetadata.copyOfRange(16, txMetadataDocument.encryptedMetadata.size)
txMetadataDocument.encryptedMetadata.copyOfRange(1, 17),
txMetadataDocument.encryptedMetadata.copyOfRange(17, txMetadataDocument.encryptedMetadata.size)
)

val decryptedData = cipher.decrypt(encryptedData, aesKeyParameter)
val decryptedList = Cbor.decodeList(decryptedData)

return decryptedList.map { TxMetadataItem(it as Map<String, Any?>) }

return when (version) {
TxMetadataDocument.VERSION_CBOR -> {
val decryptedList = Cbor.decodeList(decryptedData)
decryptedList.map { TxMetadataItem(it as Map<String, Any?>) }
}
TxMetadataDocument.VERSION_PROTOBUF -> {
val decryptedList = TxMetadataBatch.parser().parseFrom(decryptedData)
decryptedList.itemsList.map { TxMetadataItem(it) }
}
else -> error ("invalid tx metadata version $version")
}
}

fun deleteDocument(typeLocator: String, documentId: Identifier, keyParameter: KeyParameter?): Boolean {
Expand Down
7 changes: 4 additions & 3 deletions dpp/src/main/java/org/dashj/platform/sdk/platform/Platform.kt
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,17 @@ class Platform(val params: NetworkParameters) {
init {
apps["dpns"] = ClientAppDefinition(SystemIds.dpnsDataContractId)
apps["dashpay"] = ClientAppDefinition(SystemIds.dashpayDataContractId)
apps["wallet-utils"] = ClientAppDefinition(SystemIds.walletUtilsDataContractId)
when {
params.id.contains("test") -> {
useWhiteList = true
apps["dashwallet"] = ClientAppDefinition("Bhptm3yBDhLkRNt7ofjpwaBHhMUKjDrQoPufKzQaxmpK")
apps["identity-verify"] = ClientAppDefinition("Bhptm3yBDhLkRNt7ofjpwaBHhMUKjDrQoPufKzQaxmpK")
}
params.id.contains("bintang") -> {
apps["dashwallet"] = ClientAppDefinition("Fds5DDfXoLwpUZ71AAVYZP1uod8S7Ze2bR28JExBvZKR")
apps["identity-verify"] = ClientAppDefinition("Fds5DDfXoLwpUZ71AAVYZP1uod8S7Ze2bR28JExBvZKR")
}
params.id.contains("production") -> {
apps["dashwallet"] = ClientAppDefinition("EVKMFboB3QBUa9Jo7PP5bsLyohzUz8zvw5c2gJs1SfcX")
apps["identity-verify"] = ClientAppDefinition("EVKMFboB3QBUa9Jo7PP5bsLyohzUz8zvw5c2gJs1SfcX")
}
}
System.loadLibrary("sdklib")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class IdentityVerify(
) {

companion object {
const val DOCUMENT: String = "dashwallet.identityVerify"
const val DOCUMENT: String = "identity-verify.identityVerify"
private val log = LoggerFactory.getLogger(IdentityVerify::class.java)
}

Expand Down
43 changes: 40 additions & 3 deletions dpp/src/main/java/org/dashj/platform/wallet/TxMetadata.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,31 @@ package org.dashj.platform.wallet
import java.util.Date
import kotlin.collections.HashMap
import org.bitcoinj.core.ECKey
import org.dashj.platform.contracts.wallet.TxMetadataDocument
import org.dashj.platform.dapiclient.model.DocumentQuery
import org.dashj.platform.dashpay.callback.SingleKeySignerCallback
import org.dashj.platform.dpp.document.Document
import org.dashj.platform.dpp.document.DocumentCreateTransition
import org.dashj.platform.dpp.document.DocumentsBatchTransition
import org.dashj.platform.dpp.identifier.Identifier
import org.dashj.platform.dpp.identity.Identity
import org.dashj.platform.dpp.util.Cbor
import org.dashj.platform.sdk.BlockHeight
import org.dashj.platform.sdk.CoreBlockHeight
import org.dashj.platform.sdk.Purpose
import org.dashj.platform.sdk.SecurityLevel
import org.dashj.platform.sdk.callbacks.Signer
import org.dashj.platform.sdk.dashsdk
import org.dashj.platform.sdk.platform.Platform
import org.dashj.platform.wallet.WalletUtils.TxMetadataBatch
import java.math.BigInteger

class TxMetadata(
val platform: Platform
) {

companion object {
const val DOCUMENT: String = "dashwallet.tx_metadata"
const val DOCUMENT: String = "wallet-utils.txMetadata"
}

fun create(
Expand Down Expand Up @@ -63,6 +66,30 @@ class TxMetadata(
return Document(domain, profileDocument.dataContractId!!)
}

fun publish(
txMetadataDocument: Document,
identity: Identity,
signer: Signer
): Document {
val highIdentityPublicKey = identity.getFirstPublicKey(Purpose.AUTHENTICATION, SecurityLevel.HIGH)
?: error("can't find a public key with HIGH security level")

val documentResult = dashsdk.platformMobilePutPutDocumentSdk(
platform.rustSdk,
txMetadataDocument.toNative(),
txMetadataDocument.dataContractId!!.toNative(),
txMetadataDocument.type,
highIdentityPublicKey.toNative(),
BlockHeight(10000),
CoreBlockHeight(platform.coreBlockHeight),
signer.nativeContext,
BigInteger.valueOf(signer.signerCallback),
)
val domain = documentResult.unwrap()

return Document(domain, txMetadataDocument.dataContractId!!)
}

fun createDocument(
keyIndex: Int,
encryptionKeyIndex: Int,
Expand All @@ -83,17 +110,27 @@ class TxMetadata(
return document
}

fun getBuffer(version: Int, metadataItems: List<TxMetadataItem>): ByteArray {
return when (version) {
TxMetadataDocument.VERSION_CBOR -> Cbor.encode(metadataItems.map { it.toObject() })
TxMetadataDocument.VERSION_PROTOBUF -> {
TxMetadataBatch.newBuilder().addAllItems(metadataItems.map { it.toProtobuf() }).build().toByteArray()
}
else -> error("Invalid version txmetadata $version")
}
}

fun get(userId: String): List<Document> {
return get(Identifier.from(userId))
}

fun get(userId: Identifier, createdAfter: Long = -1): List<Document> {
val queryBuilder = DocumentQuery.Builder()
.where("\$ownerId", "==", userId)
.orderBy("\$createdAt")
.orderBy("\$updatedAt")

if (createdAfter != -1L) {
queryBuilder.where(listOf("\$createdAt", ">=", createdAfter))
queryBuilder.where(listOf("\$updatedAt", ">=", createdAfter))
}

val query = queryBuilder.build()
Expand Down
27 changes: 23 additions & 4 deletions dpp/src/main/java/org/dashj/platform/wallet/TxMetadataDocument.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,19 @@ import org.bouncycastle.crypto.params.KeyParameter
import org.dashj.platform.dpp.document.Document
import org.dashj.platform.dpp.util.Cbor
import org.dashj.platform.sdk.platform.AbstractDocument
import org.dashj.platform.wallet.TxMetadataItem
import org.dashj.platform.wallet.WalletUtils.TxMetadataBatch

class TxMetadataDocument(document: Document) : AbstractDocument(document) {

companion object {
// 2^16 + 2
val childNumber = ChildNumber(2 shl 15 + 1, true)
const val MAX_ENCRYPTED_SIZE = 4096 - 32 // leave room for a partially filled block and the IV

Comment on lines 21 to 26
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Operator precedence bug in child number expression.

2 shl 15 + 1 is parsed as 2 shl (15 + 1) yielding 131072, not “2^16 + 2” as the comment states. Make the intent explicit.

Apply:

-        // 2^16 + 2
-        val childNumber = ChildNumber(2 shl 15 + 1, true)
+        // 2^16 + 2 = 65538
+        val childNumber = ChildNumber((1 shl 16) + 2, true)

Also fix the same expression in tests (BlockchainIdentityTest.kt Lines 172–173).

🤖 Prompt for AI Agents
In dpp/src/main/java/org/dashj/platform/wallet/TxMetadataDocument.kt around
lines 23–26, the expression `2 shl 15 + 1` has wrong operator precedence and
does not match the comment "2^16 + 2"; replace it with an explicit calculation
such as `(1 shl 16) + 2` (or a literal 65538) to make the intent unambiguous,
and apply the same fix to the identical expression in tests at
BlockchainIdentityTest.kt lines 172–173.

const val VERSION_UNKNOWN = -1
const val VERSION_CBOR = 0
const val VERSION_PROTOBUF = 1
}

val keyIndex: Int
Expand All @@ -29,6 +35,8 @@ class TxMetadataDocument(document: Document) : AbstractDocument(document) {
get() = (document.data["encryptionKeyIndex"] as Long).toInt()
val encryptedMetadata: ByteArray
get() = getFieldByteArray("encryptedMetadata")!!
var txMetadataVersion = VERSION_UNKNOWN
private set

override fun equals(other: Any?): Boolean {
if (this === other) return true
Expand All @@ -53,9 +61,20 @@ class TxMetadataDocument(document: Document) : AbstractDocument(document) {
val iv = encryptedMetadata.copyOfRange(0, 16)
val encryptedData = encryptedMetadata.copyOfRange(16, encryptedMetadata.size)
val decryptedData = cipher.decrypt(EncryptedData(iv, encryptedData), keyParameter)
// use Cbor.decodeList
val list = Cbor.decodeList(decryptedData)
// use .map to convert to List<TxMetadataItem>
return list.map { TxMetadataItem(it as Map<String, Any?>) }
val version = decryptedData.copyOfRange(0, 1)[0].toInt() and 0xFF
return when (version) {
VERSION_CBOR -> {
val list = Cbor.decodeList(decryptedData)
this.txMetadataVersion = VERSION_CBOR
// use .map to convert to List<TxMetadataItem>
list.map { TxMetadataItem(it as Map<String, Any?>) }
}
VERSION_PROTOBUF -> {
val batch = TxMetadataBatch.parser().parseFrom(decryptedData, 1, decryptedData.size - 1)
txMetadataVersion = VERSION_PROTOBUF
batch.itemsList.map { TxMetadataItem(it) }
}
else -> error("")
}
}
}
Loading