gitmark 0.0.62 → 0.0.65
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/git-mark-list +23 -11
- package/package.json +1 -1
package/bin/git-mark-list
CHANGED
|
@@ -21,6 +21,13 @@ globalThis.data = {
|
|
|
21
21
|
// console.log('data', data)
|
|
22
22
|
|
|
23
23
|
// FUNCTIONS
|
|
24
|
+
function buf2hex(buffer) {
|
|
25
|
+
// buffer is an ArrayBuffer
|
|
26
|
+
return [...new Uint8Array(buffer)]
|
|
27
|
+
.map(x => x.toString(16).padStart(2, '0'))
|
|
28
|
+
.join('')
|
|
29
|
+
}
|
|
30
|
+
|
|
24
31
|
const BITMARK = {
|
|
25
32
|
messagePrefix: '\x19BITMARK Signed Message:\n',
|
|
26
33
|
bech32: 'btm',
|
|
@@ -56,12 +63,6 @@ function addCryptoToCommit(commit) {
|
|
|
56
63
|
)
|
|
57
64
|
commit.wifkey = keyPair1.toWIF()
|
|
58
65
|
|
|
59
|
-
function buf2hex(buffer) {
|
|
60
|
-
// buffer is an ArrayBuffer
|
|
61
|
-
return [...new Uint8Array(buffer)]
|
|
62
|
-
.map(x => x.toString(16).padStart(2, '0'))
|
|
63
|
-
.join('')
|
|
64
|
-
}
|
|
65
66
|
|
|
66
67
|
commit.pubkey = buf2hex(keyPair1.publicKey).substring(2)
|
|
67
68
|
// console.log('private key WIF:', keyPair1.toWIF())
|
|
@@ -82,13 +83,14 @@ function addCryptoToCommit(commit) {
|
|
|
82
83
|
|
|
83
84
|
function renderCommit(commit, type) {
|
|
84
85
|
if (!commit) return
|
|
86
|
+
commit.tags = commit.tags || []
|
|
85
87
|
if (type === 'nostr') {
|
|
86
|
-
var canon = [0, commit.pubkey, commit.authorDate, 17,
|
|
88
|
+
var canon = [0, commit.pubkey, commit.authorDate, 17, commit.tags, commit.hash]
|
|
87
89
|
|
|
88
|
-
canon = JSON.stringify(canon)
|
|
90
|
+
canon = JSON.stringify(canon).replace(/\\"/g, '"')
|
|
89
91
|
var id = sha256(canon)
|
|
90
92
|
|
|
91
|
-
console.log(canon)
|
|
93
|
+
// console.log(canon)
|
|
92
94
|
|
|
93
95
|
// sign
|
|
94
96
|
const KIND_CODE = 17
|
|
@@ -101,7 +103,7 @@ function renderCommit(commit, type) {
|
|
|
101
103
|
// console.log(sig)
|
|
102
104
|
// var sig = 1
|
|
103
105
|
|
|
104
|
-
var event = `["EVENT",{"id":"${id}","pubkey":"${commit.pubkey}","created_at":${commit.authorDate},"kind":${KIND_CODE},"tags"
|
|
106
|
+
var event = `["EVENT",{"id":"${id}","pubkey":"${commit.pubkey}","created_at":${commit.authorDate},"kind":${KIND_CODE},"tags":${JSON.stringify(commit.tags)},"content":"${commit.hash}","sig":"${sig}"}]`
|
|
105
107
|
|
|
106
108
|
console.log(event)
|
|
107
109
|
} else {
|
|
@@ -135,6 +137,7 @@ function getPrivKey() {
|
|
|
135
137
|
|
|
136
138
|
// INIT
|
|
137
139
|
data.privkey = argv._[0] || getPrivKey() || data.privkey
|
|
140
|
+
data.g = argv.g
|
|
138
141
|
data.count = argv.count
|
|
139
142
|
|
|
140
143
|
var POINT = Buffer.from(data.privkey, 'hex')
|
|
@@ -153,11 +156,20 @@ var b3
|
|
|
153
156
|
// genesis
|
|
154
157
|
var genesis = require('../gitmark.json')
|
|
155
158
|
var genesisCommit = {
|
|
156
|
-
"pubkey": genesis.pubkey,
|
|
157
159
|
"hash": "genesis",
|
|
158
160
|
"authorDate": genesis.created_at,
|
|
159
161
|
"privkey": b1.toString(16)
|
|
160
162
|
}
|
|
163
|
+
var keyPair1 = bitcoin.ECPair.fromPrivateKey(
|
|
164
|
+
Buffer.from(b1.toString(16), 'hex'),
|
|
165
|
+
{ network: BITMARK }
|
|
166
|
+
)
|
|
167
|
+
genesisCommit.pubkey = buf2hex(keyPair1.publicKey).substring(2)
|
|
168
|
+
if (data.g) {
|
|
169
|
+
genesisCommit.tags = [["g", data.g]]
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
|
|
161
173
|
// console.log('genesis', genesis)
|
|
162
174
|
// console.log('genesisCommit', genesisCommit)
|
|
163
175
|
if (!data.count) {
|