Merge branch 'master' into cleanup-20240306

This commit is contained in:
QuickMythril
2024-05-15 01:32:51 -04:00
committed by GitHub
411 changed files with 92412 additions and 92852 deletions

View File

@@ -1,9 +1,9 @@
import {Sha256} from 'asmcrypto.js'
import { Sha256 } from 'asmcrypto.js'
import Base58 from './api/deps/Base58'
import Base64 from './api/deps/Base64'
import {base58PublicKeyToAddress} from './api/wallet/base58PublicKeyToAddress'
import {validateAddress} from './api/wallet/validateAddress'
import {decryptChatMessage, decryptChatMessageBase64} from './api/transactions/chat/decryptChatMessage'
import { base58PublicKeyToAddress } from './api/wallet/base58PublicKeyToAddress'
import { validateAddress } from './api/wallet/validateAddress'
import { decryptChatMessage, decryptChatMessageBase64 } from './api/transactions/chat/decryptChatMessage'
import _ from 'lodash'
window.Sha256 = Sha256
@@ -15,8 +15,8 @@ window.validateAddress = validateAddress
window.decryptChatMessage = decryptChatMessage
window.decryptChatMessageBase64 = decryptChatMessageBase64
export { initApi, store } from './api_deps.js'
export * from './api/deps/deps.js'
export * from './api/api.js'
export * from './api/registerUsername.js'
export { createWallet } from './api/createWallet.js'
export { initApi, store } from './api_deps'
export * from './api/deps/deps'
export * from './api/api'
export * from './api/registerUsername'
export { createWallet } from './api/createWallet'

View File

