-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspartan-dark-tran-mint.js
51 lines (40 loc) · 1.4 KB
/
spartan-dark-tran-mint.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//COMPLETED
"use strict";
const { utils } = require('spartan-gold');
//const { ZeroTransaction } = require('./zero-transaction.js');
// String constants mixed in before hashing.
const TX_CONST = "TX";
//ASK: what does hash in spartan gold utils return? String or Buffer. needed to confirm type of cms
/**
* A mint transaction is required in the case of minitng new coin and is defined as a tuple (cm, v, *), where cm is a coin commitment, v is a coin value, and * is some extra information related to the transaction. Each transaction TranMint shows that a coin c with the coin commitment cm and the value v has been minted.
*
* @param {Buffer} cm
* @param {v} v
* @param {Array} info
*/
// HIGHLIGHTS: does not require signing, verify sign etc like the og transaction as the transactions
// are anonymous. So no sender validation reqd
class TranMint {
constructor ({cm, hashv, k, s}){
this.cm = cm;
this.hashv = hashv;
this.k = k;
this.s = s;
}
/**
* A transaction's ID is derived from its contents.
* Fetched from spartan-gold src
*/
// CITE: spartan-gold Transaction getID
get id() {
return utils.hash(TX_CONST + JSON.stringify({
cm: this.cm,
v: this.hashv,
k: this.k,
s: this.s
// no transaction fee during minting reqd
//fee: this.fee,
}));
}
}
module.exports.TranMint = TranMint;