You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- getAddress() - returns {String} ```represented the bech32 encoding version of a publickey e.g. ```
33
+
- getAddress() - returns {String} ```represented the bech32 encoding version of a publickey ```
34
34
- decodeAddress() - returns {Object} ```with fields script_type (string representing) and pubHex (hex string of public key)```
35
35
36
36
- static decodeFromAddressString(address) - returns ```{Object} with fields script_type {Number} and pubHex {String} (hexdecimal string of public key)```
@@ -40,7 +40,9 @@ The following is a breakdown of sections and classes for this cbdc-module:
40
40
- secretKeyData - ```{String} a valid 32 byte hexadecimal string```
41
41
- static fromPrivateKeyData(secretKeyData)
42
42
- secretKeyData - ```{String} a valid 32 byte hexadecimal string```
- contructor(randBytes) - ```returns new SecretKey with randBytes provided as random seed (if provided), otherwise it creates random key from random secrety bytes```
@@ -54,10 +56,14 @@ The following is a breakdown of sections and classes for this cbdc-module:
54
56
55
57
## Networking
56
58
* Networking
57
-
-broadcastTx(port, host, signedTxHex) - ```broadcast a signedTxBuf to a sentinel server at host {host} and port {port} number```
59
+
-broadcast(port, host, payloadHex, reqType) - ```Broadcast a payload to a (sentinel/coordinator/shard) and returns a promise that resolves to response```
58
60
- port - {number} port number of host
59
-
- host - {string} hostname url to send signedTx
60
-
- signedTxHex - {string} a valid hexadecimal encoded transaction that has been signed
61
+
- host - {string} hostname or url to send payloadHex
62
+
- payloadHex - {string} a valid hexadecimal encoded message, could be signed tx or compact tx or any other message
63
+
- reqType - {number|null} indicates type of request. can be null for no request type and for others:
64
+
- sentinel: 0=execute, 1=validate
65
+
- shard (read-only endpoint): 0=UHS, 1=tx
66
+
- coordinator doesn't have request type
61
67
62
68
## Transaction
63
69
- Input
@@ -67,20 +73,9 @@ The following is a breakdown of sections and classes for this cbdc-module:
67
73
- witnessProgramCommitment {String} - witness commitment for this input
68
74
- value {number} - the number of dollar units this input is worth
69
75
- writeInputToBuffer() - ```returns Buffer representation as buffer type```
70
-
- getUHSHash() - ```returns {Buffer} Universal Hash Set hash of the input e.g. concatentation of [txid, index, witnessProgramCommitment, value] into bytes```
71
-
e.g.
76
+
- getUHSHash() - ```returns {Buffer} Universal Hash Set hash of the input i.e. concatenation of [txid, index, witnessProgramCommitment, value] into bytes```
- verify(publicKey, message, signature) ```returns true or false whether the produced signature is validly signed publicKey```
80
-
- publicKey - 32 byte hexadecimal string
81
-
- message - message to verify was signed
82
-
- signature - {String} signature to verify validly signed message against public key message pair
83
-
84
79
*N.B.:* A hash is used to identify a specfic UTXO within the monetary supply (the UHS ID); it is a concatenation of a txid, a 64-bit index of the UTXO's position in previous tx's outputs, a witnessProgramCommitment, and the 64-bit encoded value of that output
85
80
86
81
- Output
@@ -99,11 +94,23 @@ The following is a breakdown of sections and classes for this cbdc-module:
99
94
- outputs - Array{Output}
100
95
- witnesses - Array of witness object
101
96
- toHex() - ```returns {String} hexadecimal string of the unsigned raw transaction```
97
+
- getCompactHex(sentinelAttestation) - ```returns {String} compact-tx in hexadecimal format with given sentinel attestations```
102
98
- getTxid() - ```returns {String} returns hexadecimal string of transaction id (txid)```
103
99
- sign(secretKey) - ```returns {Buffer} signed tx in bytes```
104
100
- static txFromHex(rawHex) - ```returns {Transaction} object from the provided rawTx```
105
101
- rawHex - valid hexadecimal string represents a valid tx
106
102
103
+
## Utils
104
+
- Utility Methods CBDC module
105
+
- sign(secretKey, message) - ```returns signature that signed message {message} with privateKey {privateKey}```
console.log(await Comms.broadcast(SHARD_PORT, SHARD_IP, input.getUHSHash(), 0)); // input UHS doesn't exists, so output will be 0100
208
+
console.log(await Comms.broadcast(COORD_PORT, COORD_IP, mint_tx.getCompactHex([sentinel_attest]), null)); // okay mint result will be 0101
209
+
console.log(await Comms.broadcast(SHARD_PORT, SHARD_IP, input.getUHSHash(), 0)); // input UHS will exist and output will be 0101
210
+
211
+
const output22 = new Output(witness2, 20); // pay 20 to user2
212
+
const output21 = new Output(witness1, 30); // take 30 back as change
213
+
const transferTx = new Transaction([input], [output22, output21], []);
214
+
const input21 = new Input(transferTx.getTxid(), 1, witness1, 30);
215
+
transferTx.sign(user1_sk.toHex());
216
+
console.log(await Comms.broadcast(SHARD_PORT, SHARD_IP, input21.getUHSHash(), 0)); // input21 UHS doesn't exists, so output will be 0100
217
+
console.log(await Comms.broadcast(SENTINEL_PORT, SENTINEL_IP, transferTx.toHex(), 0)); // output for successful transfer = 01 00 03 00 00 00 00
218
+
console.log(await Comms.broadcast(SHARD_PORT, SHARD_IP, input21.getUHSHash(), 0)); // input21 UHS exists after successful transfer, so output will be 0101
0 commit comments