@@ -1,15 +1,12 @@
/*
Copyright 2017-2018 @ irontiga and vbcs (original developer)
*/
'use strict'
import Base58 from './deps/Base58.js'
import {Sha256, Sha512} from 'asmcrypto.js'
import nacl from './deps/nacl-fast.js'
import utils from './deps/utils.js'
import {generateSaveWalletData} from './storeWallet.js'
import publicKeyToAddress from './wallet/publicKeyToAddress.js'
import Base58 from './deps/Base58'
import { Sha256, Sha512 } from 'asmcrypto.js'
import nacl from './deps/nacl-fast'
import utils from './deps/utils'
import { generateSaveWalletData } from './storeWallet'
import publicKeyToAddress from './wallet/publicKeyToAddress'
import AltcoinHDWallet from "./bitcoin/AltcoinHDWallet"
export default class PhraseWallet {

View File

@@ -1,5 +1,5 @@
export { request } from './fetch-request.js'
export { transactionTypes as transactions } from './transactions/transactions.js'
export { processTransaction, processTransactionVersion2, createTransaction, computeChatNonce, signChatTransaction, signArbitraryTransaction, signArbitraryWithFeeTransaction } from './createTransaction.js'
export { tradeBotCreateRequest, tradeBotRespondRequest, signTradeBotTxn, deleteTradeOffer, sendBtc, sendLtc, sendDoge, sendDgb, sendRvn, sendArrr } from './tradeRequest.js'
export { cancelAllOffers } from './transactions/trade-portal/tradeoffer/cancelAllOffers.js'
export { request } from './fetch-request'
export { transactionTypes as transactions } from './transactions/transactions'
export { processTransaction, processTransactionVersion2, createTransaction, computeChatNonce, signChatTransaction, signArbitraryTransaction, signArbitraryWithFeeTransaction } from './createTransaction'
export { tradeBotCreateRequest, tradeBotRespondRequest, signTradeBotTxn, deleteTradeOffer, sendBtc, sendLtc, sendDoge, sendDgb, sendRvn, sendArrr } from './tradeRequest'
export { cancelAllOffers } from './transactions/trade-portal/tradeoffer/cancelAllOffers'

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,3 @@
'use strict'
// Qortal TX types
const TX_TYPES = {
1: "Genesis",

View File

@@ -1,10 +1,9 @@
import {transactionTypes as transactions} from './transactions/transactions.js'
import Base58 from './deps/Base58.js'
import {request} from './fetch-request'
import signChat from './transactions/chat/signChat.js'
import signArbitrary from './transactions/arbitrary/signArbitrary.js'
import signArbitraryWithFee from './transactions/arbitrary/signArbitraryWithFee.js'
import { transactionTypes as transactions } from './transactions/transactions'
import Base58 from './deps/Base58'
import { request } from './fetch-request'
import signChat from './transactions/chat/signChat'
import signArbitrary from './transactions/arbitrary/signArbitrary'
import signArbitraryWithFee from './transactions/arbitrary/signArbitraryWithFee'
export const createTransaction = (type, keyPair, params) => {
const tx = new transactions[type]()
@@ -32,12 +31,10 @@ export const signArbitraryTransaction = (arbitraryBytesBase58, arbitraryBytesFor
return signArbitrary(arbitraryBytesBase58, arbitraryBytesForSigningBase58, nonce, keyPair)
}
export const signArbitraryWithFeeTransaction = (arbitraryBytesBase58, arbitraryBytesForSigningBase58, keyPair) => {
return signArbitraryWithFee(arbitraryBytesBase58, arbitraryBytesForSigningBase58, keyPair)
export const signArbitraryWithFeeTransaction = (arbitraryBytesBase58, arbitraryBytesForSigningBase58, keyPair) => {
return signArbitraryWithFee(arbitraryBytesBase58, arbitraryBytesForSigningBase58, keyPair)
}
// Process Transactions
export const processTransaction = bytes => request('/transactions/process', {
method: 'POST',

View File

@@ -1,7 +1,7 @@
import {kdf} from './kdf.js'
import PhraseWallet from './PhraseWallet.js'
import Base58 from './deps/Base58.js'
import {decryptStoredWallet} from './decryptStoredWallet.js'
import { kdf } from './kdf'
import PhraseWallet from './PhraseWallet'
import Base58 from './deps/Base58'
import { decryptStoredWallet } from './decryptStoredWallet'
export const createWallet = async (sourceType, source, statusUpdateFn) => {
let version, seed

View File

@@ -1,10 +1,10 @@
import Base58 from './deps/Base58.js'
import {kdf} from './kdf.js'
import {AES_CBC, HmacSha512} from 'asmcrypto.js'
import {get, registerTranslateConfig} from '../../core/translate'
import Base58 from './deps/Base58'
import { kdf } from './kdf'
import { AES_CBC, HmacSha512 } from 'asmcrypto.js'
import { get, registerTranslateConfig } from '../../core/translate'
registerTranslateConfig({
loader: lang => fetch(`/language/${lang}.json`).then(res => res.json())
loader: lang => fetch(`/language/${lang}.json`).then(res => res.json())
})
export const decryptStoredWallet = async (password, wallet, statusFn = () => { }) => {

View File

@@ -1,10 +1,6 @@
// Generated by CoffeeScript 1.8.0
// == Changed for ES6 modules == //
//(function() {
//var ALPHABET, ALPHABET_MAP, Base58, i;
//const Base58 = (typeof module !== "undefined" && module !== null ? module.exports : void 0) || (window.Base58 = {});
const Base58 = {};
const ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
@@ -14,95 +10,92 @@ const ALPHABET_MAP = {};
let i = 0;
while (i < ALPHABET.length) {
ALPHABET_MAP[ALPHABET.charAt(i)] = i;
i++;
ALPHABET_MAP[ALPHABET.charAt(i)] = i;
i++;
}
Base58.encode = function(buffer) {
buffer = new Uint8Array(buffer);
var carry, digits, j;
if (buffer.length === 0) {
return "";
}
i = void 0;
j = void 0;
digits = [0];
i = 0;
while (i < buffer.length) {
j = 0;
while (j < digits.length) {
digits[j] <<= 8;
j++;
}
digits[0] += buffer[i];
carry = 0;
j = 0;
while (j < digits.length) {
digits[j] += carry;
carry = (digits[j] / 58) | 0;
digits[j] %= 58;
++j;
}
while (carry) {
digits.push(carry % 58);
carry = (carry / 58) | 0;
}
i++;
}
i = 0;
while (buffer[i] === 0 && i < buffer.length - 1) {
digits.push(0);
i++;
}
return digits.reverse().map(function(digit) {
return ALPHABET[digit];
}).join("");
Base58.encode = function (buffer) {
buffer = new Uint8Array(buffer);
var carry, digits, j;
if (buffer.length === 0) {
return "";
}
i = void 0;
j = void 0;
digits = [0];
i = 0;
while (i < buffer.length) {
j = 0;
while (j < digits.length) {
digits[j] <<= 8;
j++;
}
digits[0] += buffer[i];
carry = 0;
j = 0;
while (j < digits.length) {
digits[j] += carry;
carry = (digits[j] / 58) | 0;
digits[j] %= 58;
++j;
}
while (carry) {
digits.push(carry % 58);
carry = (carry / 58) | 0;
}
i++;
}
i = 0;
while (buffer[i] === 0 && i < buffer.length - 1) {
digits.push(0);
i++;
}
return digits.reverse().map(function (digit) {
return ALPHABET[digit];
}).join("");
};
Base58.decode = function(string) {
var bytes, c, carry, j;
if (string.length === 0) {
return new (typeof Uint8Array !== "undefined" && Uint8Array !== null ? Uint8Array : Buffer)(0);
}
i = void 0;
j = void 0;
bytes = [0];
i = 0;
while (i < string.length) {
c = string[i];
if (!(c in ALPHABET_MAP)) {
throw "Base58.decode received unacceptable input. Character '" + c + "' is not in the Base58 alphabet.";
}
j = 0;
while (j < bytes.length) {
bytes[j] *= 58;
j++;
}
bytes[0] += ALPHABET_MAP[c];
carry = 0;
j = 0;
while (j < bytes.length) {
bytes[j] += carry;
carry = bytes[j] >> 8;
bytes[j] &= 0xff;
++j;
}
while (carry) {
bytes.push(carry & 0xff);
carry >>= 8;
}
i++;
}
i = 0;
while (string[i] === "1" && i < string.length - 1) {
bytes.push(0);
i++;
}
return new (typeof Uint8Array !== "undefined" && Uint8Array !== null ? Uint8Array : Buffer)(bytes.reverse());
Base58.decode = function (string) {
var bytes, c, carry, j;
if (string.length === 0) {
return new (typeof Uint8Array !== "undefined" && Uint8Array !== null ? Uint8Array : Buffer)(0);
}
i = void 0;
j = void 0;
bytes = [0];
i = 0;
while (i < string.length) {
c = string[i];
if (!(c in ALPHABET_MAP)) {
throw "Base58.decode received unacceptable input. Character '" + c + "' is not in the Base58 alphabet.";
}
j = 0;
while (j < bytes.length) {
bytes[j] *= 58;
j++;
}
bytes[0] += ALPHABET_MAP[c];
carry = 0;
j = 0;
while (j < bytes.length) {
bytes[j] += carry;
carry = bytes[j] >> 8;
bytes[j] &= 0xff;
++j;
}
while (carry) {
bytes.push(carry & 0xff);
carry >>= 8;
}
i++;
}
i = 0;
while (string[i] === "1" && i < string.length - 1) {
bytes.push(0);
i++;
}
return new (typeof Uint8Array !== "undefined" && Uint8Array !== null ? Uint8Array : Buffer)(bytes.reverse());
};
// == Changed for ES6 modules == //
//}).call(this);
export default Base58;
export default Base58;

View File

@@ -1,23 +1,18 @@
const Base64 = {};
Base64.decode = function (string) {
const binaryString = atob(string);
const binaryLength = binaryString.length;
const bytes = new Uint8Array(binaryLength);
const binaryString = atob(string);
const binaryLength = binaryString.length;
const bytes = new Uint8Array(binaryLength);
for (let i = 0; i < binaryLength; i++) {
bytes[i] = binaryString.charCodeAt(i);
}
for (let i = 0; i < binaryLength; i++) {
bytes[i] = binaryString.charCodeAt(i);
}
const decoder = new TextDecoder();
const decoder = new TextDecoder();
return decoder.decode(bytes);
};
export default Base64;

File diff suppressed because it is too large Load Diff

View File

@@ -1,180 +1,179 @@
// "Generated from Java with JSweet 1.0.0 - http://www.jsweet.org";
// BAD IMPLEMENTATION. BROKEN, BUT MUST KEEP CAUSE OF NETWORK
//const RIPEMD160 = (function () {
// == Convert to ES6 module for export == //
const RIPEMD160 = (function () {
function RIPEMD160() {
this.MDbuf = [];
this.MDbuf[0] = 1732584193;
this.MDbuf[1] = -271733879;
this.MDbuf[2] = -1732584194;
this.MDbuf[3] = 271733878;
this.MDbuf[4] = -1009589776;
this.working = new Int32Array(16);
function RIPEMD160() {
this.MDbuf = [];
this.MDbuf[0] = 1732584193;
this.MDbuf[1] = -271733879;
this.MDbuf[2] = -1732584194;
this.MDbuf[3] = 271733878;
this.MDbuf[4] = -1009589776;
this.working = new Int32Array(16);
this.working_ptr = 0;
this.msglen = 0;
}
RIPEMD160.prototype.reset = function () {
this.MDbuf = [];
this.MDbuf[0] = 1732584193;
this.MDbuf[1] = -271733879;
this.MDbuf[2] = -1732584194;
this.MDbuf[3] = 271733878;
this.MDbuf[4] = -1009589776;
this.working = new Int32Array(16);
this.working_ptr = 0;
this.msglen = 0;
};
RIPEMD160.prototype.compress = function (X) {
var index = 0;
var a;
var b;
var c;
var d;
var e;
var A;
var B;
var C;
var D;
var E;
var temp;
var s;
A = a = this.MDbuf[0];
B = b = this.MDbuf[1];
C = c = this.MDbuf[2];
D = d = this.MDbuf[3];
E = e = this.MDbuf[4];
for (; index < 16; index++) {
temp = a + (b ^ c ^ d) + X[RIPEMD160.IndexArray[0][index]];
a = e;
e = d;
d = (c << 10) | (c >>> 22);
c = b;
s = RIPEMD160.ArgArray[0][index];
b = ((temp << s) | (temp >>> (32 - s))) + a;
temp = A + (B ^ (C | ~D)) + X[RIPEMD160.IndexArray[1][index]] + 1352829926;
A = E;
E = D;
D = (C << 10) | (C >>> 22);
C = B;
s = RIPEMD160.ArgArray[1][index];
B = ((temp << s) | (temp >>> (32 - s))) + A;
}
for (; index < 32; index++) {
temp = a + ((b & c) | (~b & d)) + X[RIPEMD160.IndexArray[0][index]] + 1518500249;
a = e;
e = d;
d = (c << 10) | (c >>> 22);
c = b;
s = RIPEMD160.ArgArray[0][index];
b = ((temp << s) | (temp >>> (32 - s))) + a;
temp = A + ((B & D) | (C & ~D)) + X[RIPEMD160.IndexArray[1][index]] + 1548603684;
A = E;
E = D;
D = (C << 10) | (C >>> 22);
C = B;
s = RIPEMD160.ArgArray[1][index];
B = ((temp << s) | (temp >>> (32 - s))) + A;
}
for (; index < 48; index++) {
temp = a + ((b | ~c) ^ d) + X[RIPEMD160.IndexArray[0][index]] + 1859775393;
a = e;
e = d;
d = (c << 10) | (c >>> 22);
c = b;
s = RIPEMD160.ArgArray[0][index];
b = ((temp << s) | (temp >>> (32 - s))) + a;
temp = A + ((B | ~C) ^ D) + X[RIPEMD160.IndexArray[1][index]] + 1836072691;
A = E;
E = D;
D = (C << 10) | (C >>> 22);
C = B;
s = RIPEMD160.ArgArray[1][index];
B = ((temp << s) | (temp >>> (32 - s))) + A;
}
for (; index < 64; index++) {
temp = a + ((b & d) | (c & ~d)) + X[RIPEMD160.IndexArray[0][index]] + -1894007588;
a = e;
e = d;
d = (c << 10) | (c >>> 22);
c = b;
s = RIPEMD160.ArgArray[0][index];
b = ((temp << s) | (temp >>> (32 - s))) + a;
temp = A + ((B & C) | (~B & D)) + X[RIPEMD160.IndexArray[1][index]] + 2053994217;
A = E;
E = D;
D = (C << 10) | (C >>> 22);
C = B;
s = RIPEMD160.ArgArray[1][index];
B = ((temp << s) | (temp >>> (32 - s))) + A;
}
for (; index < 80; index++) {
temp = a + (b ^ (c | ~d)) + X[RIPEMD160.IndexArray[0][index]] + -1454113458;
a = e;
e = d;
d = (c << 10) | (c >>> 22);
c = b;
s = RIPEMD160.ArgArray[0][index];
b = ((temp << s) | (temp >>> (32 - s))) + a;
temp = A + (B ^ C ^ D) + X[RIPEMD160.IndexArray[1][index]];
A = E;
E = D;
D = (C << 10) | (C >>> 22);
C = B;
s = RIPEMD160.ArgArray[1][index];
B = ((temp << s) | (temp >>> (32 - s))) + A;
}
D += c + this.MDbuf[1];
this.MDbuf[1] = this.MDbuf[2] + d + E;
this.MDbuf[2] = this.MDbuf[3] + e + A;
this.MDbuf[3] = this.MDbuf[4] + a + B;
this.MDbuf[4] = this.MDbuf[0] + b + C;
this.MDbuf[0] = D;
};
RIPEMD160.prototype.MDfinish = function (array, lswlen, mswlen) {
var X = array;
X[(lswlen >> 2) & 15] ^= 1 << (((lswlen & 3) << 3) + 7);
if (((lswlen & 63) > 55)) {
this.compress(X);
for (var i = 0; i < 14; i++) {
X[i] = 0;
}
}
X[14] = lswlen << 3;
X[15] = (lswlen >> 29) | (mswlen << 3);
this.compress(X);
};
RIPEMD160.prototype.update = function (input) {
for (var i = 0; i < input.length; i++) {
this.working[this.working_ptr >> 2] ^= input[i] << ((this.working_ptr & 3) << 3);
this.working_ptr++;
if ((this.working_ptr == 64)) {
this.compress(this.working);
for (var j = 0; j < 16; j++) {
this.working[j] = 0;
}
this.working_ptr = 0;
}
}
this.msglen += input.length;
};
RIPEMD160.prototype.digestBin = function () {
this.MDfinish(this.working, this.msglen, 0);
//var res = new Int8Array();
var res = [];
for (var i = 0; i < 20; i++) {
res[i] = ((this.MDbuf[i >> 2] >>> ((i & 3) << 3)) & 255);
}
return new Uint8Array(res);
};
RIPEMD160.prototype.digest = function (input) {
this.update(new Int8Array(input));
return this.digestBin();
};
RIPEMD160.ArgArray = [[11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8, 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12, 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5, 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12, 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6], [8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6, 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11, 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5, 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8, 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11]];
RIPEMD160.IndexArray = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8, 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12, 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2, 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13], [5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12, 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2, 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13, 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14, 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11]];
return RIPEMD160;
this.working_ptr = 0;
this.msglen = 0;
}
RIPEMD160.prototype.reset = function () {
this.MDbuf = [];
this.MDbuf[0] = 1732584193;
this.MDbuf[1] = -271733879;
this.MDbuf[2] = -1732584194;
this.MDbuf[3] = 271733878;
this.MDbuf[4] = -1009589776;
this.working = new Int32Array(16);
this.working_ptr = 0;
this.msglen = 0;
};
RIPEMD160.prototype.compress = function (X) {
var index = 0;
var a;
var b;
var c;
var d;
var e;
var A;
var B;
var C;
var D;
var E;
var temp;
var s;
A = a = this.MDbuf[0];
B = b = this.MDbuf[1];
C = c = this.MDbuf[2];
D = d = this.MDbuf[3];
E = e = this.MDbuf[4];
for (; index < 16; index++) {
temp = a + (b ^ c ^ d) + X[RIPEMD160.IndexArray[0][index]];
a = e;
e = d;
d = (c << 10) | (c >>> 22);
c = b;
s = RIPEMD160.ArgArray[0][index];
b = ((temp << s) | (temp >>> (32 - s))) + a;
temp = A + (B ^ (C | ~D)) + X[RIPEMD160.IndexArray[1][index]] + 1352829926;
A = E;
E = D;
D = (C << 10) | (C >>> 22);
C = B;
s = RIPEMD160.ArgArray[1][index];
B = ((temp << s) | (temp >>> (32 - s))) + A;
}
for (; index < 32; index++) {
temp = a + ((b & c) | (~b & d)) + X[RIPEMD160.IndexArray[0][index]] + 1518500249;
a = e;
e = d;
d = (c << 10) | (c >>> 22);
c = b;
s = RIPEMD160.ArgArray[0][index];
b = ((temp << s) | (temp >>> (32 - s))) + a;
temp = A + ((B & D) | (C & ~D)) + X[RIPEMD160.IndexArray[1][index]] + 1548603684;
A = E;
E = D;
D = (C << 10) | (C >>> 22);
C = B;
s = RIPEMD160.ArgArray[1][index];
B = ((temp << s) | (temp >>> (32 - s))) + A;
}
for (; index < 48; index++) {
temp = a + ((b | ~c) ^ d) + X[RIPEMD160.IndexArray[0][index]] + 1859775393;
a = e;
e = d;
d = (c << 10) | (c >>> 22);
c = b;
s = RIPEMD160.ArgArray[0][index];
b = ((temp << s) | (temp >>> (32 - s))) + a;
temp = A + ((B | ~C) ^ D) + X[RIPEMD160.IndexArray[1][index]] + 1836072691;
A = E;
E = D;
D = (C << 10) | (C >>> 22);
C = B;
s = RIPEMD160.ArgArray[1][index];
B = ((temp << s) | (temp >>> (32 - s))) + A;
}
for (; index < 64; index++) {
temp = a + ((b & d) | (c & ~d)) + X[RIPEMD160.IndexArray[0][index]] + -1894007588;
a = e;
e = d;
d = (c << 10) | (c >>> 22);
c = b;
s = RIPEMD160.ArgArray[0][index];
b = ((temp << s) | (temp >>> (32 - s))) + a;
temp = A + ((B & C) | (~B & D)) + X[RIPEMD160.IndexArray[1][index]] + 2053994217;
A = E;
E = D;
D = (C << 10) | (C >>> 22);
C = B;
s = RIPEMD160.ArgArray[1][index];
B = ((temp << s) | (temp >>> (32 - s))) + A;
}
for (; index < 80; index++) {
temp = a + (b ^ (c | ~d)) + X[RIPEMD160.IndexArray[0][index]] + -1454113458;
a = e;
e = d;
d = (c << 10) | (c >>> 22);
c = b;
s = RIPEMD160.ArgArray[0][index];
b = ((temp << s) | (temp >>> (32 - s))) + a;
temp = A + (B ^ C ^ D) + X[RIPEMD160.IndexArray[1][index]];
A = E;
E = D;
D = (C << 10) | (C >>> 22);
C = B;
s = RIPEMD160.ArgArray[1][index];
B = ((temp << s) | (temp >>> (32 - s))) + A;
}
D += c + this.MDbuf[1];
this.MDbuf[1] = this.MDbuf[2] + d + E;
this.MDbuf[2] = this.MDbuf[3] + e + A;
this.MDbuf[3] = this.MDbuf[4] + a + B;
this.MDbuf[4] = this.MDbuf[0] + b + C;
this.MDbuf[0] = D;
};
RIPEMD160.prototype.MDfinish = function (array, lswlen, mswlen) {
var X = array;
X[(lswlen >> 2) & 15] ^= 1 << (((lswlen & 3) << 3) + 7);
if (((lswlen & 63) > 55)) {
this.compress(X);
for (var i = 0; i < 14; i++) {
X[i] = 0;
}
}
X[14] = lswlen << 3;
X[15] = (lswlen >> 29) | (mswlen << 3);
this.compress(X);
};
RIPEMD160.prototype.update = function (input) {
for (var i = 0; i < input.length; i++) {
this.working[this.working_ptr >> 2] ^= input[i] << ((this.working_ptr & 3) << 3);
this.working_ptr++;
if ((this.working_ptr == 64)) {
this.compress(this.working);
for (var j = 0; j < 16; j++) {
this.working[j] = 0;
}
this.working_ptr = 0;
}
}
this.msglen += input.length;
};
RIPEMD160.prototype.digestBin = function () {
this.MDfinish(this.working, this.msglen, 0);
//var res = new Int8Array();
var res = [];
for (var i = 0; i < 20; i++) {
res[i] = ((this.MDbuf[i >> 2] >>> ((i & 3) << 3)) & 255);
}
return new Uint8Array(res);
};
RIPEMD160.prototype.digest = function (input) {
this.update(new Int8Array(input));
return this.digestBin();
};
RIPEMD160.ArgArray = [[11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8, 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12, 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5, 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12, 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6], [8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6, 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11, 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5, 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8, 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11]];
RIPEMD160.IndexArray = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8, 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12, 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2, 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13], [5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12, 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2, 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13, 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14, 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11]];
return RIPEMD160;
})();
export default RIPEMD160

View File

@@ -1,3 +1,2 @@
export { default as Base58 } from './Base58.js'
export { default as utils } from './utils.js'
export { default as Base58 } from './Base58'
export { default as utils } from './utils'

View File

@@ -10,255 +10,239 @@
Change to es6 import/export
*/
import nacl from './nacl-fast.js'
import nacl from './nacl-fast'
// (function(root, f) {
// 'use strict';
// if (typeof module !== 'undefined' && module.exports) module.exports = f(require('tweetnacl'));
// else root.ed2curve = f(root.nacl);
// }(this, function(nacl) {
// 'use strict';
// if (!nacl) throw new Error('tweetnacl not loaded');
// -- Operations copied from TweetNaCl.js. --
// -- Operations copied from TweetNaCl.js. --
var gf = function (init) {
var i, r = new Float64Array(16);
if (init) for (i = 0; i < init.length; i++) r[i] = init[i];
return r;
};
var gf = function(init) {
var i, r = new Float64Array(16);
if (init) for (i = 0; i < init.length; i++) r[i] = init[i];
return r;
};
var gf0 = gf(),
gf1 = gf([1]),
D = gf([0x78a3, 0x1359, 0x4dca, 0x75eb, 0xd8ab, 0x4141, 0x0a4d, 0x0070, 0xe898, 0x7779, 0x4079, 0x8cc7, 0xfe73, 0x2b6f, 0x6cee, 0x5203]),
I = gf([0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43, 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83]);
var gf0 = gf(),
gf1 = gf([1]),
D = gf([0x78a3, 0x1359, 0x4dca, 0x75eb, 0xd8ab, 0x4141, 0x0a4d, 0x0070, 0xe898, 0x7779, 0x4079, 0x8cc7, 0xfe73, 0x2b6f, 0x6cee, 0x5203]),
I = gf([0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43, 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83]);
function car25519(o) {
var c;
var i;
for (i = 0; i < 16; i++) {
o[i] += 65536;
c = Math.floor(o[i] / 65536);
o[(i+1)*(i<15?1:0)] += c - 1 + 37 * (c-1) * (i===15?1:0);
o[i] -= (c * 65536);
}
}
function sel25519(p, q, b) {
var t, c = ~(b-1);
for (var i = 0; i < 16; i++) {
t = c & (p[i] ^ q[i]);
p[i] ^= t;
q[i] ^= t;
}
}
function unpack25519(o, n) {
var i;
for (i = 0; i < 16; i++) o[i] = n[2*i] + (n[2*i+1] << 8);
o[15] &= 0x7fff;
}
// addition
function A(o, a, b) {
var i;
for (i = 0; i < 16; i++) o[i] = (a[i] + b[i])|0;
}
// subtraction
function Z(o, a, b) {
var i;
for (i = 0; i < 16; i++) o[i] = (a[i] - b[i])|0;
}
// multiplication
function M(o, a, b) {
var i, j, t = new Float64Array(31);
for (i = 0; i < 31; i++) t[i] = 0;
for (i = 0; i < 16; i++) {
for (j = 0; j < 16; j++) {
t[i+j] += a[i] * b[j];
}
}
for (i = 0; i < 15; i++) {
t[i] += 38 * t[i+16];
}
for (i = 0; i < 16; i++) o[i] = t[i];
car25519(o);
car25519(o);
}
// squaring
function S(o, a) {
M(o, a, a);
}
// inversion
function inv25519(o, i) {
var c = gf();
var a;
for (a = 0; a < 16; a++) c[a] = i[a];
for (a = 253; a >= 0; a--) {
S(c, c);
if(a !== 2 && a !== 4) M(c, c, i);
}
for (a = 0; a < 16; a++) o[a] = c[a];
}
function pack25519(o, n) {
var i, j, b;
var m = gf(), t = gf();
for (i = 0; i < 16; i++) t[i] = n[i];
car25519(t);
car25519(t);
car25519(t);
for (j = 0; j < 2; j++) {
m[0] = t[0] - 0xffed;
for (i = 1; i < 15; i++) {
m[i] = t[i] - 0xffff - ((m[i-1]>>16) & 1);
m[i-1] &= 0xffff;
}
m[15] = t[15] - 0x7fff - ((m[14]>>16) & 1);
b = (m[15]>>16) & 1;
m[14] &= 0xffff;
sel25519(t, m, 1-b);
}
for (i = 0; i < 16; i++) {
o[2*i] = t[i] & 0xff;
o[2*i+1] = t[i] >> 8;
}
}
function par25519(a) {
var d = new Uint8Array(32);
pack25519(d, a);
return d[0] & 1;
}
function vn(x, xi, y, yi, n) {
var i, d = 0;
for (i = 0; i < n; i++) d |= x[xi + i] ^ y[yi + i];
return (1 & ((d - 1) >>> 8)) - 1;
}
function crypto_verify_32(x, xi, y, yi) {
return vn(x, xi, y, yi, 32);
}
function neq25519(a, b) {
var c = new Uint8Array(32), d = new Uint8Array(32);
pack25519(c, a);
pack25519(d, b);
return crypto_verify_32(c, 0, d, 0);
}
function pow2523(o, i) {
var c = gf();
var a;
for (a = 0; a < 16; a++) c[a] = i[a];
for (a = 250; a >= 0; a--) {
S(c, c);
if (a !== 1) M(c, c, i);
}
for (a = 0; a < 16; a++) o[a] = c[a];
}
function set25519(r, a) {
var i;
for (i = 0; i < 16; i++) r[i] = a[i] | 0;
}
function unpackneg(r, p) {
var t = gf(), chk = gf(), num = gf(),
den = gf(), den2 = gf(), den4 = gf(),
den6 = gf();
set25519(r[2], gf1);
unpack25519(r[1], p);
S(num, r[1]);
M(den, num, D);
Z(num, num, r[2]);
A(den, r[2], den);
S(den2, den);
S(den4, den2);
M(den6, den4, den2);
M(t, den6, num);
M(t, t, den);
pow2523(t, t);
M(t, t, num);
M(t, t, den);
M(t, t, den);
M(r[0], t, den);
S(chk, r[0]);
M(chk, chk, den);
if (neq25519(chk, num)) M(r[0], r[0], I);
S(chk, r[0]);
M(chk, chk, den);
if (neq25519(chk, num)) return -1;
if (par25519(r[0]) === (p[31] >> 7)) Z(r[0], gf0, r[0]);
M(r[3], r[0], r[1]);
return 0;
}
// ----
// Converts Ed25519 public key to Curve25519 public key.
// montgomeryX = (edwardsY + 1)*inverse(1 - edwardsY) mod p
function convertPublicKey(pk) {
var z = new Uint8Array(32),
q = [gf(), gf(), gf(), gf()],
a = gf(), b = gf();
if (unpackneg(q, pk)) return null; // reject invalid key
var y = q[1];
A(a, gf1, y);
Z(b, gf1, y);
inv25519(b, b);
M(a, a, b);
pack25519(z, a);
return z;
}
// Converts Ed25519 secret key to Curve25519 secret key.
function convertSecretKey(sk) {
var d = new Uint8Array(64), o = new Uint8Array(32), i;
nacl.lowlevel.crypto_hash(d, sk, 32);
d[0] &= 248;
d[31] &= 127;
d[31] |= 64;
for (i = 0; i < 32; i++) o[i] = d[i];
for (i = 0; i < 64; i++) d[i] = 0;
return o;
}
function convertKeyPair(edKeyPair) {
var publicKey = convertPublicKey(edKeyPair.publicKey);
if (!publicKey) return null;
return {
publicKey: publicKey,
secretKey: convertSecretKey(edKeyPair.secretKey)
};
}
// return {
// convertPublicKey: convertPublicKey,
// convertSecretKey: convertSecretKey,
// convertKeyPair: convertKeyPair,
// };
export default {
convertPublicKey: convertPublicKey,
convertSecretKey: convertSecretKey,
convertKeyPair: convertKeyPair,
function car25519(o) {
var c;
var i;
for (i = 0; i < 16; i++) {
o[i] += 65536;
c = Math.floor(o[i] / 65536);
o[(i + 1) * (i < 15 ? 1 : 0)] += c - 1 + 37 * (c - 1) * (i === 15 ? 1 : 0);
o[i] -= (c * 65536);
}
}
// }));
function sel25519(p, q, b) {
var t, c = ~(b - 1);
for (var i = 0; i < 16; i++) {
t = c & (p[i] ^ q[i]);
p[i] ^= t;
q[i] ^= t;
}
}
function unpack25519(o, n) {
var i;
for (i = 0; i < 16; i++) o[i] = n[2 * i] + (n[2 * i + 1] << 8);
o[15] &= 0x7fff;
}
// addition
function A(o, a, b) {
var i;
for (i = 0; i < 16; i++) o[i] = (a[i] + b[i]) | 0;
}
// subtraction
function Z(o, a, b) {
var i;
for (i = 0; i < 16; i++) o[i] = (a[i] - b[i]) | 0;
}
// multiplication
function M(o, a, b) {
var i, j, t = new Float64Array(31);
for (i = 0; i < 31; i++) t[i] = 0;
for (i = 0; i < 16; i++) {
for (j = 0; j < 16; j++) {
t[i + j] += a[i] * b[j];
}
}
for (i = 0; i < 15; i++) {
t[i] += 38 * t[i + 16];
}
for (i = 0; i < 16; i++) o[i] = t[i];
car25519(o);
car25519(o);
}
// squaring
function S(o, a) {
M(o, a, a);
}
// inversion
function inv25519(o, i) {
var c = gf();
var a;
for (a = 0; a < 16; a++) c[a] = i[a];
for (a = 253; a >= 0; a--) {
S(c, c);
if (a !== 2 && a !== 4) M(c, c, i);
}
for (a = 0; a < 16; a++) o[a] = c[a];
}
function pack25519(o, n) {
var i, j, b;
var m = gf(), t = gf();
for (i = 0; i < 16; i++) t[i] = n[i];
car25519(t);
car25519(t);
car25519(t);
for (j = 0; j < 2; j++) {
m[0] = t[0] - 0xffed;
for (i = 1; i < 15; i++) {
m[i] = t[i] - 0xffff - ((m[i - 1] >> 16) & 1);
m[i - 1] &= 0xffff;
}
m[15] = t[15] - 0x7fff - ((m[14] >> 16) & 1);
b = (m[15] >> 16) & 1;
m[14] &= 0xffff;
sel25519(t, m, 1 - b);
}
for (i = 0; i < 16; i++) {
o[2 * i] = t[i] & 0xff;
o[2 * i + 1] = t[i] >> 8;
}
}
function par25519(a) {
var d = new Uint8Array(32);
pack25519(d, a);
return d[0] & 1;
}
function vn(x, xi, y, yi, n) {
var i, d = 0;
for (i = 0; i < n; i++) d |= x[xi + i] ^ y[yi + i];
return (1 & ((d - 1) >>> 8)) - 1;
}
function crypto_verify_32(x, xi, y, yi) {
return vn(x, xi, y, yi, 32);
}
function neq25519(a, b) {
var c = new Uint8Array(32), d = new Uint8Array(32);
pack25519(c, a);
pack25519(d, b);
return crypto_verify_32(c, 0, d, 0);
}
function pow2523(o, i) {
var c = gf();
var a;
for (a = 0; a < 16; a++) c[a] = i[a];
for (a = 250; a >= 0; a--) {
S(c, c);
if (a !== 1) M(c, c, i);
}
for (a = 0; a < 16; a++) o[a] = c[a];
}
function set25519(r, a) {
var i;
for (i = 0; i < 16; i++) r[i] = a[i] | 0;
}
function unpackneg(r, p) {
var t = gf(), chk = gf(), num = gf(),
den = gf(), den2 = gf(), den4 = gf(),
den6 = gf();
set25519(r[2], gf1);
unpack25519(r[1], p);
S(num, r[1]);
M(den, num, D);
Z(num, num, r[2]);
A(den, r[2], den);
S(den2, den);
S(den4, den2);
M(den6, den4, den2);
M(t, den6, num);
M(t, t, den);
pow2523(t, t);
M(t, t, num);
M(t, t, den);
M(t, t, den);
M(r[0], t, den);
S(chk, r[0]);
M(chk, chk, den);
if (neq25519(chk, num)) M(r[0], r[0], I);
S(chk, r[0]);
M(chk, chk, den);
if (neq25519(chk, num)) return -1;
if (par25519(r[0]) === (p[31] >> 7)) Z(r[0], gf0, r[0]);
M(r[3], r[0], r[1]);
return 0;
}
// ----
// Converts Ed25519 public key to Curve25519 public key.
// montgomeryX = (edwardsY + 1)*inverse(1 - edwardsY) mod p
function convertPublicKey(pk) {
var z = new Uint8Array(32),
q = [gf(), gf(), gf(), gf()],
a = gf(), b = gf();
if (unpackneg(q, pk)) return null; // reject invalid key
var y = q[1];
A(a, gf1, y);
Z(b, gf1, y);
inv25519(b, b);
M(a, a, b);
pack25519(z, a);
return z;
}
// Converts Ed25519 secret key to Curve25519 secret key.
function convertSecretKey(sk) {
var d = new Uint8Array(64), o = new Uint8Array(32), i;
nacl.lowlevel.crypto_hash(d, sk, 32);
d[0] &= 248;
d[31] &= 127;
d[31] |= 64;
for (i = 0; i < 32; i++) o[i] = d[i];
for (i = 0; i < 64; i++) d[i] = 0;
return o;
}
function convertKeyPair(edKeyPair) {
var publicKey = convertPublicKey(edKeyPair.publicKey);
if (!publicKey) return null;
return {
publicKey: publicKey,
secretKey: convertSecretKey(edKeyPair.secretKey)
};
}
export default {
convertPublicKey: convertPublicKey,
convertSecretKey: convertSecretKey,
convertKeyPair: convertKeyPair,
}

File diff suppressed because it is too large Load Diff

View File

@@ -26,9 +26,8 @@ const TYPES = {
MESSAGE_TRANSACTION: 17
};
function getKeyPairFromSeed(seed, returnBase58)
{
if(typeof(seed) == "string") {
function getKeyPairFromSeed(seed, returnBase58) {
if (typeof (seed) == "string") {
seed = new Uint8Array(Base58.decode(seed));
}
@@ -36,7 +35,7 @@ function getKeyPairFromSeed(seed, returnBase58)
var base58privateKey = Base58.encode(keyPair.secretKey);
var base58publicKey = Base58.encode(keyPair.publicKey);
if(returnBase58) {
if (returnBase58) {
return {
privateKey: Base58.encode(keyPair.secretKey),
publicKey: Base58.encode(keyPair.publicKey)
@@ -51,16 +50,16 @@ function getKeyPairFromSeed(seed, returnBase58)
function stringtoUTF8Array(message) {
if (typeof message == 'string') {
var s = unescape(encodeURIComponent(message)); // UTF-8
message = new Uint8Array(s.length);
for (var i = 0; i < s.length; i++) {
var s = unescape(encodeURIComponent(message)); // UTF-8
message = new Uint8Array(s.length);
for (var i = 0; i < s.length; i++) {
message[i] = s.charCodeAt(i) & 0xff;
}
}
return message;
}
function int32ToBytes (word) {
function int32ToBytes(word) {
var byteArray = [];
for (var b = 0; b < 32; b += 8) {
byteArray.push((word >>> (24 - b % 32)) & 0xFF);
@@ -68,20 +67,20 @@ function int32ToBytes (word) {
return byteArray;
}
function int64ToBytes (int64) {
// we want to represent the input as a 8-bytes array
var byteArray = [0, 0, 0, 0, 0, 0, 0, 0];
function int64ToBytes(int64) {
// we want to represent the input as a 8-bytes array
var byteArray = [0, 0, 0, 0, 0, 0, 0, 0];
for ( var index = 0; index < byteArray.length; index ++ ) {
var byte = int64 & 0xff;
byteArray [ byteArray.length - index - 1 ] = byte;
int64 = (int64 - byte) / 256 ;
}
for (var index = 0; index < byteArray.length; index++) {
var byte = int64 & 0xff;
byteArray[byteArray.length - index - 1] = byte;
int64 = (int64 - byte) / 256;
}
return byteArray;
return byteArray;
}
function appendBuffer (buffer1, buffer2) {
function appendBuffer(buffer1, buffer2) {
buffer1 = new Uint8Array(buffer1);
buffer2 = new Uint8Array(buffer2);
var tmp = new Uint8Array(buffer1.byteLength + buffer2.byteLength);
@@ -90,21 +89,18 @@ function appendBuffer (buffer1, buffer2) {
return tmp;
}
function equal (buf1, buf2)
{
if (buf1.byteLength != buf2.byteLength) return false;
var dv1 = new Uint8Array(buf1);
var dv2 = new Uint8Array(buf2);
for (var i = 0; i != buf1.byteLength; i++)
{
if (dv1[i] != dv2[i]) return false;
}
return true;
function equal(buf1, buf2) {
if (buf1.byteLength != buf2.byteLength) return false;
var dv1 = new Uint8Array(buf1);
var dv2 = new Uint8Array(buf2);
for (var i = 0; i != buf1.byteLength; i++) {
if (dv1[i] != dv2[i]) return false;
}
return true;
}
function generateAccountSeed(seed, nonce, returnBase58)
{
if(typeof(seed) == "string") {
function generateAccountSeed(seed, nonce, returnBase58) {
if (typeof (seed) == "string") {
seed = Base58.decode(seed);
}
@@ -116,7 +112,7 @@ function generateAccountSeed(seed, nonce, returnBase58)
resultSeed = appendBuffer(resultSeed, seed);
resultSeed = appendBuffer(resultSeed, nonceBytes);
if(returnBase58) {
if (returnBase58) {
return Base58.encode(SHA256.digest(SHA256.digest(resultSeed)));
} else {
return new SHA256.digest(SHA256.digest(resultSeed));
@@ -124,11 +120,10 @@ function generateAccountSeed(seed, nonce, returnBase58)
}
function getAccountAddressFromPublicKey(publicKey)
{
function getAccountAddressFromPublicKey(publicKey) {
var ADDRESS_VERSION = 58; // Q
if(typeof(publicKey) == "string") {
if (typeof (publicKey) == "string") {
publicKey = Base58.decode(publicKey);
}
@@ -150,13 +145,12 @@ function getAccountAddressFromPublicKey(publicKey)
return Base58.encode(addressArray);
}
function getAccountAddressType(address)
{
function getAccountAddressType(address) {
try {
var ADDRESS_VERSION = 58; // Q
var AT_ADDRESS_VERSION = 23; // A
if(typeof(address) == "string") {
if (typeof (address) == "string") {
address = Base58.decode(address);
}
@@ -166,14 +160,11 @@ function getAccountAddressType(address)
var checkSumTwo = SHA256.digest(SHA256.digest(addressWitoutChecksum));
checkSumTwo = checkSumTwo.subarray(0, 4);
if (equal(checkSum, checkSumTwo))
{
if(address[0] == ADDRESS_VERSION)
{
if (equal(checkSum, checkSumTwo)) {
if (address[0] == ADDRESS_VERSION) {
return "standard";
}
if(address[0] == AT_ADDRESS_VERSION)
{
if (address[0] == AT_ADDRESS_VERSION) {
return "at";
}
}
@@ -185,8 +176,7 @@ function getAccountAddressType(address)
}
}
function isValidAddress(address)
{
function isValidAddress(address) {
return (getAccountAddressType(address) != "invalid");
}
@@ -307,8 +297,8 @@ function generateSignatureRegisterNameTransaction(keyPair, lastReference, owner,
}
function generateRegisterNameTransaction(keyPair, lastReference, owner, name, value, fee, timestamp, signature) {
return appendBuffer( generateRegisterNameTransactionBase(keyPair.publicKey, lastReference, owner, name, value, fee, timestamp),
signature );
return appendBuffer(generateRegisterNameTransactionBase(keyPair.publicKey, lastReference, owner, name, value, fee, timestamp),
signature);
}
function generateRegisterNameTransactionBase(publicKey, lastReference, owner, name, value, fee, timestamp) {
@@ -333,4 +323,4 @@ function generateRegisterNameTransactionBase(publicKey, lastReference, owner, na
data = appendBuffer(data, feeBytes);
return data;
}
}

View File

@@ -1,5 +1,7 @@
// Extracted from https://github.com/crypto-browserify/ripemd160
const ARRAY16 = new Array(16);
const zl = initU8Array([
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,

View File

@@ -3,140 +3,139 @@
const SHA256 = {};
SHA256.K = [
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b,
0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01,
0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7,
0xc19bf174, 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, 0x983e5152,
0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147,
0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc,
0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819,
0xd6990624, 0xf40e3585, 0x106aa070, 0x19a4c116, 0x1e376c08,
0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f,
0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b,
0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01,
0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7,
0xc19bf174, 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, 0x983e5152,
0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147,
0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc,
0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819,
0xd6990624, 0xf40e3585, 0x106aa070, 0x19a4c116, 0x1e376c08,
0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f,
0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
];
// The digest function returns the hash value (digest)
// as a 32 byte (typed) array.
// message: the string or byte array to hash
SHA256.digest = function(message) {
var h0 = 0x6a09e667;
var h1 = 0xbb67ae85;
var h2 = 0x3c6ef372;
var h3 = 0xa54ff53a;
var h4 = 0x510e527f;
var h5 = 0x9b05688c;
var h6 = 0x1f83d9ab;
var h7 = 0x5be0cd19;
var K = SHA256.K;
if (typeof message == 'string') {
var s = unescape(encodeURIComponent(message)); // UTF-8
message = new Uint8Array(s.length);
for (var i = 0; i < s.length; i++) {
message[i] = s.charCodeAt(i) & 0xff;
}
}
var length = message.length;
var byteLength = Math.floor((length + 72) / 64) * 64;
var wordLength = byteLength / 4;
var bitLength = length * 8;
var m = new Uint8Array(byteLength);
m.set(message);
m[length] = 0x80;
m[byteLength - 4] = bitLength >>> 24;
m[byteLength - 3] = (bitLength >>> 16) & 0xff;
m[byteLength - 2] = (bitLength >>> 8) & 0xff;
m[byteLength - 1] = bitLength & 0xff;
var words = new Int32Array(wordLength);
var byteIndex = 0;
for (var i = 0; i < words.length; i++) {
var word = m[byteIndex++] << 24;
word |= m[byteIndex++] << 16;
word |= m[byteIndex++] << 8;
word |= m[byteIndex++];
words[i] = word;
}
var w = new Int32Array(64);
for (var j = 0; j < wordLength; j += 16) {
for (i = 0; i < 16; i++) {
w[i] = words[j + i];
}
for (i = 16; i < 64; i++) {
var v = w[i - 15];
var s0 = (v >>> 7) | (v << 25);
s0 ^= (v >>> 18) | (v << 14);
s0 ^= (v >>> 3);
v = w[i - 2];
var s1 = (v >>> 17) | (v << 15);
s1 ^= (v >>> 19) | (v << 13);
s1 ^= (v >>> 10);
w[i] = (w[i - 16] + s0 + w[i - 7] + s1) & 0xffffffff;
}
var a = h0;
var b = h1;
var c = h2;
var d = h3;
var e = h4;
var f = h5;
var g = h6;
var h = h7;
for (i = 0; i < 64; i++) {
s1 = (e >>> 6) | (e << 26);
s1 ^= (e >>> 11) | (e << 21);
s1 ^= (e >>> 25) | (e << 7);
var ch = (e & f) ^ (~e & g);
var temp1 = (h + s1 + ch + K[i] + w[i]) & 0xffffffff;
s0 = (a >>> 2) | (a << 30);
s0 ^= (a >>> 13) | (a << 19);
s0 ^= (a >>> 22) | (a << 10);
var maj = (a & b) ^ (a & c) ^ (b & c);
var temp2 = (s0 + maj) & 0xffffffff;
h = g
g = f
f = e
e = (d + temp1) & 0xffffffff;
d = c;
c = b;
b = a;
a = (temp1 + temp2) & 0xffffffff;
}
h0 = (h0 + a) & 0xffffffff;
h1 = (h1 + b) & 0xffffffff;
h2 = (h2 + c) & 0xffffffff;
h3 = (h3 + d) & 0xffffffff;
h4 = (h4 + e) & 0xffffffff;
h5 = (h5 + f) & 0xffffffff;
h6 = (h6 + g) & 0xffffffff;
h7 = (h7 + h) & 0xffffffff;
}
var hash = new Uint8Array(32);
for (var i = 0; i < 4; i++) {
hash[i] = (h0 >>> (8 * (3 - i))) & 0xff;
hash[i + 4] = (h1 >>> (8 * (3 - i))) & 0xff;
hash[i + 8] = (h2 >>> (8 * (3 - i))) & 0xff;
hash[i + 12] = (h3 >>> (8 * (3 - i))) & 0xff;
hash[i + 16] = (h4 >>> (8 * (3 - i))) & 0xff;
hash[i + 20] = (h5 >>> (8 * (3 - i))) & 0xff;
hash[i + 24] = (h6 >>> (8 * (3 - i))) & 0xff;
hash[i + 28] = (h7 >>> (8 * (3 - i))) & 0xff;
}
return hash;
}
SHA256.digest = function (message) {
var h0 = 0x6a09e667;
var h1 = 0xbb67ae85;
var h2 = 0x3c6ef372;
var h3 = 0xa54ff53a;
var h4 = 0x510e527f;
var h5 = 0x9b05688c;
var h6 = 0x1f83d9ab;
var h7 = 0x5be0cd19;
var K = SHA256.K;
if (typeof message == 'string') {
var s = unescape(encodeURIComponent(message)); // UTF-8
message = new Uint8Array(s.length);
for (var i = 0; i < s.length; i++) {
message[i] = s.charCodeAt(i) & 0xff;
}
}
var length = message.length;
var byteLength = Math.floor((length + 72) / 64) * 64;
var wordLength = byteLength / 4;
var bitLength = length * 8;
var m = new Uint8Array(byteLength);
m.set(message);
m[length] = 0x80;
m[byteLength - 4] = bitLength >>> 24;
m[byteLength - 3] = (bitLength >>> 16) & 0xff;
m[byteLength - 2] = (bitLength >>> 8) & 0xff;
m[byteLength - 1] = bitLength & 0xff;
var words = new Int32Array(wordLength);
var byteIndex = 0;
for (var i = 0; i < words.length; i++) {
var word = m[byteIndex++] << 24;
word |= m[byteIndex++] << 16;
word |= m[byteIndex++] << 8;
word |= m[byteIndex++];
words[i] = word;
}
var w = new Int32Array(64);
for (var j = 0; j < wordLength; j += 16) {
for (i = 0; i < 16; i++) {
w[i] = words[j + i];
}
for (i = 16; i < 64; i++) {
var v = w[i - 15];
var s0 = (v >>> 7) | (v << 25);
s0 ^= (v >>> 18) | (v << 14);
s0 ^= (v >>> 3);
v = w[i - 2];
var s1 = (v >>> 17) | (v << 15);
s1 ^= (v >>> 19) | (v << 13);
s1 ^= (v >>> 10);
w[i] = (w[i - 16] + s0 + w[i - 7] + s1) & 0xffffffff;
}
var a = h0;
var b = h1;
var c = h2;
var d = h3;
var e = h4;
var f = h5;
var g = h6;
var h = h7;
for (i = 0; i < 64; i++) {
s1 = (e >>> 6) | (e << 26);
s1 ^= (e >>> 11) | (e << 21);
s1 ^= (e >>> 25) | (e << 7);
var ch = (e & f) ^ (~e & g);
var temp1 = (h + s1 + ch + K[i] + w[i]) & 0xffffffff;
s0 = (a >>> 2) | (a << 30);
s0 ^= (a >>> 13) | (a << 19);
s0 ^= (a >>> 22) | (a << 10);
var maj = (a & b) ^ (a & c) ^ (b & c);
var temp2 = (s0 + maj) & 0xffffffff;
h = g
g = f
f = e
e = (d + temp1) & 0xffffffff;
d = c;
c = b;
b = a;
a = (temp1 + temp2) & 0xffffffff;
}
h0 = (h0 + a) & 0xffffffff;
h1 = (h1 + b) & 0xffffffff;
h2 = (h2 + c) & 0xffffffff;
h3 = (h3 + d) & 0xffffffff;
h4 = (h4 + e) & 0xffffffff;
h5 = (h5 + f) & 0xffffffff;
h6 = (h6 + g) & 0xffffffff;
h7 = (h7 + h) & 0xffffffff;
}
var hash = new Uint8Array(32);
for (var i = 0; i < 4; i++) {
hash[i] = (h0 >>> (8 * (3 - i))) & 0xff;
hash[i + 4] = (h1 >>> (8 * (3 - i))) & 0xff;
hash[i + 8] = (h2 >>> (8 * (3 - i))) & 0xff;
hash[i + 12] = (h3 >>> (8 * (3 - i))) & 0xff;
hash[i + 16] = (h4 >>> (8 * (3 - i))) & 0xff;
hash[i + 20] = (h5 >>> (8 * (3 - i))) & 0xff;
hash[i + 24] = (h6 >>> (8 * (3 - i))) & 0xff;
hash[i + 28] = (h7 >>> (8 * (3 - i))) & 0xff;
}
return hash;
}
// The hash function returns the hash value as a hex string.
// message: the string or byte array to hash
SHA256.hash = function(message) {
var digest = SHA256.digest(message);
var hex = '';
SHA256.hash = function (message) {
var digest = SHA256.digest(message);
var hex = '';
for (var i = 0; i < digest.length; i++) {
var s = '0' + digest[i].toString(16);
hex += s.length > 2 ? s.substring(1) : s;
hex += s.length > 2 ? s.substring(1) : s;
}
return hex;
return hex;
}
// == Convert to ES6 Module == //
export default SHA256;
export default SHA256;

View File

@@ -1,74 +1,73 @@
'use strict'
const utils = {
int32ToBytes(word) {
var byteArray = []
for (var b = 0; b < 32; b += 8) {
byteArray.push((word >>> (24 - b % 32)) & 0xFF)
}
return byteArray
},
int32ToBytes(word) {
var byteArray = []
for (var b = 0; b < 32; b += 8) {
byteArray.push((word >>> (24 - b % 32)) & 0xFF)
}
return byteArray
},
stringtoUTF8Array(message) {
if (typeof message === 'string') {
var s = unescape(encodeURIComponent(message)) // UTF-8
message = new Uint8Array(s.length)
for (var i = 0; i < s.length; i++) {
message[i] = s.charCodeAt(i) & 0xff
}
}
return message
},
// ...buffers then buffers.foreach and append to buffer1
appendBuffer(buffer1, buffer2) {
buffer1 = new Uint8Array(buffer1)
buffer2 = new Uint8Array(buffer2)
let tmp = new Uint8Array(buffer1.byteLength + buffer2.byteLength)
tmp.set(buffer1, 0)
tmp.set(buffer2, buffer1.byteLength)
return tmp
},
stringtoUTF8Array(message) {
if (typeof message === 'string') {
var s = unescape(encodeURIComponent(message)) // UTF-8
message = new Uint8Array(s.length)
for (var i = 0; i < s.length; i++) {
message[i] = s.charCodeAt(i) & 0xff
}
}
return message
},
// ...buffers then buffers.foreach and append to buffer1
appendBuffer(buffer1, buffer2) {
buffer1 = new Uint8Array(buffer1)
buffer2 = new Uint8Array(buffer2)
let tmp = new Uint8Array(buffer1.byteLength + buffer2.byteLength)
tmp.set(buffer1, 0)
tmp.set(buffer2, buffer1.byteLength)
return tmp
},
int64ToBytes(int64) {
// we want to represent the input as a 8-bytes array
var byteArray = [0, 0, 0, 0, 0, 0, 0, 0]
int64ToBytes(int64) {
// we want to represent the input as a 8-bytes array
var byteArray = [0, 0, 0, 0, 0, 0, 0, 0]
for (var index = 0; index < byteArray.length; index++) {
var byte = int64 & 0xff
byteArray[byteArray.length - index - 1] = byte
int64 = (int64 - byte) / 256
}
for (var index = 0; index < byteArray.length; index++) {
var byte = int64 & 0xff
byteArray[byteArray.length - index - 1] = byte
int64 = (int64 - byte) / 256
}
return byteArray
},
return byteArray
},
hexToBytes(hexString) {
return new Uint8Array(hexString.match(/.{1,2}/g).map(byte => parseInt(byte, 16)))
},
hexToBytes(hexString) {
return new Uint8Array(hexString.match(/.{1,2}/g).map(byte => parseInt(byte, 16)))
},
stringToHex(bytes) {
return bytes.reduce((str, byte) => str + byte.toString(16).padStart(2, '0'), '')
},
stringToHex(bytes) {
return bytes.reduce((str, byte) => str + byte.toString(16).padStart(2, '0'), '')
},
equal(buf1, buf2) {
if (buf1.byteLength != buf2.byteLength) return false
var dv1 = new Uint8Array(buf1)
var dv2 = new Uint8Array(buf2)
for (var i = 0; i != buf1.byteLength; i++) {
if (dv1[i] != dv2[i]) return false
}
return true
},
equal(buf1, buf2) {
if (buf1.byteLength != buf2.byteLength) return false
var dv1 = new Uint8Array(buf1)
var dv2 = new Uint8Array(buf2)
for (var i = 0; i != buf1.byteLength; i++) {
if (dv1[i] != dv2[i]) return false
}
return true
},
bytesToHex(byteArray) {
var _byteArrayToHex = []
bytesToHex(byteArray) {
var _byteArrayToHex = []
for (var index = 0; index < byteArray.length; index++) {
_byteArrayToHex.push((byteArray[index] >>> 4).toString(16))
_byteArrayToHex.push((byteArray[index] & 15).toString(16));
}
for (var index = 0; index < byteArray.length; index++) {
_byteArrayToHex.push((byteArray[index] >>> 4).toString(16))
_byteArrayToHex.push((byteArray[index] & 15).toString(16));
}
return _byteArrayToHex.join("")
}
return _byteArrayToHex.join("")
}
}
export default utils

View File

@@ -1,6 +1,7 @@
import {waitForConfig, watchConfig} from '../config.js'
import { waitForConfig, watchConfig } from '../config'
let config = {}
watchConfig((c) => {
config = c
})
@@ -15,6 +16,7 @@ export async function request(url, options) {
const n = config.nodeConfig.knownNodes[config.nodeConfig.node]
const node = n.protocol + '://' + n.domain + ':' + n.port
return fetch(node + url, {
method,
headers,

View File

@@ -1,11 +1,11 @@
import {store} from '../api_deps.js'
import {stateAwait} from './utils/stateAwait.js'
import {Sha512} from 'asmcrypto.js'
import utils from '../api/deps/utils.js'
import {get, registerTranslateConfig} from '../../core/translate'
import { store } from '../api_deps'
import { stateAwait } from './utils/stateAwait'
import { Sha512 } from 'asmcrypto.js'
import utils from '../api/deps/utils'
import { get, registerTranslateConfig } from '../../core/translate'
registerTranslateConfig({
loader: lang => fetch(`/language/${lang}.json`).then(res => res.json())
loader: lang => fetch(`/language/${lang}.json`).then(res => res.json())
})
export const kdf = async (seed, salt, status = () => { }) => {

View File

@@ -1,7 +1,7 @@
/**
* Not to be confused with register name...this is a special use case
*/
import {createTransaction, processTransaction, request} from './api.js'
import { createTransaction, processTransaction, request } from './api'
const TX_TYPE = 3 // NAME_REGISTRATION
const CHECK_LAST_REF_INTERVAL = 30 * 1000 // err 30 seconds

View File

@@ -1,6 +1,6 @@
import {AES_CBC, HmacSha512} from 'asmcrypto.js'
import {kdf} from './kdf.js'
import Base58 from './deps/Base58.js'
import { AES_CBC, HmacSha512 } from 'asmcrypto.js'
import { kdf } from './kdf'
import Base58 from './deps/Base58'
const getRandomValues = window.crypto ? window.crypto.getRandomValues.bind(window.crypto) : window.msCrypto.getRandomValues.bind(window.msCrypto)

View File

@@ -1,9 +1,9 @@
// Trade Bot
import TradeBotCreateRequest from './transactions/trade-portal/tradebot/TradeBotCreateRequest.js'
import TradeBotRespondRequest from './transactions/trade-portal/tradebot/TradeBotRespondRequest.js'
import signTradeBotTransaction from './transactions/trade-portal/tradebot/signTradeBotTransaction.js'
import DeleteTradeOffer from './transactions/trade-portal/tradeoffer/DeleteTradeOffer.js'
import {request} from './fetch-request'
import TradeBotCreateRequest from './transactions/trade-portal/tradebot/TradeBotCreateRequest'
import TradeBotRespondRequest from './transactions/trade-portal/tradebot/TradeBotRespondRequest'
import signTradeBotTransaction from './transactions/trade-portal/tradebot/signTradeBotTransaction'
import DeleteTradeOffer from './transactions/trade-portal/tradeoffer/DeleteTradeOffer'
import { request } from './fetch-request'
// TradeBotCreateRequest
export const tradeBotCreateRequest = (requestObject) => {

View File

@@ -1,6 +1,5 @@
'use strict'
import TransactionBase from './TransactionBase.js'
import {QORT_DECIMALS} from '../constants.js'
import TransactionBase from './TransactionBase'
import { QORT_DECIMALS } from '../constants'
export default class PaymentTransaction extends TransactionBase {
constructor() {

View File

@@ -1,5 +1,4 @@
'use strict'
import TransactionBase from './TransactionBase.js'
import TransactionBase from './TransactionBase'
export default class DelegationTransaction extends TransactionBase {
constructor() {

View File

@@ -1,7 +1,6 @@
'use strict'
import TransactionBase from './TransactionBase.js'
import {store} from '../../api.js'
import {QORT_DECIMALS} from '../constants.js'
import TransactionBase from './TransactionBase'
import { store } from '../../api'
import { QORT_DECIMALS } from '../constants'
export default class DeployAtTransaction extends TransactionBase {
constructor() {
@@ -9,7 +8,6 @@ export default class DeployAtTransaction extends TransactionBase {
this.type = 16
}
render(html) {
return html`
${this._atDeployDialog1}:
@@ -31,12 +29,15 @@ export default class DeployAtTransaction extends TransactionBase {
set atDeployDialog1(atDeployDialog1) {
this._atDeployDialog1 = atDeployDialog1
}
set atDeployDialog2(atDeployDialog2) {
this._atDeployDialog2 = atDeployDialog2
}
set atDeployDialog3(atDeployDialog3) {
this._atDeployDialog3 = atDeployDialog3
}
set atDeployDialog4(atDeployDialog4) {
this._atDeployDialog4 = atDeployDialog4
}
@@ -46,6 +47,7 @@ export default class DeployAtTransaction extends TransactionBase {
this._fee = fee * QORT_DECIMALS
this._feeBytes = this.constructor.utils.int64ToBytes(this._fee)
}
set rAmount(rAmount) {
this._amountToShow = rAmount
this._rAmount = Math.round(rAmount * store.getState().config.coin.decimals)
@@ -63,26 +65,29 @@ export default class DeployAtTransaction extends TransactionBase {
this._rDescriptionBytes = this.constructor.utils.stringtoUTF8Array(this._rDescription.toLocaleLowerCase())
this._rDescriptionLength = this.constructor.utils.int32ToBytes(this._rDescriptionBytes.length)
}
set atType(atType) {
this._atType = atType
this._atTypeBytes = this.constructor.utils.stringtoUTF8Array(this._atType)
this._atTypeLength = this.constructor.utils.int32ToBytes(this._atTypeBytes.length)
}
set rTags(rTags) {
this._rTags = rTags
this._rTagsBytes = this.constructor.utils.stringtoUTF8Array(this._rTags.toLocaleLowerCase())
this._rTagsLength = this.constructor.utils.int32ToBytes(this._rTagsBytes.length)
}
set rCreationBytes(rCreationBytes) {
const decode = this.constructor.Base58.decode(rCreationBytes)
this._rCreationBytes = this.constructor.utils.stringtoUTF8Array(decode)
this._rCreationBytesLength = this.constructor.utils.int32ToBytes(this._rCreationBytes.length)
}
set rAssetId(rAssetId) {
this._rAssetId = this.constructor.utils.int64ToBytes(rAssetId)
}
get params() {
const params = super.params
params.push(

View File

@@ -1,13 +1,12 @@
'use strict'
import PaymentTransaction from './PaymentTransaction.js'
import PaymentTransaction from './PaymentTransaction'
export default class MessageTransaction extends PaymentTransaction {
constructor() {
super()
this.type = 17
this._key = this.constructor.utils.int64ToBytes(0);
this._isEncrypted = new Uint8Array(1); // Defaults to false
this._isText = new Uint8Array(1); // Defaults to false
this._key = this.constructor.utils.int64ToBytes(0)
this._isEncrypted = new Uint8Array(1) // Defaults to false
this._isText = new Uint8Array(1) // Defaults to false
}
set message(message /* UTF8 String */) {

View File

@@ -1,7 +1,6 @@
'use strict'
import TransactionBase from './TransactionBase.js'
import Base58 from '../deps/Base58.js'
import {store} from '../../api.js'
import TransactionBase from './TransactionBase'
import Base58 from '../deps/Base58'
import { store } from '../../api'
export default class PaymentTransaction extends TransactionBase {
constructor() {

View File

@@ -1,6 +1,5 @@
"use strict";
import ChatBase from "./chat/ChatBase.js"
import {QORT_DECIMALS} from "../constants.js"
import ChatBase from './chat/ChatBase'
import { QORT_DECIMALS } from '../constants'
export default class PublicizeTransaction extends ChatBase {
constructor() {
@@ -9,19 +8,21 @@ export default class PublicizeTransaction extends ChatBase {
this.fee = 0
}
set proofOfWorkNonce(proofOfWorkNonce) {
this._proofOfWorkNonce = this.constructor.utils.int32ToBytes(proofOfWorkNonce)
}
set fee(fee) {
this._fee = fee * QORT_DECIMALS
this._feeBytes = this.constructor.utils.int64ToBytes(this._fee)
}
get params() {
const params = super.params;
params.push(
this._proofOfWorkNonce,
this._feeBytes
)
return params;
}
set proofOfWorkNonce(proofOfWorkNonce) {
this._proofOfWorkNonce = this.constructor.utils.int32ToBytes(proofOfWorkNonce)
}
set fee(fee) {
this._fee = fee * QORT_DECIMALS
this._feeBytes = this.constructor.utils.int64ToBytes(this._fee)
}
get params() {
const params = super.params
params.push(
this._proofOfWorkNonce,
this._feeBytes
)
return params
}
}

View File

@@ -1,16 +1,17 @@
'use strict'
import {QORT_DECIMALS, TX_TYPES} from '../constants.js'
import nacl from '../deps/nacl-fast.js'
import Base58 from '../deps/Base58.js'
import utils from '../deps/utils.js'
import { QORT_DECIMALS, TX_TYPES } from '../constants'
import nacl from '../deps/nacl-fast'
import Base58 from '../deps/Base58'
import utils from '../deps/utils'
export default class TransactionBase {
static get utils() {
return utils
}
static get nacl() {
return nacl
}
static get Base58() {
return Base58
}

View File

@@ -1,7 +1,6 @@
'use strict'
import TransactionBase from './TransactionBase.js'
import {store} from '../../api.js'
import {QORT_DECIMALS} from '../constants.js'
import TransactionBase from './TransactionBase'
import { store } from '../../api'
import { QORT_DECIMALS } from '../constants'
export default class TransferPrivsTransaction extends TransactionBase {
constructor() {
@@ -12,12 +11,12 @@ export default class TransferPrivsTransaction extends TransactionBase {
render(html) {
const conf = store.getState().config
return html`
Are you sure to transfer privileges to this account ?
<div style="background: #eee; padding: 8px; margin: 8px 0; border-radius: 5px;">
<span style="color: #000;">${this.theRecipient}</span>
</div>
On pressing confirm, the transfer privileges request will be sent!
`
Are you sure to transfer privileges to this account ?
<div style="background: #eee; padding: 8px; margin: 8px 0; border-radius: 5px;">
<span style="color: #000;">${this.theRecipient}</span>
</div>
On pressing confirm, the transfer privileges request will be sent!
`
}
set recipient(recipient) {

View File

@@ -1,9 +1,8 @@
import nacl from '../../deps/nacl-fast.js'
import utils from '../../deps/utils.js'
import Base58 from '../../deps/Base58.js'
import nacl from '../../deps/nacl-fast'
import utils from '../../deps/utils'
import Base58 from '../../deps/Base58'
const signArbitrary = (arbitraryBytesBase58, arbitraryBytesForSigningBase58, nonce, keyPair) => {
if (!arbitraryBytesBase58) {
throw new Error('ArbitraryBytesBase58 not defined')
}
@@ -19,12 +18,11 @@ const signArbitrary = (arbitraryBytesBase58, arbitraryBytesForSigningBase58, non
const arbitraryBytes = Base58.decode(arbitraryBytesBase58)
const _arbitraryBytesBuffer = Object.keys(arbitraryBytes).map(function (key) { return arbitraryBytes[key]; })
const arbitraryBytesBuffer = new Uint8Array(_arbitraryBytesBuffer)
const arbitraryBytesForSigning = Base58.decode(arbitraryBytesForSigningBase58)
const _arbitraryBytesForSigningBuffer = Object.keys(arbitraryBytesForSigning).map(function (key) { return arbitraryBytesForSigning[key]; })
const arbitraryBytesForSigningBuffer = new Uint8Array(_arbitraryBytesForSigningBuffer)
const _nonce = utils.int32ToBytes(nonce)
arbitraryBytesBuffer.set(_nonce, 112)
arbitraryBytesForSigningBuffer.set(_nonce, 112)

View File

@@ -1,14 +1,12 @@
import nacl from '../../deps/nacl-fast.js'
import utils from '../../deps/utils.js'
import Base58 from '../../deps/Base58.js'
import nacl from '../../deps/nacl-fast'
import utils from '../../deps/utils'
import Base58 from '../../deps/Base58'
const signArbitraryWithFee = (arbitraryBytesBase58, arbitraryBytesForSigningBase58, keyPair) => {
if (!arbitraryBytesBase58) {
throw new Error('ArbitraryBytesBase58 not defined')
}
if (!keyPair) {
throw new Error('keyPair not defined')
}
@@ -16,13 +14,9 @@ const signArbitraryWithFee = (arbitraryBytesBase58, arbitraryBytesForSigningBase
const arbitraryBytes = Base58.decode(arbitraryBytesBase58)
const _arbitraryBytesBuffer = Object.keys(arbitraryBytes).map(function (key) { return arbitraryBytes[key]; })
const arbitraryBytesBuffer = new Uint8Array(_arbitraryBytesBuffer)
const arbitraryBytesForSigning = Base58.decode(arbitraryBytesForSigningBase58)
const _arbitraryBytesForSigningBuffer = Object.keys(arbitraryBytesForSigning).map(function (key) { return arbitraryBytesForSigning[key]; })
const arbitraryBytesForSigningBuffer = new Uint8Array(_arbitraryBytesForSigningBuffer)
const signature = nacl.sign.detached(arbitraryBytesForSigningBuffer, keyPair.privateKey)
return utils.appendBuffer(arbitraryBytesBuffer, signature)

View File

@@ -1,37 +1,36 @@
'use strict'
(function () {
function generateSignatureArbitraryTransactionV3(keyPair, lastReference, service, arbitraryData, fee, timestamp) => {
const data = generateArbitraryTransactionV3Base(keyPair.publicKey, lastReference, service, arbitraryData, fee, timestamp)
return nacl.sign.detached(data, keyPair.privateKey)
}
(function () {
function generateSignatureArbitraryTransactionV3(keyPair, lastReference, service, arbitraryData, fee, timestamp) => {
const data = generateArbitraryTransactionV3Base(keyPair.publicKey, lastReference, service, arbitraryData, fee, timestamp)
return nacl.sign.detached(data, keyPair.privateKey)
}
function generateArbitraryTransactionV3(keyPair, lastReference, service, arbitraryData, fee, timestamp, signature) => {
return appendBuffer(generateArbitraryTransactionV3Base(keyPair.publicKey, lastReference, service, arbitraryData, fee, timestamp), signature)
}
function generateArbitraryTransactionV3(keyPair, lastReference, service, arbitraryData, fee, timestamp, signature) => {
return appendBuffer(generateArbitraryTransactionV3Base(keyPair.publicKey, lastReference, service, arbitraryData, fee, timestamp), signature)
}
function generateArbitraryTransactionV3Base(publicKey, lastReference, service, arbitraryData, fee, timestamp) => {
const txType = TYPES.ARBITRARY_TRANSACTION
const typeBytes = int32ToBytes(txType)
const timestampBytes = int64ToBytes(timestamp)
const feeBytes = int64ToBytes(fee * 100000000)
const serviceBytes = int32ToBytes(service)
const dataSizeBytes = int32ToBytes(arbitraryData.length)
const paymentsLengthBytes = int32ToBytes(0) // Support payments - not yet.
function generateArbitraryTransactionV3Base(publicKey, lastReference, service, arbitraryData, fee, timestamp) => {
const txType = TYPES.ARBITRARY_TRANSACTION
const typeBytes = int32ToBytes(txType)
const timestampBytes = int64ToBytes(timestamp)
const feeBytes = int64ToBytes(fee * 100000000)
const serviceBytes = int32ToBytes(service)
const dataSizeBytes = int32ToBytes(arbitraryData.length)
const paymentsLengthBytes = int32ToBytes(0) // Support payments - not yet.
var data = new Uint8Array()
var data = new Uint8Array()
data = appendBuffer(data, typeBytes)
data = appendBuffer(data, timestampBytes)
data = appendBuffer(data, lastReference)
data = appendBuffer(data, publicKey)
data = appendBuffer(data, paymentsLengthBytes)
data = appendBuffer(data, typeBytes)
data = appendBuffer(data, timestampBytes)
data = appendBuffer(data, lastReference)
data = appendBuffer(data, publicKey)
data = appendBuffer(data, paymentsLengthBytes)
// Here it is necessary to insert the payments, if there are
data = appendBuffer(data, serviceBytes)
data = appendBuffer(data, dataSizeBytes)
data = appendBuffer(data, arbitraryData)
data = appendBuffer(data, feeBytes)
// Here it is necessary to insert the payments, if there are
data = appendBuffer(data, serviceBytes)
data = appendBuffer(data, dataSizeBytes)
data = appendBuffer(data, arbitraryData)
data = appendBuffer(data, feeBytes)
return data
}
}())
return data
}
}())

View File

@@ -1,141 +1,143 @@
'use strict'
import {QORT_DECIMALS, TX_TYPES} from '../../constants.js'
import nacl from '../../deps/nacl-fast.js'
import Base58 from '../../deps/Base58.js'
import utils from '../../deps/utils.js'
import { QORT_DECIMALS, TX_TYPES } from '../../constants'
import nacl from '../../deps/nacl-fast'
import Base58 from '../../deps/Base58'
import utils from '../../deps/utils'
export default class ChatBase {
static get utils() {
return utils
}
static get nacl() {
return nacl
}
static get Base58() {
return Base58
}
static get utils() {
return utils
}
constructor() {
this.fee = 0
this.groupID = 0
this.tests = [
() => {
if (!(this._type >= 1 && this._type in TX_TYPES)) {
return 'Invalid type: ' + this.type
}
return true
},
() => {
if (this._fee < 0) {
return 'Invalid fee: ' + this._fee / QORT_DECIMALS
}
return true
},
() => {
if (this._groupID < 0 || !Number.isInteger(this._groupID)) {
return 'Invalid groupID: ' + this._groupID
}
return true
},
() => {
if (!(new Date(this._timestamp)).getTime() > 0) {
return 'Invalid timestamp: ' + this._timestamp
}
return true
},
() => {
if (!(this._lastReference instanceof Uint8Array && this._lastReference.byteLength == 64)) {
return 'Invalid last reference: ' + this._lastReference
}
return true
},
() => {
if (!(this._keyPair)) {
return 'keyPair must be specified'
}
if (!(this._keyPair.publicKey instanceof Uint8Array && this._keyPair.publicKey.byteLength === 32)) {
return 'Invalid publicKey'
}
if (!(this._keyPair.privateKey instanceof Uint8Array && this._keyPair.privateKey.byteLength === 64)) {
return 'Invalid privateKey'
}
return true
}
]
}
static get nacl() {
return nacl
}
set keyPair(keyPair) {
this._keyPair = keyPair
}
static get Base58() {
return Base58
}
set type(type) {
this.typeText = TX_TYPES[type]
this._type = type
this._typeBytes = this.constructor.utils.int32ToBytes(this._type)
}
constructor() {
this.fee = 0
this.groupID = 0
this.tests = [
() => {
if (!(this._type >= 1 && this._type in TX_TYPES)) {
return 'Invalid type: ' + this.type
}
return true
},
() => {
if (this._fee < 0) {
return 'Invalid fee: ' + this._fee / QORT_DECIMALS
}
return true
},
() => {
if (this._groupID < 0 || !Number.isInteger(this._groupID)) {
return 'Invalid groupID: ' + this._groupID
}
return true
},
() => {
if (!(new Date(this._timestamp)).getTime() > 0) {
return 'Invalid timestamp: ' + this._timestamp
}
return true
},
() => {
if (!(this._lastReference instanceof Uint8Array && this._lastReference.byteLength == 64)) {
return 'Invalid last reference: ' + this._lastReference
}
return true
},
() => {
if (!(this._keyPair)) {
return 'keyPair must be specified'
}
if (!(this._keyPair.publicKey instanceof Uint8Array && this._keyPair.publicKey.byteLength === 32)) {
return 'Invalid publicKey'
}
if (!(this._keyPair.privateKey instanceof Uint8Array && this._keyPair.privateKey.byteLength === 64)) {
return 'Invalid privateKey'
}
return true
}
]
}
set groupID(groupID) {
this._groupID = groupID
this._groupIDBytes = this.constructor.utils.int32ToBytes(this._groupID)
}
set keyPair(keyPair) {
this._keyPair = keyPair
}
set timestamp(timestamp) {
this._timestamp = timestamp
this._timestampBytes = this.constructor.utils.int64ToBytes(this._timestamp)
}
set type(type) {
this.typeText = TX_TYPES[type]
this._type = type
this._typeBytes = this.constructor.utils.int32ToBytes(this._type)
}
set fee(fee) {
this._fee = fee * QORT_DECIMALS
this._feeBytes = this.constructor.utils.int64ToBytes(this._fee)
}
set groupID(groupID) {
this._groupID = groupID
this._groupIDBytes = this.constructor.utils.int32ToBytes(this._groupID)
}
set lastReference(lastReference) {
this._lastReference = lastReference instanceof Uint8Array ? lastReference : this.constructor.Base58.decode(lastReference)
}
set timestamp(timestamp) {
this._timestamp = timestamp
this._timestampBytes = this.constructor.utils.int64ToBytes(this._timestamp)
}
get params() {
return [
this._typeBytes,
this._timestampBytes,
this._groupIDBytes,
this._lastReference,
this._keyPair.publicKey
]
}
set fee(fee) {
this._fee = fee * QORT_DECIMALS
this._feeBytes = this.constructor.utils.int64ToBytes(this._fee)
}
get chatBytes() {
const isValid = this.validParams()
if (!isValid.valid) {
throw new Error(isValid.message)
}
set lastReference(lastReference) {
this._lastReference = lastReference instanceof Uint8Array ? lastReference : this.constructor.Base58.decode(lastReference)
}
let result = new Uint8Array()
get params() {
return [
this._typeBytes,
this._timestampBytes,
this._groupIDBytes,
this._lastReference,
this._keyPair.publicKey
]
}
this.params.forEach(item => {
result = this.constructor.utils.appendBuffer(result, item)
})
get chatBytes() {
const isValid = this.validParams()
if (!isValid.valid) {
throw new Error(isValid.message)
}
this._chatBytes = result
let result = new Uint8Array()
return this._chatBytes
}
this.params.forEach(item => {
result = this.constructor.utils.appendBuffer(result, item)
})
validParams() {
let finalResult = {
valid: true
}
this._chatBytes = result
this.tests.some(test => {
const result = test()
if (result !== true) {
finalResult = {
valid: false,
message: result
}
return true
}
})
return finalResult
}
return this._chatBytes
}
validParams() {
let finalResult = {
valid: true
}
this.tests.some(test => {
const result = test()
if (result !== true) {
finalResult = {
valid: false,
message: result
}
return true
}
})
return finalResult
}
}

View File

@@ -1,10 +1,8 @@
'use strict'
import ChatBase from "./ChatBase.js"
import nacl from '../../deps/nacl-fast.js'
import ed2curve from '../../deps/ed2curve.js'
import {Sha256} from 'asmcrypto.js'
import {CHAT_REFERENCE_FEATURE_TRIGGER_TIMESTAMP} from '../../constants.js'
import ChatBase from './ChatBase'
import nacl from '../../deps/nacl-fast'
import ed2curve from '../../deps/ed2curve'
import { Sha256 } from 'asmcrypto.js'
import { CHAT_REFERENCE_FEATURE_TRIGGER_TIMESTAMP } from '../../constants'
export default class ChatTransaction extends ChatBase {
constructor() {

View File

@@ -1,6 +1,5 @@
'use strict'
import ChatBase from "./ChatBase.js"
import {CHAT_REFERENCE_FEATURE_TRIGGER_TIMESTAMP} from '../../constants.js'
import ChatBase from './ChatBase'
import { CHAT_REFERENCE_FEATURE_TRIGGER_TIMESTAMP } from '../../constants'
export default class GroupChatTransaction extends ChatBase {
constructor() {
@@ -34,7 +33,7 @@ export default class GroupChatTransaction extends ChatBase {
}
set isEncrypted(isEncrypted) {
this._isEncrypted = new Uint8Array(1);
this._isEncrypted = new Uint8Array(1)
this._isEncrypted[0] = isEncrypted
}
@@ -63,6 +62,7 @@ export default class GroupChatTransaction extends ChatBase {
params.push(this._chatReference)
}
}
return params
}
}

View File

@@ -1,19 +1,18 @@
import nacl from '../../deps/nacl-fast.js'
import Base58 from '../../deps/Base58.js'
import ed2curve from '../../deps/ed2curve.js'
import {Sha256} from 'asmcrypto.js'
import nacl from '../../deps/nacl-fast'
import Base58 from '../../deps/Base58'
import ed2curve from '../../deps/ed2curve'
import { Sha256 } from 'asmcrypto.js'
export const decryptChatMessage = (encryptedMessage, privateKey, recipientPublicKey, lastReference) => {
let _encryptedMessage = Base58.decode(encryptedMessage)
const _base58RecipientPublicKey = recipientPublicKey instanceof Uint8Array ? Base58.encode(recipientPublicKey) : recipientPublicKey
const _recipientPublicKey = Base58.decode(_base58RecipientPublicKey)
const _lastReference = lastReference instanceof Uint8Array ? lastReference : Base58.decode(lastReference)
const convertedPrivateKey = ed2curve.convertSecretKey(privateKey)
const convertedPublicKey = ed2curve.convertPublicKey(_recipientPublicKey)
const sharedSecret = new Uint8Array(32);
const sharedSecret = new Uint8Array(32)
nacl.lowlevel.crypto_scalarmult(sharedSecret, convertedPrivateKey, convertedPublicKey)
const _chatEncryptionSeed = new Sha256().process(sharedSecret).finish().result
@@ -26,32 +25,30 @@ export const decryptChatMessage = (encryptedMessage, privateKey, recipientPublic
}
export const decryptChatMessageBase64 = (encryptedMessage, privateKey, recipientPublicKey, lastReference) => {
let _encryptedMessage = atob(encryptedMessage);
const binaryLength = _encryptedMessage.length;
const bytes = new Uint8Array(binaryLength);
let _encryptedMessage = atob(encryptedMessage)
const binaryLength = _encryptedMessage.length
const bytes = new Uint8Array(binaryLength)
for (let i = 0; i < binaryLength; i++) {
bytes[i] = _encryptedMessage.charCodeAt(i);
bytes[i] = _encryptedMessage.charCodeAt(i)
}
const _base58RecipientPublicKey = recipientPublicKey instanceof Uint8Array ? Base58.encode(recipientPublicKey) : recipientPublicKey
const _recipientPublicKey = Base58.decode(_base58RecipientPublicKey)
const _lastReference = lastReference instanceof Uint8Array ? lastReference : Base58.decode(lastReference)
const convertedPrivateKey = ed2curve.convertSecretKey(privateKey)
const convertedPublicKey = ed2curve.convertPublicKey(_recipientPublicKey)
const sharedSecret = new Uint8Array(32);
const sharedSecret = new Uint8Array(32)
nacl.lowlevel.crypto_scalarmult(sharedSecret, convertedPrivateKey, convertedPublicKey)
const _chatEncryptionSeed = new Sha256().process(sharedSecret).finish().result
const _decryptedMessage = nacl.secretbox.open(bytes, _lastReference.slice(0, 24), _chatEncryptionSeed)
if (_decryptedMessage === false) {
return _decryptedMessage
}
return new TextDecoder('utf-8').decode(_decryptedMessage)
}

View File

@@ -1,5 +1,5 @@
import nacl from '../../deps/nacl-fast.js'
import utils from '../../deps/utils.js'
import nacl from '../../deps/nacl-fast'
import utils from '../../deps/utils'
const signChat = (chatBytes, nonce, keyPair) => {

View File

@@ -1,6 +1,5 @@
'use strict'
import TransactionBase from '../TransactionBase.js'
import {QORT_DECIMALS} from '../../constants.js'
import TransactionBase from '../TransactionBase'
import { QORT_DECIMALS } from '../../constants'
export default class AddGroupAdminTransaction extends TransactionBase {
constructor() {

View File

@@ -1,6 +1,5 @@
'use strict'
import TransactionBase from '../TransactionBase.js'
import {QORT_DECIMALS} from '../../constants.js'
import TransactionBase from '../TransactionBase'
import { QORT_DECIMALS } from '../../constants'
export default class CancelGroupBanTransaction extends TransactionBase {
constructor() {

View File

@@ -1,6 +1,5 @@
'use strict'
import TransactionBase from '../TransactionBase.js'
import {QORT_DECIMALS} from '../../constants.js'
import TransactionBase from '../TransactionBase'
import { QORT_DECIMALS } from '../../constants'
export default class CancelGroupInviteTransaction extends TransactionBase {
constructor() {

View File

@@ -1,6 +1,5 @@
'use strict'
import TransactionBase from '../TransactionBase.js'
import {QORT_DECIMALS} from '../../constants.js'
import TransactionBase from '../TransactionBase'
import { QORT_DECIMALS } from '../../constants'
export default class CreateGroupTransaction extends TransactionBase {
constructor() {
@@ -12,11 +11,11 @@ export default class CreateGroupTransaction extends TransactionBase {
return html`
${this._groupdialog5}
<div style="background: #eee; padding: 8px; margin: 8px 0; border-radius: 5px;">
<div>${this._groupdialog7}: <span style="color: #000;">${this._rGroupName}</span></div>
<br>
<div>${this._groupdialog8}: <span style="color: #000;">${this._rGroupDesc}</span></div>
<br>
<div>${this._groupdialog9}: <span style="color: #000;">${this.myGroupType === 1 ? "Public" : "Private"}</span></div>
<div><span style="color: #000;">${this._groupdialog7}: ${this._rGroupName}</span></div>
<hr style="border: 2px solid #03a9f4;">
<div><span style="color: #000;">${this._groupdialog8}: ${this._rGroupDesc}</span></div>
<hr style="border: 2px solid #03a9f4;">
<div><span style="color: #000;">${this._groupdialog9}: ${this._rGroupTypeDesc}</span></div>
</div>
${this._groupdialog6}
`
@@ -42,6 +41,10 @@ export default class CreateGroupTransaction extends TransactionBase {
this._groupdialog9 = groupdialog9
}
set groupTypeDesc(groupTypeDesc) {
this._rGroupTypeDesc = groupTypeDesc
}
set fee(fee) {
this._fee = fee * QORT_DECIMALS
this._feeBytes = this.constructor.utils.int64ToBytes(this._fee)
@@ -49,18 +52,17 @@ export default class CreateGroupTransaction extends TransactionBase {
set rGroupName(rGroupName) {
this._rGroupName = rGroupName
this._rGroupNameBytes = this.constructor.utils.stringtoUTF8Array(this._rGroupName.toLocaleLowerCase())
this._rGroupNameBytes = this.constructor.utils.stringtoUTF8Array(this._rGroupName)
this._rGroupNameLength = this.constructor.utils.int32ToBytes(this._rGroupNameBytes.length)
}
set rGroupDesc(rGroupDesc) {
this._rGroupDesc = rGroupDesc
this._rGroupDescBytes = this.constructor.utils.stringtoUTF8Array(this._rGroupDesc.toLocaleLowerCase())
this._rGroupDescBytes = this.constructor.utils.stringtoUTF8Array(this._rGroupDesc)
this._rGroupDescLength = this.constructor.utils.int32ToBytes(this._rGroupDescBytes.length)
}
set rGroupType(rGroupType) {
this.myGroupType = rGroupType
this._rGroupType = new Uint8Array(1)
this._rGroupType[0] = rGroupType
}
@@ -71,13 +73,11 @@ export default class CreateGroupTransaction extends TransactionBase {
}
set rGroupMinimumBlockDelay(rGroupMinimumBlockDelay) {
this._rGroupMinimumBlockDelay = rGroupMinimumBlockDelay
this._rGroupMinimumBlockDelayBytes = this.constructor.utils.int32ToBytes(this._rGroupMinimumBlockDelay)
this._rGroupMinimumBlockDelayBytes = this.constructor.utils.int32ToBytes(rGroupMinimumBlockDelay)
}
set rGroupMaximumBlockDelay(rGroupMaximumBlockDelay) {
this._rGroupMaximumBlockDelay = rGroupMaximumBlockDelay
this._rGroupMaximumBlockDelayBytes = this.constructor.utils.int32ToBytes(this._rGroupMaximumBlockDelay)
this._rGroupMaximumBlockDelayBytes = this.constructor.utils.int32ToBytes(rGroupMaximumBlockDelay)
}
get params() {

View File

@@ -1,6 +1,5 @@
'use strict'
import TransactionBase from '../TransactionBase.js'
import {QORT_DECIMALS} from '../../constants.js'
import TransactionBase from '../TransactionBase'
import { QORT_DECIMALS } from '../../constants'
export default class GroupBanTransaction extends TransactionBase {
constructor() {
@@ -33,7 +32,7 @@ export default class GroupBanTransaction extends TransactionBase {
set rBanReason(rBanReason) {
this._rBanReason = rBanReason
this._rBanReasonBytes = this.constructor.utils.stringtoUTF8Array(this._rBanReason.toLocaleLowerCase())
this._rBanReasonBytes = this.constructor.utils.stringtoUTF8Array(this._rBanReason)
this._rBanReasonLength = this.constructor.utils.int32ToBytes(this._rBanReasonBytes.length)
}

View File

@@ -1,6 +1,5 @@
'use strict'
import TransactionBase from '../TransactionBase.js'
import {QORT_DECIMALS} from '../../constants.js'
import TransactionBase from '../TransactionBase'
import { QORT_DECIMALS } from '../../constants'
export default class GroupInviteTransaction extends TransactionBase {
constructor() {

View File

@@ -1,6 +1,5 @@
'use strict'
import TransactionBase from '../TransactionBase.js'
import {QORT_DECIMALS} from '../../constants.js'
import TransactionBase from '../TransactionBase'
import { QORT_DECIMALS } from '../../constants'
export default class GroupKickTransaction extends TransactionBase {
constructor() {
@@ -33,7 +32,7 @@ export default class GroupKickTransaction extends TransactionBase {
set rBanReason(rBanReason) {
this._rBanReason = rBanReason
this._rBanReasonBytes = this.constructor.utils.stringtoUTF8Array(this._rBanReason.toLocaleLowerCase())
this._rBanReasonBytes = this.constructor.utils.stringtoUTF8Array(this._rBanReason)
this._rBanReasonLength = this.constructor.utils.int32ToBytes(this._rBanReasonBytes.length)
}

View File

@@ -1,6 +1,5 @@
'use strict'
import TransactionBase from '../TransactionBase.js'
import {QORT_DECIMALS} from '../../constants.js'
import TransactionBase from '../TransactionBase'
import { QORT_DECIMALS } from '../../constants'
export default class JoinGroupTransaction extends TransactionBase {
constructor() {

View File

@@ -1,6 +1,5 @@
'use strict'
import TransactionBase from '../TransactionBase.js'
import {QORT_DECIMALS} from '../../constants.js'
import TransactionBase from '../TransactionBase'
import { QORT_DECIMALS } from '../../constants'
export default class LeaveGroupTransaction extends TransactionBase {
constructor() {

View File

@@ -1,6 +1,5 @@
'use strict'
import TransactionBase from '../TransactionBase.js'
import {QORT_DECIMALS} from '../../constants.js'
import TransactionBase from '../TransactionBase'
import { QORT_DECIMALS } from '../../constants'
export default class RemoveGroupAdminTransaction extends TransactionBase {
constructor() {

View File

@@ -1,74 +1,109 @@
'use strict';
import TransactionBase from '../TransactionBase.js'
import {store} from '../../../api.js'
import {QORT_DECIMALS} from "../../constants.js"
import TransactionBase from '../TransactionBase'
import { QORT_DECIMALS } from '../../constants'
export default class UpdateGroupTransaction extends TransactionBase {
constructor() {
super()
this.type = 23
}
constructor() {
super()
this.type = 23
}
render(html) {
const conf = store.getState().config
return html`
Are you sure to update this group ?
<div style="background: #eee; padding: 8px; margin: 8px 0; border-radius: 5px;">
render(html) {
return html`
${this._updategroupdialog1}
<div style="background: #eee; padding: 8px; margin: 8px 0; border-radius: 5px;">
<div><span style="color: #000;">${this._updategroupdialog3}: ${this._rGroupNewOwnerDesc}</span></div>
<hr style="border: 2px solid #03a9f4;">
<div><span style="color: #000;">${this._updategroupdialog4}: ${this._rGroupNewName}</span></div>
<hr style="border: 2px solid #03a9f4;">
<div><span style="color: #000;">${this._updategroupdialog5}: ${this._rGroupNewDesc}</span></div>
<hr style="border: 2px solid #03a9f4;">
<div><span style="color: #000;">${this._updategroupdialog6}: ${this._rGroupTypeDesc}</span></div>
</div>
${this._updategroupdialog2}
`
}
</div>
On pressing confirm, the group details will be updated!
`
}
set updategroupdialog1(updategroupdialog1) {
this._updategroupdialog1 = updategroupdialog1
}
set fee(fee) {
this._fee = fee * QORT_DECIMALS
this._feeBytes = this.constructor.utils.int64ToBytes(this._fee)
}
set updategroupdialog2(updategroupdialog2) {
this._updategroupdialog2 = updategroupdialog2
}
set newOwner(newOwner) {
this._newOwner = newOwner instanceof Uint8Array ? newOwner : this.constructor.Base58.decode(newOwner)
}
set updategroupdialog3(updategroupdialog3) {
this._updategroupdialog3 = updategroupdialog3
}
set newIsOpen(newIsOpen) {
this._rGroupType = new Uint8Array(1)
this._rGroupType[0] = newIsOpen
}
set updategroupdialog4(updategroupdialog4) {
this._updategroupdialog4 = updategroupdialog4
}
set newDescription(newDescription) {
this._rGroupDescBytes = this.constructor.utils.stringtoUTF8Array(newDescription.toLocaleLowerCase())
this._rGroupDescLength = this.constructor.utils.int32ToBytes(this._rGroupDescBytes.length)
}
set updategroupdialog5(updategroupdialog5) {
this._updategroupdialog5 = updategroupdialog5
}
set newApprovalThreshold(newApprovalThreshold) {
this._rGroupApprovalThreshold = new Uint8Array(1)
this._rGroupApprovalThreshold[0] = newApprovalThreshold;
}
set groupTypeDesc(groupTypeDesc) {
this._rGroupTypeDesc = groupTypeDesc
}
set newMinimumBlockDelay(newMinimumBlockDelay) {
this._rGroupMinimumBlockDelayBytes = this.constructor.utils.int32ToBytes(newMinimumBlockDelay)
}
set fee(fee) {
this._fee = fee * QORT_DECIMALS
this._feeBytes = this.constructor.utils.int64ToBytes(this._fee)
}
set newMaximumBlockDelay(newMaximumBlockDelay) {
this._rGroupMaximumBlockDelayBytes = this.constructor.utils.int32ToBytes(newMaximumBlockDelay)
}
set newGroupId(newGroupId) {
this._rGroupNewBytes = this.constructor.utils.int32ToBytes(newGroupId)
}
set _groupId(_groupId){
this._groupBytes = this.constructor.utils.int32ToBytes(_groupId)
}
set newOwner(newOwner) {
this._rGroupNewOwnerDesc = newOwner
this._rGroupNewOwner = newOwner instanceof Uint8Array ? newOwner : this.constructor.Base58.decode(newOwner)
}
get params() {
const params = super.params
params.push(
this._groupBytes,
this._newOwner,
this._rGroupDescLength,
this._rGroupDescBytes,
this._rGroupType,
this._rGroupApprovalThreshold,
this._rGroupMinimumBlockDelayBytes,
this._rGroupMaximumBlockDelayBytes,
this._feeBytes
)
return params
}
set newName(newName) {
this._rGroupNewName = newName
this._rGroupNewNameBytes = this.constructor.utils.stringtoUTF8Array(this._rGroupNewName)
this._rGroupNewNameLength = this.constructor.utils.int32ToBytes(this._rGroupNewNameBytes.length)
}
set newDescription(newDescription) {
this._rGroupNewDesc = newDescription
this._rGroupNewDescBytes = this.constructor.utils.stringtoUTF8Array(this._rGroupNewDesc)
this._rGroupNewDescLength = this.constructor.utils.int32ToBytes(this._rGroupNewDescBytes.length)
}
set newIsOpen(newIsOpen) {
this._rGroupNewType = new Uint8Array(1)
this._rGroupNewType[0] = newIsOpen
}
set newApprovalThreshold(newApprovalThreshold) {
this._rGroupNewApprovalThreshold = new Uint8Array(1)
this._rGroupNewApprovalThreshold[0] = newApprovalThreshold
}
set newMinimumBlockDelay(newMinimumBlockDelay) {
this._rGroupNewMinimumBlockDelayBytes = this.constructor.utils.int32ToBytes(newMinimumBlockDelay)
}
set newMaximumBlockDelay(newMaximumBlockDelay) {
this._rGroupNewMaximumBlockDelayBytes = this.constructor.utils.int32ToBytes(newMaximumBlockDelay)
}
get params() {
const params = super.params
params.push(
this._rGroupNewBytes,
this._rGroupNewOwner,
this._rGroupNewDescLength,
this._rGroupNewDescBytes,
this._rGroupNewType,
this._rGroupNewApprovalThreshold,
this._rGroupNewMinimumBlockDelayBytes,
this._rGroupNewMaximumBlockDelayBytes,
this._feeBytes
)
return params
}
}

View File

@@ -1,6 +1,5 @@
'use strict'
import TransactionBase from '../TransactionBase.js'
import {QORT_DECIMALS} from '../../constants.js'
import TransactionBase from '../TransactionBase'
import { QORT_DECIMALS } from '../../constants'
export default class BuyNameTransacion extends TransactionBase {
constructor() {

View File

@@ -1,6 +1,5 @@
'use strict'
import TransactionBase from '../TransactionBase.js'
import {QORT_DECIMALS} from '../../constants.js'
import TransactionBase from '../TransactionBase'
import { QORT_DECIMALS } from '../../constants'
export default class CancelSellNameTransacion extends TransactionBase {
constructor() {

View File

@@ -1,6 +1,5 @@
'use strict'
import TransactionBase from '../TransactionBase.js'
import {QORT_DECIMALS} from '../../constants.js'
import TransactionBase from '../TransactionBase'
import { QORT_DECIMALS } from '../../constants'
export default class RegisterNameTransaction extends TransactionBase {
constructor() {

View File

@@ -1,6 +1,5 @@
'use strict'
import TransactionBase from '../TransactionBase.js'
import {QORT_DECIMALS} from '../../constants.js'
import TransactionBase from '../TransactionBase'
import { QORT_DECIMALS } from '../../constants'
export default class SellNameTransacion extends TransactionBase {
constructor() {

View File

@@ -1,6 +1,5 @@
'use strict'
import TransactionBase from '../TransactionBase.js'
import {QORT_DECIMALS} from '../../constants.js'
import TransactionBase from '../TransactionBase'
import { QORT_DECIMALS } from '../../constants'
export default class UpdateNameTransaction extends TransactionBase {
constructor() {

View File

@@ -1,6 +1,5 @@
'use strict'
import TransactionBase from '../TransactionBase.js'
import {QORT_DECIMALS} from '../../constants.js'
import TransactionBase from '../TransactionBase'
import { QORT_DECIMALS } from '../../constants'
export default class CreatePollTransaction extends TransactionBase {
constructor() {
@@ -25,18 +24,18 @@ export default class CreatePollTransaction extends TransactionBase {
</div>
${this._votedialog6}
<div style="margin-top: 10px; font-weight: bold">
${this._feeDialog}: ${this._feeDisplay}
${this._feeDialog}: ${this._feeDisplay}
</div>
`
}
addOption(option) {
const optionBytes = this.constructor.utils.stringtoUTF8Array(option);
const optionLength = this.constructor.utils.int32ToBytes(optionBytes.length);
this._options.push({ length: optionLength, bytes: optionBytes });
const optionBytes = this.constructor.utils.stringtoUTF8Array(option)
const optionLength = this.constructor.utils.int32ToBytes(optionBytes.length)
this._options.push({ length: optionLength, bytes: optionBytes })
}
set feeDialog(feeDialog){
set feeDialog(feeDialog) {
this._feeDialog = feeDialog
}
@@ -69,7 +68,7 @@ export default class CreatePollTransaction extends TransactionBase {
set rPollName(rPollName) {
this._rPollName = rPollName
this._rPollNameBytes = this.constructor.utils.stringtoUTF8Array(this._rPollName)
this._rPollNameLength = this.constructor.utils.int32ToBytes(this._rPollNameBytes.length);
this._rPollNameLength = this.constructor.utils.int32ToBytes(this._rPollNameBytes.length)
}
@@ -80,13 +79,14 @@ export default class CreatePollTransaction extends TransactionBase {
}
set rOptions(rOptions) {
const optionsArray = rOptions[0].split(', ').map(opt => opt.trim());
const optionsArray = rOptions[0].split(', ').map(opt => opt.trim())
this._pollOptions = optionsArray
for (let i = 0; i < optionsArray.length; i++) {
this.addOption(optionsArray[i]);
this.addOption(optionsArray[i])
}
this._rNumberOfOptionsBytes = this.constructor.utils.int32ToBytes(optionsArray.length);
this._rNumberOfOptionsBytes = this.constructor.utils.int32ToBytes(optionsArray.length)
}
@@ -100,12 +100,13 @@ export default class CreatePollTransaction extends TransactionBase {
this._rPollDescBytes,
this._rNumberOfOptionsBytes
)
// Push the dynamic options
for (let i = 0; i < this._options.length; i++) {
params.push(this._options[i].length, this._options[i].bytes);
params.push(this._options[i].length, this._options[i].bytes)
}
params.push(this._feeBytes);
params.push(this._feeBytes)
return params
}

View File

@@ -1,6 +1,5 @@
'use strict'
import TransactionBase from '../TransactionBase.js'
import {QORT_DECIMALS} from '../../constants.js'
import TransactionBase from '../TransactionBase'
import { QORT_DECIMALS } from '../../constants'
export default class VoteOnPollTransaction extends TransactionBase {
constructor() {
@@ -16,12 +15,12 @@ export default class VoteOnPollTransaction extends TransactionBase {
</div>
${this._votedialog2}
<div style="margin-top: 10px; font-weight: bold">
${this._feeDialog}: ${this._feeDisplay}
${this._feeDialog}: ${this._feeDisplay}
</div>
`
}
set feeDialog(feeDialog){
set feeDialog(feeDialog) {
this._feeDialog = feeDialog
}
@@ -39,14 +38,12 @@ export default class VoteOnPollTransaction extends TransactionBase {
this._feeBytes = this.constructor.utils.int64ToBytes(this._fee)
}
set rPollName(rPollName) {
this._rPollName = rPollName
this._rPollNameBytes = this.constructor.utils.stringtoUTF8Array(this._rPollName)
this._rPollNameLength = this.constructor.utils.int32ToBytes(this._rPollNameBytes.length)
this._rPollNameLength = this.constructor.utils.int32ToBytes(this._rPollNameBytes.length)
}
set rOptionIndex(rOptionIndex) {
this._rOptionIndex = rOptionIndex
this._rOptionIndexBytes = this.constructor.utils.int32ToBytes(this._rOptionIndex)
@@ -55,7 +52,7 @@ export default class VoteOnPollTransaction extends TransactionBase {
get params() {
const params = super.params
params.push(
this._rPollNameLength,
this._rPollNameLength,
this._rPollNameBytes,
this._rOptionIndexBytes,
this._feeBytes

View File

@@ -1,36 +1,34 @@
'use strict'
(function () {
function generateSignatureRegisterNameTransaction(keyPair, lastReference, owner, name, value, fee, timestamp) => {
const data = generateRegisterNameTransactionBase(keyPair.publicKey, lastReference, owner, name, value, fee, timestamp)
return nacl.sign.detached(data, keyPair.privateKey)
}
(function () {
function generateSignatureRegisterNameTransaction(keyPair, lastReference, owner, name, value, fee, timestamp) => {
const data = generateRegisterNameTransactionBase(keyPair.publicKey, lastReference, owner, name, value, fee, timestamp)
return nacl.sign.detached(data, keyPair.privateKey)
}
function generateRegisterNameTransaction(keyPair, lastReference, owner, name, value, fee, timestamp, signature) => {
return appendBuffer(generateRegisterNameTransactionBase(keyPair.publicKey, lastReference, owner, name, value, fee, timestamp), signature)
}
function generateRegisterNameTransaction(keyPair, lastReference, owner, name, value, fee, timestamp, signature) => {
return appendBuffer(generateRegisterNameTransactionBase(keyPair.publicKey, lastReference, owner, name, value, fee, timestamp), signature)
}
function generateRegisterNameTransactionBase(publicKey, lastReference, owner, name, value, fee, timestamp) => {
const txType = TYPES.REGISTER_NAME_TRANSACTION
const typeBytes = int32ToBytes(txType)
const timestampBytes = int64ToBytes(timestamp)
const feeBytes = int64ToBytes(fee * 100000000)
const nameSizeBytes = int32ToBytes(name.length)
const valueSizeBytes = int32ToBytes(value.length)
function generateRegisterNameTransactionBase(publicKey, lastReference, owner, name, value, fee, timestamp) => {
const txType = TYPES.REGISTER_NAME_TRANSACTION
const typeBytes = int32ToBytes(txType)
const timestampBytes = int64ToBytes(timestamp)
const feeBytes = int64ToBytes(fee * 100000000)
const nameSizeBytes = int32ToBytes(name.length)
const valueSizeBytes = int32ToBytes(value.length)
let data = new Uint8Array()
let data = new Uint8Array()
data = appendBuffer(data, typeBytes)
data = appendBuffer(data, timestampBytes)
data = appendBuffer(data, lastReference)
data = appendBuffer(data, publicKey)
data = appendBuffer(data, owner)
data = appendBuffer(data, nameSizeBytes)
data = appendBuffer(data, name)
data = appendBuffer(data, valueSizeBytes)
data = appendBuffer(data, value)
data = appendBuffer(data, feeBytes)
data = appendBuffer(data, typeBytes)
data = appendBuffer(data, timestampBytes)
data = appendBuffer(data, lastReference)
data = appendBuffer(data, publicKey)
data = appendBuffer(data, owner)
data = appendBuffer(data, nameSizeBytes)
data = appendBuffer(data, name)
data = appendBuffer(data, valueSizeBytes)
data = appendBuffer(data, value)
data = appendBuffer(data, feeBytes)
return data
}
}())
return data
}
}())

View File

@@ -1,8 +1,7 @@
'use strict'
import TransactionBase from '../TransactionBase.js'
import publicKeyToAddress from '../../wallet/publicKeyToAddress.js'
import {Base58} from '../../deps/deps.js'
import {DYNAMIC_FEE_TIMESTAMP} from '../../constants.js'
import TransactionBase from '../TransactionBase'
import publicKeyToAddress from '../../wallet/publicKeyToAddress'
import { Base58 } from '../../deps/deps'
import { DYNAMIC_FEE_TIMESTAMP } from '../../constants'
export default class RemoveRewardShareTransaction extends TransactionBase {
constructor() {

View File

@@ -1,10 +1,9 @@
'use strict'
import publicKeyToAddress from '../../wallet/publicKeyToAddress.js'
import TransactionBase from "../TransactionBase.js"
import nacl from '../../deps/nacl-fast.js'
import ed2curve from '../../deps/ed2curve.js'
import {Sha256} from 'asmcrypto.js'
import {DYNAMIC_FEE_TIMESTAMP} from '../../constants.js'
import publicKeyToAddress from '../../wallet/publicKeyToAddress'
import TransactionBase from '../TransactionBase'
import nacl from '../../deps/nacl-fast'
import ed2curve from '../../deps/ed2curve'
import { Sha256 } from 'asmcrypto.js'
import { DYNAMIC_FEE_TIMESTAMP } from '../../constants'
export default class RewardShareTransaction extends TransactionBase {
constructor() {
@@ -42,18 +41,16 @@ export default class RewardShareTransaction extends TransactionBase {
set recipientPublicKey(recipientPublicKey) {
this._base58RecipientPublicKey = recipientPublicKey instanceof Uint8Array ? this.constructor.Base58.encode(recipientPublicKey) : recipientPublicKey
this._recipientPublicKey = this.constructor.Base58.decode(this._base58RecipientPublicKey)
this.recipient = publicKeyToAddress(this._recipientPublicKey)
this.fee = (recipientPublicKey === this.constructor.Base58.encode(this._keyPair.publicKey) ? 0 : 0.001)
const convertedPrivateKey = ed2curve.convertSecretKey(this._keyPair.privateKey)
const convertedPublicKey = ed2curve.convertPublicKey(this._recipientPublicKey)
const sharedSecret = new Uint8Array(32);
nacl.lowlevel.crypto_scalarmult(sharedSecret, convertedPrivateKey, convertedPublicKey);
const sharedSecret = new Uint8Array(32)
nacl.lowlevel.crypto_scalarmult(sharedSecret, convertedPrivateKey, convertedPublicKey)
this._rewardShareSeed = new Sha256().process(sharedSecret).finish().result
this._base58RewardShareSeed = this.constructor.Base58.encode(this._rewardShareSeed)
this._rewardShareKeyPair = nacl.sign.keyPair.fromSeed(this._rewardShareSeed)
if (new Date(this._timestamp).getTime() >= DYNAMIC_FEE_TIMESTAMP) {

View File

@@ -1,6 +1,6 @@
import Base58 from '../../../deps/Base58.js'
import nacl from '../../../deps/nacl-fast.js'
import utils from '../../../deps/utils.js'
import Base58 from '../../../deps/Base58'
import nacl from '../../../deps/nacl-fast'
import utils from '../../../deps/utils'
const signTradeBotTransaction = (unsignedTxn, keyPair) => {
if (!unsignedTxn) {

View File

@@ -1,6 +1,6 @@
import {request} from '../../../fetch-request.js'
import {deleteTradeOffer, signTradeBotTxn} from '../../../tradeRequest.js'
import {processTransaction} from '../../../createTransaction.js'
import {request} from '../../../fetch-request'
import {deleteTradeOffer, signTradeBotTxn} from '../../../tradeRequest'
import {processTransaction} from '../../../createTransaction'
export const cancelAllOffers = async (requestObject) => {
const keyPair = requestObject.keyPair
@@ -13,6 +13,7 @@ export const cancelAllOffers = async (requestObject) => {
}
const myOpenOffers = await getMyOpenOffers()
let response = true
myOpenOffers.forEach(async (openOffer) => {
@@ -20,5 +21,6 @@ export const cancelAllOffers = async (requestObject) => {
let signedTxnBytes = await signTradeBotTxn(unsignedTxn, keyPair)
await processTransaction(signedTxnBytes)
})
return response
}

View File

@@ -1,29 +1,30 @@
import PaymentTransaction from './PaymentTransaction.js'
import RegisterNameTransaction from './names/RegisterNameTransaction.js'
import UpdateNameTransaction from './names/UpdateNameTransaction.js'
import SellNameTransacion from './names/SellNameTransacion.js'
import CancelSellNameTransacion from './names/CancelSellNameTransacion.js'
import BuyNameTransacion from './names/BuyNameTransacion.js'
import MessageTransaction from './MessageTransaction.js'
import ChatTransaction from './chat/ChatTransaction.js'
import GroupChatTransaction from './chat/GroupChatTransaction.js'
import PublicizeTransaction from './PublicizeTransaction.js'
import CreateGroupTransaction from './groups/CreateGroupTransaction.js'
import AddGroupAdminTransaction from './groups/AddGroupAdminTransaction.js'
import RemoveGroupAdminTransaction from './groups/RemoveGroupAdminTransaction.js'
import GroupBanTransaction from './groups/GroupBanTransaction.js'
import CancelGroupBanTransaction from './groups/CancelGroupBanTransaction.js'
import GroupKickTransaction from './groups/GroupKickTransaction.js'
import GroupInviteTransaction from './groups/GroupInviteTransaction.js'
import CancelGroupInviteTransaction from './groups/CancelGroupInviteTransaction.js'
import JoinGroupTransaction from './groups/JoinGroupTransaction.js'
import LeaveGroupTransaction from './groups/LeaveGroupTransaction.js'
import RewardShareTransaction from './reward-share/RewardShareTransaction.js'
import RemoveRewardShareTransaction from './reward-share/RemoveRewardShareTransaction.js'
import TransferPrivsTransaction from './TransferPrivsTransaction.js'
import DeployAtTransaction from './DeployAtTransaction.js'
import VoteOnPollTransaction from './polls/VoteOnPollTransaction.js'
import CreatePollTransaction from './polls/CreatePollTransaction.js'
import PaymentTransaction from './PaymentTransaction'
import RegisterNameTransaction from './names/RegisterNameTransaction'
import UpdateNameTransaction from './names/UpdateNameTransaction'
import SellNameTransacion from './names/SellNameTransacion'
import CancelSellNameTransacion from './names/CancelSellNameTransacion'
import BuyNameTransacion from './names/BuyNameTransacion'
import MessageTransaction from './MessageTransaction'
import ChatTransaction from './chat/ChatTransaction'
import GroupChatTransaction from './chat/GroupChatTransaction'
import PublicizeTransaction from './PublicizeTransaction'
import CreateGroupTransaction from './groups/CreateGroupTransaction'
import UpdateGroupTransaction from './groups/UpdateGroupTransaction'
import AddGroupAdminTransaction from './groups/AddGroupAdminTransaction'
import RemoveGroupAdminTransaction from './groups/RemoveGroupAdminTransaction'
import GroupBanTransaction from './groups/GroupBanTransaction'
import CancelGroupBanTransaction from './groups/CancelGroupBanTransaction'
import GroupKickTransaction from './groups/GroupKickTransaction'
import GroupInviteTransaction from './groups/GroupInviteTransaction'
import CancelGroupInviteTransaction from './groups/CancelGroupInviteTransaction'
import JoinGroupTransaction from './groups/JoinGroupTransaction'
import LeaveGroupTransaction from './groups/LeaveGroupTransaction'
import RewardShareTransaction from './reward-share/RewardShareTransaction'
import RemoveRewardShareTransaction from './reward-share/RemoveRewardShareTransaction'
import TransferPrivsTransaction from './TransferPrivsTransaction'
import DeployAtTransaction from './DeployAtTransaction'
import VoteOnPollTransaction from './polls/VoteOnPollTransaction'
import CreatePollTransaction from './polls/CreatePollTransaction'
export const transactionTypes = {
2: PaymentTransaction,
@@ -40,6 +41,7 @@ export const transactionTypes = {
181: GroupChatTransaction,
19: PublicizeTransaction,
22: CreateGroupTransaction,
23: UpdateGroupTransaction,
24: AddGroupAdminTransaction,
25: RemoveGroupAdminTransaction,
26: GroupBanTransaction,

View File

@@ -1,11 +1,11 @@
export const randomBase58Generator = (digits) => {
digits = digits || 0
let base58 = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'.split('')
let result = ''
let char
while (result.length < digits) {
char = base58[Math.random() * 57 >> 0]
if (result.indexOf(char) === -1) result += char
}
return result
digits = digits || 0
let base58 = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'.split('')
let result = ''
let char
while (result.length < digits) {
char = base58[Math.random() * 57 >> 0]
if (result.indexOf(char) === -1) result += char
}
return result
}

View File

@@ -1,31 +1,31 @@
import {store} from '../../api.js'
import { store } from '../../api'
let subscriptions = []
// Have to wait with init because something import stateAwait before the store gets initialized
let initialized = false
const init = () => {
initialized = true
store.subscribe(() => {
const state = store.getState()
initialized = true
store.subscribe(() => {
const state = store.getState()
subscriptions = subscriptions.filter(fn => fn(state))
})
subscriptions = subscriptions.filter(fn => fn(state))
})
}
export const stateAwait = fn => {
return new Promise((resolve, reject) => {
// Check immediately...then if not true store it
if (!initialized) {
init()
}
if (fn(store.getState())) resolve()
subscriptions.push(state => {
if (fn(state)) {
resolve()
return true
}
return false
})
})
return new Promise((resolve, reject) => {
// Check immediately...then if not true store it
if (!initialized) {
init()
}
if (fn(store.getState())) resolve()
subscriptions.push(state => {
if (fn(state)) {
resolve()
return true
}
return false
})
})
}

View File

@@ -1,5 +1,5 @@
import publicKeyToAddress from './publicKeyToAddress'
import Base58 from '../deps/Base58.js'
import Base58 from '../deps/Base58'
export const base58PublicKeyToAddress = (base58pubkey, qora = false) => {
const decodePubKey = Base58.decode(base58pubkey)

View File

@@ -1,10 +1,10 @@
import Base58 from '../deps/Base58.js'
import BROKEN_RIPEMD160 from '../deps/broken-ripemd160.js'
import RIPEMD160 from '../deps/ripemd160.js'
import utils from '../deps/utils.js'
import {ADDRESS_VERSION} from '../constants.js'
import {Buffer} from 'buffer'
import {Sha256} from 'asmcrypto.js'
import Base58 from '../deps/Base58'
import BROKEN_RIPEMD160 from '../deps/broken-ripemd160'
import RIPEMD160 from '../deps/ripemd160'
import utils from '../deps/utils'
import { ADDRESS_VERSION } from '../constants'
import { Buffer } from 'buffer'
import { Sha256 } from 'asmcrypto.js'
const repeatSHA256 = (passphrase, hashes) => {
let hash = passphrase

View File

@@ -1,8 +1,8 @@
import Base58 from '../deps/Base58.js'
import Base58 from '../deps/Base58'
export const validateAddress = (address) => {
const decodePubKey = Base58.decode(address)
return decodePubKey instanceof Uint8Array && decodePubKey.length == 25;
return decodePubKey instanceof Uint8Array && decodePubKey.length == 25
}

View File

@@ -1,4 +1,4 @@
import {store} from './api.js'
import { store } from './api'
let config = false
let loaded = false