-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindex.js
90 lines (71 loc) · 2.08 KB
/
index.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/* Import modules. */
import { EventEmitter } from 'events'
/* Import (local) modules. */
import _buildCoins from './src/buildCoins.js'
import _getCoins from './src/getCoins.js'
import _getDustLimit from './src/getDustLimit.js'
import _sendCoins from './src/sendCoins.js'
/* Export (local) modules. */
export const buildCoins = _buildCoins
export const getCoins = _getCoins
export const getDustLimit = _getDustLimit
export const send = _sendCoins // alias
export const sendCoin = _sendCoins // alias
export const sendCoins = _sendCoins
/**
* Purse Class
*
* Manages individual unspent transaction outputs (UTXOs).
*/
export class Purse extends EventEmitter {
constructor(_params) {
/* Initialize Purse class. */
// console.info('Initializing Purse...')
// console.log(JSON.stringify(_params, null, 2))
super()
/* Validate parameters. */
if (!_params) {
throw new Error(`Oops! You MUST provide a seed to initialize a Purse.`)
}
/* Set private key. */
this._privateKey = _params?.privateKey
if (!this._privateKey) {
}
// TBD
}
get privateKey() {
return this._privateKey
}
set privateKey(_privateKey) {
this._privateKey = _privateKey
}
test() {
return 'Purse (Instance) is ready to GO!'
}
static test() {
return 'Purse (Static) is ready to GO!'
}
send(_params) {
return send(_params)
}
static send(_params) {
return send(_params)
}
}
/* Initialize (globalThis) Nexa class. */
const Nexa = {}
/* Initialize Purse class. */
Nexa.Purse = Purse
/* Initialize Purse modules. */
Nexa.buildCoins = buildCoins
Nexa.getCoins = getCoins
Nexa.getDustLimit = getDustLimit
// Nexa.send = send // alias (DEPRECATED NOTE: Managed by Wallet)
Nexa.sendCoin = sendCoins // alias
Nexa.sendCoins = sendCoins
/* Export Nexa to globalThis. */
// NOTE: We merge to avoid conflict with other libraries.
globalThis.Nexa = {
...globalThis.Nexa, // preserve Nexa object
...Nexa, // extend Nexa object
}