Skip to main content

SyncUniverse

SyncUniverse takes host information for a remote Universe server, then attempts to synchronize either only the set of specified asset_ids, or all assets if none are specified. The sync process will attempt to query for the latest known root for each asset, performing tree based reconciliation to arrive at a new shared root.

Source: universerpc/universe.proto

gRPC

rpc SyncUniverse (SyncRequest) returns (SyncResponse);

REST

HTTP MethodPath
POST /v1/taproot-assets/universe/sync

Code Samples

const fs = require('fs');
const grpc = require('@grpc/grpc-js');
const protoLoader = require('@grpc/proto-loader');

const GRPC_HOST = 'localhost:10029'
const MACAROON_PATH = 'TAPROOT-ASSETS_DIR/regtest/taproot-assets.macaroon'
const TLS_PATH = 'TAPROOT-ASSETS_DIR/tls.cert'

const loaderOptions = {
keepCase: true,
longs: String,
enums: String,
defaults: true,
oneofs: true,
};
const packageDefinition = protoLoader.loadSync('universerpc/universe.proto', loaderOptions);
const universerpc = grpc.loadPackageDefinition(packageDefinition).universerpc;
process.env.GRPC_SSL_CIPHER_SUITES = 'HIGH+ECDSA';
const tlsCert = fs.readFileSync(TLS_PATH);
const sslCreds = grpc.credentials.createSsl(tlsCert);
const macaroon = fs.readFileSync(MACAROON_PATH).toString('hex');
const macaroonCreds = grpc.credentials.createFromMetadataGenerator(function(args, callback) {
let metadata = new grpc.Metadata();
metadata.add('macaroon', macaroon);
callback(null, metadata);
});
let creds = grpc.credentials.combineChannelCredentials(sslCreds, macaroonCreds);
let client = new universerpc.Universe(GRPC_HOST, creds);
let request = {
universe_host: <string>,
sync_mode: <UniverseSyncMode>,
sync_targets: <SyncTarget>,
};
client.syncUniverse(request, function(err, response) {
console.log(response);
});
// Console output:
// {
// "synced_universes": <SyncedUniverse>,
// }

Messages

universerpc.SyncRequest

Source: universerpc/universe.proto

FieldgRPC TypeREST TypeREST Placement
universe_host
stringstringbody
sync_mode
UniverseSyncModestringbody
sync_targets
SyncTarget[]arraybody

universerpc.SyncResponse

Source: universerpc/universe.proto

FieldgRPC TypeREST Type
synced_universes
SyncedUniverse[]array

Nested Messages

taprpc.AnchorInfo

FieldgRPC TypeREST Type
anchor_tx
bytesstring
anchor_block_hash
stringstring
anchor_outpoint
stringstring
internal_key
bytesstring
merkle_root
bytesstring
tapscript_sibling
bytesstring
block_height
uint32integer

taprpc.Asset

FieldgRPC TypeREST Type
version
AssetVersionstring
asset_genesis
GenesisInfoobject
amount
uint64string
lock_time
int32integer
relative_lock_time
int32integer
script_version
int32integer
script_key
bytesstring
script_key_is_local
boolboolean
asset_group
AssetGroupobject
chain_anchor
AnchorInfoobject
prev_witnesses
PrevWitness[]array
is_spent
boolboolean
lease_owner
bytesstring
lease_expiry
int64string
is_burn
boolboolean
script_key_declared_known
boolboolean
script_key_has_script_path
boolboolean
decimal_display
DecimalDisplayobject

taprpc.AssetGroup

FieldgRPC TypeREST Type
raw_group_key
bytesstring
tweaked_group_key
bytesstring
asset_witness
bytesstring
tapscript_root
bytesstring

taprpc.DecimalDisplay

FieldgRPC TypeREST Type
decimal_display
uint32integer

taprpc.GenesisInfo

FieldgRPC TypeREST Type
genesis_point
stringstring
name
stringstring
meta_hash
bytesstring
asset_id
bytesstring
asset_type
AssetTypestring
output_index
uint32integer

taprpc.PrevInputAsset

FieldgRPC TypeREST Type
anchor_point
stringstring
asset_id
bytesstring
script_key
bytesstring
amount
uint64string

taprpc.PrevWitness

FieldgRPC TypeREST Type
prev_id
PrevInputAssetobject
tx_witness
bytes[]array
split_commitment
SplitCommitmentobject

taprpc.SplitCommitment

FieldgRPC TypeREST Type
root_asset
Assetobject

universerpc.AssetLeaf

FieldgRPC TypeREST Type
asset
Assetobject
proof
bytesstring

universerpc.ID

FieldgRPC TypeREST Type
asset_id
bytesstring
asset_id_str
stringstring
group_key
bytesstring
group_key_str
stringstring
proof_type
ProofTypestring

universerpc.MerkleSumNode

FieldgRPC TypeREST Type
root_hash
bytesstring
root_sum
int64string

universerpc.SyncedUniverse

FieldgRPC TypeREST Type
old_asset_root
UniverseRootobject
new_asset_root
UniverseRootobject
new_asset_leaves
AssetLeaf[]array

universerpc.SyncTarget

FieldgRPC TypeREST Type
id
IDobject

universerpc.UniverseRoot

FieldgRPC TypeREST Type
id
IDobject
mssmt_root
MerkleSumNodeobject
asset_name
stringstring
amounts_by_asset_id
AmountsByAssetIdEntry[]object

universerpc.UniverseRoot.AmountsByAssetIdEntry

FieldgRPC TypeREST Type
key
stringunknown
value
uint64unknown

Enums

taprpc.AssetType

NameNumber
NORMAL
0
COLLECTIBLE
1

taprpc.AssetVersion

NameNumber
ASSET_VERSION_V0
0
ASSET_VERSION_V1
1

universerpc.ProofType

NameNumber
PROOF_TYPE_UNSPECIFIED
0
PROOF_TYPE_ISSUANCE
1
PROOF_TYPE_TRANSFER
2

universerpc.UniverseSyncMode

NameNumber
SYNC_ISSUANCE_ONLY
0
SYNC_FULL
1