Skip to content

Commit

Permalink
Adding missing fields
Browse files Browse the repository at this point in the history
  • Loading branch information
straumat committed Nov 3, 2023
1 parent f6ebfcd commit 38996c8
Show file tree
Hide file tree
Showing 7 changed files with 171 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.royllo.explorer.core.domain.asset;

import jakarta.persistence.Column;
import jakarta.persistence.Convert;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
Expand All @@ -15,6 +16,11 @@
import org.royllo.explorer.core.domain.bitcoin.BitcoinTransactionOutput;
import org.royllo.explorer.core.domain.user.User;
import org.royllo.explorer.core.util.base.BaseDomain;
import org.royllo.explorer.core.util.converter.StringListConverter;

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;

import static jakarta.persistence.FetchType.EAGER;
import static jakarta.persistence.GenerationType.IDENTITY;
Expand Down Expand Up @@ -76,6 +82,22 @@ public class AssetState extends BaseDomain {
@Column(name = "TAPSCRIPT_SIBLING")
private String tapscriptSibling;

/** The version of the Taproot Asset. */
@Column(name = "VERSION")
private String version;

/** The total amount of the asset stored in this Taproot asset UTXO. */
@Column(name = "AMOUNT")
private BigInteger amount;

/** An optional locktime, as with Bitcoin transactions. */
@Column(name = "LOCK_TIME")
private int lockTime;

/** An optional relative lock time, same as Bitcoin transactions. */
@Column(name = "RELATIVE_LOCK_TIME")
private int relativeLockTime;

/** The version of the script, only version 0 is defined at present. */
@Column(name = "SCRIPT_VERSION")
private int scriptVersion;
Expand All @@ -84,4 +106,34 @@ public class AssetState extends BaseDomain {
@Column(name = "SCRIPT_KEY")
private String scriptKey;

/** If the asset has been leased, this is the owner (application ID) of the lease. */
@Column(name = "LEASE_OWNER")
private String leaseOwner;

/** If the asset has been leased, this is the expiry of the lease as a Unix timestamp in seconds. */
@Column(name = "LEASE_EXPIRY")
private long leaseExpiry;

/** The merkle proof for AnchorTx used to prove its inclusion within BlockHeader. */
@Column(name = "TX_MERKLE_PROOF")
private String txMerkleProof;

/** The TaprootProof proving the new inclusion of the resulting asset within AnchorTx. */
@Column(name = "INCLUSION_PROOF")
private String inclusionProof;

/** The set of TaprootProofs proving the exclusion of the resulting asset from all other Taproot outputs within AnchorTx. */
@Convert(converter = StringListConverter.class)
@Column(name = "EXCLUSION_PROOFS")
private List<String> exclusionProofs = new ArrayList<>();

/** An optional TaprootProof needed if this asset is the result of a split. SplitRootProof proves inclusion of the root asset of the split. */
@Column(name = "SPLIT_ROOT_PROOF")
private String splitRootProof;

/** ChallengeWitness is an optional virtual transaction witness that serves as an ownership proof for the asset. */
@Convert(converter = StringListConverter.class)
@Column(name = "CHALLENGE_WITNESS")
private List<String> challengeWitness = new ArrayList<>();

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
import org.royllo.explorer.core.dto.bitcoin.BitcoinTransactionOutputDTO;
import org.royllo.explorer.core.dto.user.UserDTO;

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;

import static lombok.AccessLevel.PRIVATE;

/**
Expand Down Expand Up @@ -54,6 +58,20 @@ public class AssetStateDTO {
/** The serialized preimage of a Tapscript sibling, if there was one. */
String tapscriptSibling;

/** The version of the Taproot Asset. */
@NotNull(message = "Version is required")
String version;

/** The total amount of the asset stored in this Taproot asset UTXO. */
@NotNull(message = "Amount is required")
BigInteger amount;

/** An optional locktime, as with Bitcoin transactions. */
int lockTime;

/** An optional relative lock time, same as Bitcoin transactions. */
int relativeLockTime;

/** The version of the script, only version 0 is defined at present. */
@NotNull(message = "Script version is required")
Integer scriptVersion;
Expand All @@ -62,6 +80,27 @@ public class AssetStateDTO {
@NotNull(message = "Script key is required")
String scriptKey;

/** If the asset has been leased, this is the owner (application ID) of the lease. */
String leaseOwner;

/** If the asset has been leased, this is the expiry of the lease as a Unix timestamp in seconds. */
long leaseExpiry;

/** The merkle proof for AnchorTx used to prove its inclusion within BlockHeader. */
String txMerkleProof;

/** The TaprootProof proving the new inclusion of the resulting asset within AnchorTx. */
String inclusionProof;

/** The set of TaprootProofs proving the exclusion of the resulting asset from all other Taproot outputs within AnchorTx. */
List<String> exclusionProofs = new ArrayList<>();

/** An optional TaprootProof needed if this asset is the result of a split. SplitRootProof proves inclusion of the root asset of the split. */
String splitRootProof;

/** ChallengeWitness is an optional virtual transaction witness that serves as an ownership proof for the asset. */
List<String> challengeWitness = new ArrayList<>();

/** The asset state ID that uniquely identifies the asset state (calculated by Royllo). */
@Setter
@NonFinal
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package org.royllo.explorer.core.util.converter;

import jakarta.persistence.AttributeConverter;
import jakarta.persistence.Converter;

import java.util.Arrays;
import java.util.List;

import static java.util.Collections.emptyList;

@Converter
public final class StringListConverter implements AttributeConverter<List<String>, String> {

/** Split character. */
private static final String SPLIT_CHAR = ",";

@Override
public String convertToDatabaseColumn(final List<String> stringList) {
if (stringList != null) {
return String.join(SPLIT_CHAR, stringList);
} else {
return "";
}
}

@Override
public List<String> convertToEntityAttribute(final String string) {
if (string != null) {
return Arrays.asList(string.split(SPLIT_CHAR));
} else {
return emptyList();
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/**
* Converters.
*/
package org.royllo.explorer.core.util.converter;
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,26 @@
<column name="TAPSCRIPT_SIBLING" value=""/>

<!-- State data -->
<column name="VERSION" value="ASSET_VERSION_V0"/>
<column name="AMOUNT" value="10000"/>
<column name="LOCK_TIME" value="0"/>
<column name="RELATIVE_LOCK_TIME" value="0"/>

<column name="SCRIPT_VERSION" value="0"/>
<column name="SCRIPT_KEY" value="025d615b377761a5bfcfe84f0f11afd35837a68f702dd8a0cac0a2a4052b20d211"/>

<column name="LEASE_OWNER" value=""/>
<column name="LEASE_OWNER" value="0"/>

<column name="TX_MERKLE_ROOT"
value="060d6cca264dc5ae7811f5e30305b64021c4b6107325359dd2964afb464ede9d209af1a7478aa5e8704ed521214bfa5935f022a3282ca01ec378743f8f2b26e883d7c81784fdd7aa621d14239510ee5f06add858f8f7c262941b6642674650628793c0b475e851828cbbd4048d003279eb3617939dee343f2a0edc55c6eb694929ac0f81acc5d39a6dd1675e351a7c26c84a6636253d30525ed7f09e9aba7d472b9d9a0a166581b27a343859332d3bebc60736a221995481b9355a475bb52c468330"/>
<column name="INCLUSION_PROOF"
value="0004000000000221026ad322cc8a05cf5723bf8aeb5c778c6462146e573af182ba20c6bed53ea29ae6037401490001000220ce5a426ea282d2dee3a2eb48170231403ee4768be17f73fef8e6f925d30797af04220000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff022700010002220000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"/>
<column name="EXCLUSION_PROOFS"
value="00040000000102210264e26d9bcccf4e442e08a8bab1fc2a0b64fcb83b34cbba1fe4b0404c3fd110980503040101"/>
<column name="SPLIT_ROOT_PROOF" value=""/>
<column name="CHALLENGE_WITNESS" value=""/>

</insert>

</changeSet>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

<!-- Asset genesis : The base genesis information of an asset. This information never changes -->
<column name="ASSET_ID" type="VARCHAR(255)"
remarks="Asset group id (=RAW_GROUP_KEY)."/>
remarks="Asset group id (=RAW_GROUP_KEY)"/>
<column name="FK_BITCOIN_TRANSACTION_OUTPUT_GENESIS_POINT" type="BIGINT"
remarks="The first outpoint of the transaction that created the asset (txid:vout)"/>
<column name="META_DATA_HASH" type="TEXT"
Expand All @@ -37,7 +37,7 @@
<column name="ASSET_TYPE" type="TEXT"
remarks="The type of the asset: normal or a collectible"/>
<column name="AMOUNT" type="BIGINT"
remarks="The total amount of the asset stored in this Taproot UTXO"/>
remarks="The total amount minted of the asset"/>

<!-- Technical fields -->
<column name="CREATED_ON" type="TIMESTAMP"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,32 @@
remarks="The serialized preimage of a Tapscript sibling, if there was one. If this is empty, then the merkle_root hash is equal to the Taproot root hash of the anchor output"/>

<!-- State data -->
<column name="VERSION" type="TEXT"
remarks="The version of the Taproot Asset"/>
<column name="AMOUNT" type="BIGINT"
remarks="The total amount of the asset stored in this Taproot UTXO"/>
<column name="LOCK_TIME" type="BIGINT"
remarks="An optional locktime, as with Bitcoin transactions"/>
<column name="RELATIVE_LOCK_TIME" type="BIGINT"
remarks="An optional relative lock time, same as Bitcoin transactions"/>
<column name="SCRIPT_VERSION" type="INTEGER"
remarks="The version of the script, only version 0 is defined at present"/>
<column name="SCRIPT_KEY" type="TEXT"
remarks="The script key of the asset, which can be spent under Taproot semantics"/>
<column name="LEASE_OWNER" type="TEXT"
remarks="If the asset has been leased, this is the owner (application ID) of the lease"/>
<column name="LEASE_EXPIRY" type="BIGINT"
remarks="If the asset has been leased, this is the expiry of the lease as a Unix timestamp in seconds."/>
<column name="TX_MERKLE_ROOT" type="TEXT"
remarks="The merkle root of the transaction that created the asset"/>
<column name="INCLUSION_PROOF" type="TEXT"
remarks="The TaprootProof proving the new inclusion of the resulting asset within AnchorTx"/>
<column name="EXCLUSION_PROOFS" type="TEXT"
remarks="The TaprootProof proving the exclusion of the resulting asset within AnchorTx"/>
<column name="SPLIT_ROOT_PROOF" type="TEXT"
remarks="An optional TaprootProof needed if this asset is the result of a split. SplitRootProof proves inclusion of the root asset of the split"/>
<column name="CHALLENGE_WITNESS" type="TEXT"
remarks="ChallengeWitness is an optional virtual transaction witness that serves as an ownership proof for the asset"/>

<!-- Technical fields -->
<column name="CREATED_ON" type="TIMESTAMP"
Expand Down

0 comments on commit 38996c8

Please sign in to comment.