From 8edd13a083f13e466e4bbd39f21a832df2b35804 Mon Sep 17 00:00:00 2001 From: AlphaX-Projects <77661270+AlphaX-Projects@users.noreply.github.com> Date: Fri, 13 Jan 2023 09:32:26 +0100 Subject: [PATCH 1/5] Update dependencies --- package.json | 2 +- qortal-ui-core/package.json | 17 +- .../login-view/create-account-section.js | 14 +- .../random-sentence-generator.js | 160 ++++++++++++++++++ .../functional-components/verb-past-tense.js | 36 ++++ .../src/functional-components/wordlists.js | 27 +++ qortal-ui-plugins/package.json | 16 +- 7 files changed, 247 insertions(+), 25 deletions(-) create mode 100644 qortal-ui-core/src/functional-components/random-sentence-generator.js create mode 100644 qortal-ui-core/src/functional-components/verb-past-tense.js create mode 100644 qortal-ui-core/src/functional-components/wordlists.js diff --git a/package.json b/package.json index 67893cef..f1e5a6b9 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "os-locale": "3.0.0" }, "devDependencies": { - "electron": "22.0.0", + "electron": "22.0.2", "electron-builder": "23.6.0", "electron-packager": "17.1.1", "@electron/notarize": "1.2.3", diff --git a/qortal-ui-core/package.json b/qortal-ui-core/package.json index d5b00b64..d52b6ab0 100644 --- a/qortal-ui-core/package.json +++ b/qortal-ui-core/package.json @@ -58,23 +58,22 @@ "@rollup/plugin-commonjs": "24.0.0", "@rollup/plugin-node-resolve": "15.0.1", "@rollup/plugin-replace": "5.0.2", - "@rollup/plugin-terser": "0.2.1", - "@vaadin/button": "23.3.2", - "@vaadin/grid": "23.3.2", - "@vaadin/icons": "23.3.2", - "@vaadin/password-field": "23.3.2", - "@vaadin/tooltip": "23.3.2", + "@rollup/plugin-terser": "0.3.0", + "@vaadin/button": "23.3.3", + "@vaadin/grid": "23.3.3", + "@vaadin/icons": "23.3.3", + "@vaadin/password-field": "23.3.3", + "@vaadin/tooltip": "23.3.3", "asmcrypto.js": "2.3.2", "bcryptjs": "2.4.3", "epml": "0.3.3", "file-saver": "2.0.5", - "lit": "2.5.0", + "lit": "2.6.1", "lit-translate": "2.0.1", "pwa-helpers": "0.9.1", - "random-sentence-generator": "0.0.8", "redux": "4.2.0", "redux-thunk": "2.4.2", - "rollup": "3.9.1", + "rollup": "3.10.0", "rollup-plugin-node-globals": "1.4.0", "rollup-plugin-progress": "1.1.2", "rollup-plugin-scss": "3.0.0" diff --git a/qortal-ui-core/src/components/login-view/create-account-section.js b/qortal-ui-core/src/components/login-view/create-account-section.js index b285118f..48c27985 100644 --- a/qortal-ui-core/src/components/login-view/create-account-section.js +++ b/qortal-ui-core/src/components/login-view/create-account-section.js @@ -4,11 +4,13 @@ import { store } from '../../store.js' import { use, get, translate, translateUnsafeHTML, registerTranslateConfig } from 'lit-translate' import { createWallet } from '../../../../qortal-ui-crypto/api/createWallet.js' -import FileSaver from 'file-saver' import { doLogin, doLogout, doSelectAddress } from '../../redux/app/app-actions.js' import { doStoreWallet } from '../../redux/user/user-actions.js' import { checkApiKey } from '../../apiKeyUtils.js' +import FileSaver from 'file-saver' +import ripple from '../../functional-components/loading-ripple.js' import snackbar from '../../functional-components/snackbar.js' +import '../../functional-components/random-sentence-generator.js' import '@material/mwc-button' import '@material/mwc-checkbox' import '@material/mwc-textfield' @@ -22,8 +24,6 @@ import '@polymer/paper-input/paper-input.js' import '@polymer/paper-tooltip/paper-tooltip.js' import '@vaadin/text-field/vaadin-text-field.js' import '@vaadin/password-field/vaadin-password-field.js' -import 'random-sentence-generator' -import ripple from '../../functional-components/loading-ripple.js' let lastPassword = '' @@ -393,17 +393,17 @@ class CreateAccountSection extends connect(store)(LitElement) {
diff --git a/qortal-ui-core/src/functional-components/random-sentence-generator.js b/qortal-ui-core/src/functional-components/random-sentence-generator.js new file mode 100644 index 00000000..b9482fb5 --- /dev/null +++ b/qortal-ui-core/src/functional-components/random-sentence-generator.js @@ -0,0 +1,160 @@ +// Author: irontiga + +'use strict' +import { LitElement, html, css } from 'lit' +import * as WORDLISTS from './wordlists.js' + +class RandomSentenceGenerator extends LitElement { + static get properties() { + return { + template: { + type: String, + attribute: 'template' + }, + parsedString: { + type: String + }, + fetchedWordlistCount: { + type: Number, + value: 0 + }, + capitalize: { + type: Boolean + }, + partsOfSpeechMap: { + type: Object + }, + templateEntropy: { + type: Number, + reflect: true, + attribute: 'template-entropy' + }, + maxWordLength: { + type: Number, + attribute: 'max-word-length' + } + } + } + + constructor() { + super() + this.template = 'adjective noun verb adverb.' + this.maxWordLength = 0 + this.parsedString = '' + this.fetchedWordlistCount = 0 + this.capitalize = true + this.partsOfSpeechMap = { + 'noun': 'nouns', + 'adverb': 'adverbs', + 'adv': 'adverbs', + 'verb': 'verbs', + 'interjection': 'interjections', + 'adjective': 'adjectives', + 'adj': 'adjectives', + 'verbed': 'verbed' + } + this.partsOfSpeech = Object.keys(this.partsOfSpeechMap) + this._wordlists = WORDLISTS + } + + updated(changedProperties) { + let regen = false + if (changedProperties.has('template')) { + regen = true + } + if (changedProperties.has('maxWordLength')) { + console.dir(this.maxWordLength) + if (this.maxWordLength) { + const wl = { ...this._wordlists } + for (const partOfSpeech in this._wordlists) { + console.log(this._wordlists[partOfSpeech]) + if (Array.isArray(this._wordlists[partOfSpeech])) { + wl[partOfSpeech] = this._wordlists[partOfSpeech].filter(word => word.length <= this.maxWordLength) + } + } + this._wordlists = wl + } + regen = true + } + if (regen) this.generate() + } + + _RNG(entropy) { + if (entropy > 1074) { + throw new Error('Javascript can not handle that much entropy!') + } + let randNum = 0 + const crypto = window.crypto || window.msCrypto + + if (crypto) { + const entropy256 = Math.ceil(entropy / 8) + + let buffer = new Uint8Array(entropy256) + crypto.getRandomValues(buffer) + + randNum = buffer.reduce((num, value) => { + return num * value + }, 1) / Math.pow(256, entropy256) + } else { + console.warn('Secure RNG not found. Using Math.random') + randNum = Math.random() + } + return randNum + } + + setRNG(fn) { + this._RNG = fn + } + + _captitalize(str) { + return str.charAt(0).toUpperCase() + str.slice(1) + } + + getWord(partOfSpeech) { + const words = this._wordlists[this.partsOfSpeechMap[partOfSpeech]] + const requiredEntropy = Math.log(words.length) / Math.log(2) + const index = this._RNG(requiredEntropy) * words.length + + return { + word: words[Math.round(index)], + entropy: words.length + } + } + + generate() { + this.parsedString = this.parse(this.template) + } + + parse(template) { + const split = template.split(/[\s]/g) + let entropy = 1 + const final = split.map(word => { + const lower = word.toLowerCase() + + this.partsOfSpeech.some(partOfSpeech => { + const partOfSpeechIndex = lower.indexOf(partOfSpeech) // Check it exists + const nextChar = word.charAt(partOfSpeech.length) + + if (partOfSpeechIndex === 0 && !(nextChar && (nextChar.match(/[a-zA-Z]/g) != null))) { + const replacement = this.getWord(partOfSpeech) + word = replacement.word + word.slice(partOfSpeech.length) // Append the rest of the "word" (punctuation) + entropy = entropy * replacement.entropy + return true + } + }) + return word + }) + this.templateEntropy = Math.floor(Math.log(entropy) / Math.log(8)) + return final.join(' ') + } + + render() { + return html` + ${this.parsedString} + ` + } +} + +customElements.define('random-sentence-generator', RandomSentenceGenerator) + +export default RandomSentenceGenerator diff --git a/qortal-ui-core/src/functional-components/verb-past-tense.js b/qortal-ui-core/src/functional-components/verb-past-tense.js new file mode 100644 index 00000000..198e80e9 --- /dev/null +++ b/qortal-ui-core/src/functional-components/verb-past-tense.js @@ -0,0 +1,36 @@ +// Sourced from https://gist.github.com/letsgetrandy/1e05a68ea74ba6736eb5 + +export const EXCEPTIONS = { + 'are': 'were', + 'eat': 'ate', + 'go': 'went', + 'have': 'had', + 'inherit': 'inherited', + 'is': 'was', + 'run': 'ran', + 'sit': 'sat', + 'visit': 'visited' +} + +export const getPastTense = (verb, exceptions = EXCEPTIONS) => { + if (exceptions[verb]) { + return exceptions[verb] + } + if ((/e$/i).test(verb)) { + return verb + 'd' + } + if ((/[aeiou]c$/i).test(verb)) { + return verb + 'ked' + } + // for american english only + if ((/el$/i).test(verb)) { + return verb + 'ed' + } + if ((/[aeio][aeiou][dlmnprst]$/).test(verb)) { + return verb + 'ed' + } + if ((/[aeiou][bdglmnprst]$/i).test(verb)) { + return verb.replace(/(.+[aeiou])([bdglmnprst])/, '$1$2$2ed') + } + return verb + 'ed' +} diff --git a/qortal-ui-core/src/functional-components/wordlists.js b/qortal-ui-core/src/functional-components/wordlists.js new file mode 100644 index 00000000..903889a7 --- /dev/null +++ b/qortal-ui-core/src/functional-components/wordlists.js @@ -0,0 +1,27 @@ +import { getPastTense } from './verb-past-tense.js' + +export const verbs = [ + 'abase', 'abate', 'abduct', 'abet', 'abhor', 'abide', 'abjure', 'ablate', 'abort', 'abound', 'abseil', 'absorb', 'abuse', 'abut', 'accede', 'accent', 'accept', 'access', 'accord', 'accost', 'accrue', 'accuse', 'ache', 'acquit', 'act', 'adapt', 'add', 'addict', 'addle', 'adduce', 'adhere', 'adjoin', 'adjust', 'admire', 'admit', 'adopt', 'adore', 'adorn', 'advert', 'advise', 'aerate', 'affect', 'affirm', 'affix', 'afford', 'age', 'agree', 'aid', 'aim', 'alarm', 'alert', 'alight', 'align', 'allay', 'allege', 'allot', 'allow', 'alloy', 'allure', 'ally', 'alter', 'amass', 'amaze', 'amble', 'ambush', 'amend', 'amount', 'amuse', 'anger', 'angle', 'anneal', 'annex', 'annoy', 'annul', 'anoint', 'answer', 'ape', 'appeal', 'appear', 'append', 'apply', 'arc', 'arch', 'argue', 'arise', 'arm', 'array', 'arrest', 'arrive', 'arrow', 'ascend', 'ask', 'aspire', 'assail', 'assay', 'assent', 'assert', 'assess', 'assign', 'assist', 'assort', 'assume', 'assure', 'atone', 'attach', 'attack', 'attain', 'attend', 'attest', 'attire', 'attune', 'audit', 'augur', 'author', 'avail', 'avenge', 'aver', 'avert', 'avoid', 'await', 'awake', 'awaken', 'award', 'awe', 'babble', 'back', 'badge', 'badger', 'baffle', 'bag', 'bail', 'bait', 'bake', 'bald', 'bale', 'ball', 'ballot', 'ban', 'band', 'bandy', 'bang', 'banish', 'bank', 'banter', 'bar', 'barb', 'barber', 'bard', 'bare', 'barge', 'bark', 'barn', 'barrel', 'barter', 'base', 'bash', 'bask', 'baste', 'bat', 'batch', 'bathe', 'batten', 'batter', 'battle', 'bawl', 'bay', 'be', 'beach', 'beacon', 'bead', 'beam', 'bean', 'bear', 'beard', 'beat', 'become', 'bed', 'beef', 'beep', 'beetle', 'befall', 'befit', 'beg', 'beget', 'beggar', 'begin', 'behave', 'behead', 'behold', 'belay', 'belch', 'belie', 'bell', 'bellow', 'belly', 'belong', 'belt', 'bemoan', 'bench', 'bend', 'berate', 'berry', 'beset', 'best', 'bestir', 'bestow', 'bet', 'betide', 'betray', 'better', 'bevel', 'bewail', 'beware', 'bias', 'bib', 'bicker', 'bid', 'bide', 'bilge', 'bill', 'billet', 'billow', 'bin', 'bind', 'birdie', 'birth', 'bisect', 'bit', 'bite', 'bitter', 'black', 'blame', 'blanch', 'blank', 'blare', 'blast', 'blaze', 'bleach', 'bleat', 'bleed', 'bleep', 'blench', 'blend', 'bless', 'blight', 'blind', 'blink', 'blip', 'bliss', 'blitz', 'bloat', 'blob', 'blood', 'bloody', 'bloom', 'blot', 'blotch', 'blow', 'blue', 'bluff', 'blunt', 'blur', 'blurb', 'blurt', 'blush', 'board', 'boast', 'bob', 'bode', 'body', 'bog', 'bogey', 'boggle', 'boil', 'bolt', 'bomb', 'bond', 'bone', 'bonnet', 'boo', 'book', 'boom', 'boost', 'boot', 'booze', 'bop', 'bore', 'borrow', 'boss', 'botch', 'bother', 'bottle', 'bottom', 'bounce', 'bound', 'bout', 'bow', 'bowel', 'bowl', 'box', 'brace', 'brag', 'braid', 'braise', 'brake', 'branch', 'brand', 'brave', 'brawl', 'bray', 'breach', 'bread', 'break', 'breed', 'breeze', 'brew', 'bribe', 'brick', 'bridge', 'bridle', 'brief', 'brim', 'brine', 'bring', 'broach', 'broil', 'bronze', 'brook', 'brown', 'browse', 'bruise', 'brush', 'bubble', 'buck', 'bucket', 'buckle', 'bud', 'budge', 'budget', 'buffet', 'bug', 'bugle', 'build', 'bulge', 'bulk', 'bull', 'bully', 'bumble', 'bump', 'bunch', 'bundle', 'bung', 'bungle', 'bunk', 'bunker', 'buoy', 'burble', 'burden', 'burgle', 'burn', 'burp', 'burr', 'burrow', 'burst', 'bury', 'bus', 'bush', 'busk', 'bust', 'bustle', 'busy', 'butt', 'button', 'buy', 'buzz', 'bypass', 'cab', 'cabal', 'cabin', 'cable', 'cache', 'cackle', 'cadge', 'cage', 'cajole', 'cake', 'call', 'calm', 'calve', 'camber', 'camp', 'can', 'canal', 'cancel', 'candle', 'candy', 'cane', 'cannon', 'canoe', 'canopy', 'cant', 'canter', 'cap', 'caper', 'card', 'care', 'career', 'caress', 'carol', 'carp', 'carpet', 'carry', 'cart', 'carve', 'case', 'cash', 'cast', 'castle', 'cat', 'catch', 'cater', 'caucus', 'cause', 'cave', 'cavern', 'cease', 'cede', 'cellar', 'cement', 'censor', 'chafe', 'chain', 'chair', 'chalk', 'champ', 'chance', 'change', 'chant', 'chap', 'char', 'charge', 'charm', 'chart', 'chase', 'chat', 'cheat', 'check', 'cheep', 'cheer', 'chew', 'chide', 'chill', 'chime', 'chin', 'chink', 'chip', 'chirp', 'chisel', 'chock', 'choir', 'choke', 'choose', 'chop', 'chord', 'chorus', 'chrome', 'chuck', 'chuff', 'chug', 'chum', 'chunk', 'churn', 'chute', 'cinder', 'cipher', 'circle', 'cite', 'clad', 'claim', 'clam', 'clamp', 'clang', 'clank', 'clap', 'clash', 'clasp', 'class', 'claw', 'clean', 'clear', 'cleat', 'cleave', 'clench', 'clerk', 'click', 'climax', 'climb', 'clinch', 'cling', 'clink', 'clip', 'clique', 'cloak', 'clock', 'clog', 'clone', 'close', 'closet', 'clot', 'cloud', 'clout', 'clown', 'club', 'cluck', 'clue', 'clump', 'clutch', 'coach', 'coal', 'coast', 'coat', 'coax', 'cobble', 'cobweb', 'cockle', 'cocoon', 'coddle', 'code', 'codify', 'coerce', 'coffer', 'coffin', 'cog', 'cohere', 'coil', 'coin', 'coke', 'collar', 'comb', 'combat', 'come', 'commit', 'compel', 'comply', 'con', 'concur', 'cone', 'confer', 'convey', 'convoy', 'cook', 'cool', 'cope', 'copper', 'copy', 'cord', 'cordon', 'core', 'cork', 'corn', 'corner', 'corral', 'cosset', 'cost', 'cotton', 'couch', 'cough', 'count', 'couple', 'course', 'court', 'cover', 'covet', 'cowl', 'cox', 'crab', 'crack', 'cradle', 'craft', 'cram', 'cramp', 'crane', 'crank', 'crash', 'crate', 'crater', 'crave', 'crawl', 'crayon', 'craze', 'creak', 'cream', 'crease', 'create', 'credit', 'creed', 'creep', 'crest', 'crew', 'crib', 'crick', 'crimp', 'cringe', 'crisp', 'croak', 'crook', 'croon', 'crop', 'cross', 'crouch', 'crowd', 'crown', 'cruise', 'crunch', 'crush', 'crust', 'crutch', 'cry', 'cube', 'cuckoo', 'cuddle', 'cudgel', 'cue', 'cuff', 'cull', 'cup', 'curb', 'curd', 'curdle', 'cure', 'curl', 'curry', 'curse', 'curve', 'cuss', 'cut', 'cycle', 'dab', 'dabble', 'dagger', 'dally', 'dam', 'damage', 'damn', 'damp', 'dampen', 'dance', 'dangle', 'dapple', 'dare', 'darken', 'darn', 'dart', 'dash', 'date', 'daub', 'daunt', 'dawdle', 'daze', 'dazzle', 'deaden', 'deafen', 'deal', 'debar', 'debase', 'debate', 'debit', 'debug', 'debut', 'decamp', 'decant', 'decay', 'decide', 'deck', 'decode', 'decoy', 'decree', 'decry', 'deduce', 'deduct', 'deem', 'deepen', 'deface', 'defame', 'defeat', 'defect', 'defend', 'defer', 'defile', 'define', 'deform', 'defray', 'defuse', 'defy', 'deify', 'deign', 'delay', 'delete', 'delude', 'deluge', 'delve', 'demand', 'demean', 'demise', 'demote', 'demur', 'den', 'denote', 'dent', 'denude', 'deny', 'depart', 'depend', 'depict', 'deploy', 'deport', 'depose', 'depute', 'derail', 'deride', 'derive', 'desert', 'design', 'desire', 'desist', 'detach', 'detail', 'detain', 'detect', 'deter', 'detest', 'detour', 'devil', 'devise', 'devote', 'devour', 'dial', 'diaper', 'dice', 'die', 'diet', 'differ', 'dig', 'digest', 'dilate', 'dilute', 'dim', 'dimple', 'din', 'dine', 'dint', 'dip', 'direct', 'disarm', 'disc', 'disco', 'dish', 'dismay', 'disown', 'dispel', 'disuse', 'ditch', 'dither', 'dive', 'divert', 'divest', 'divide', 'divine', 'dizzy', 'do', 'dock', 'docket', 'doctor', 'dodge', 'dog', 'dole', 'doll', 'dolly', 'dome', 'donate', 'doodle', 'doom', 'dope', 'dose', 'dot', 'dote', 'double', 'doubt', 'douse', 'dowel', 'down', 'dowse', 'doze', 'drab', 'draft', 'drag', 'drain', 'drape', 'draw', 'drawl', 'dray', 'dread', 'dream', 'dredge', 'drench', 'dress', 'drift', 'drill', 'drink', 'drip', 'drive', 'drivel', 'drone', 'drool', 'droop', 'drop', 'drown', 'drowse', 'drudge', 'drug', 'drum', 'dry', 'dub', 'duck', 'duel', 'duet', 'dull', 'dumb', 'dummy', 'dump', 'dun', 'dupe', 'dust', 'dwarf', 'dwell', 'dye', 'ear', 'earn', 'ease', 'eat', 'ebb', 'echo', 'eddy', 'edge', 'edify', 'edit', 'efface', 'egg', 'egress', 'eject', 'elapse', 'elate', 'elbow', 'elect', 'elicit', 'elide', 'elope', 'elude', 'embalm', 'embark', 'embed', 'embody', 'emboss', 'emerge', 'emit', 'employ', 'empty', 'enable', 'enact', 'enamel', 'encamp', 'encase', 'encode', 'encore', 'end', 'endear', 'endow', 'endure', 'enfold', 'engage', 'engulf', 'enjoin', 'enjoy', 'enlist', 'enrage', 'enrich', 'ensue', 'ensure', 'entail', 'enter', 'entice', 'entomb', 'entrap', 'envy', 'equal', 'equate', 'equip', 'erase', 'erect', 'erode', 'err', 'erupt', 'escape', 'eschew', 'escort', 'escrow', 'essay', 'esteem', 'etch', 'evade', 'evict', 'evince', 'evoke', 'evolve', 'exact', 'exalt', 'exceed', 'excel', 'except', 'excess', 'excise', 'excite', 'excuse', 'exempt', 'exert', 'exeunt', 'exhale', 'exhort', 'exhume', 'exile', 'exist', 'expand', 'expect', 'expel', 'expend', 'expire', 'export', 'expose', 'extend', 'extol', 'extort', 'exude', 'exult', 'eye', 'fable', 'face', 'facet', 'factor', 'fade', 'fail', 'faint', 'fair', 'fake', 'fall', 'falter', 'fame', 'fan', 'fancy', 'farce', 'fare', 'farm', 'fast', 'fasten', 'fat', 'fate', 'father', 'fathom', 'fatten', 'fault', 'fawn', 'fear', 'feast', 'fee', 'feed', 'feel', 'feign', 'fell', 'fence', 'fend', 'ferret', 'ferry', 'fester', 'fetch', 'fettle', 'feud', 'fever', 'fib', 'fiddle', 'fidget', 'field', 'fife', 'fight', 'figure', 'file', 'fill', 'fillet', 'fillip', 'film', 'filter', 'fin', 'find', 'fine', 'finger', 'finish', 'fire', 'firm', 'fish', 'fit', 'fitter', 'fix', 'fizz', 'fizzle', 'flack', 'flag', 'flail', 'flake', 'flame', 'flank', 'flap', 'flare', 'flash', 'flat', 'flaunt', 'flaw', 'flay', 'flee', 'fleece', 'fleet', 'flesh', 'flex', 'flick', 'flight', 'flinch', 'fling', 'flint', 'flip', 'flit', 'float', 'flock', 'flog', 'flood', 'floor', 'flop', 'floss', 'flour', 'flout', 'flow', 'flower', 'fluff', 'flurry', 'flush', 'flute', 'flux', 'fly', 'foal', 'foam', 'fob', 'focus', 'fodder', 'fog', 'foil', 'foist', 'fold', 'folio', 'follow', 'foment', 'fondle', 'fool', 'foot', 'forage', 'foray', 'forbid', 'force', 'ford', 'forego', 'forest', 'forge', 'forget', 'fork', 'form', 'format', 'foster', 'foul', 'found', 'fowl', 'fox', 'frame', 'frank', 'fray', 'freak', 'free', 'freeze', 'frenzy', 'fresh', 'fret', 'friend', 'fright', 'frill', 'fringe', 'frisk', 'frock', 'frog', 'frolic', 'front', 'frost', 'froth', 'frown', 'fruit', 'fry', 'fudge', 'fuel', 'full', 'fumble', 'fume', 'fun', 'fund', 'funk', 'funnel', 'fur', 'furrow', 'fuse', 'fuss', 'fuzz', 'gabble', 'gad', 'gaff', 'gag', 'gaggle', 'gain', 'gait', 'gall', 'gallop', 'gamble', 'gambol', 'game', 'gang', 'gap', 'gape', 'garage', 'garble', 'garden', 'gargle', 'garner', 'garter', 'gas', 'gash', 'gasp', 'gate', 'gather', 'gauge', 'gavel', 'gaze', 'gear', 'gel', 'gem', 'gender', 'gentle', 'get', 'ghost', 'gibber', 'gibbet', 'giddy', 'gift', 'gig', 'giggle', 'gimlet', 'gin', 'ginger', 'gird', 'girdle', 'girth', 'give', 'glad', 'glance', 'glare', 'glass', 'glaze', 'gleam', 'glean', 'glide', 'glint', 'gloat', 'globe', 'gloom', 'glory', 'gloss', 'glove', 'glow', 'glower', 'glue', 'glut', 'gnarl', 'gnash', 'gnaw', 'go', 'goad', 'gobble', 'golf', 'gong', 'goose', 'gore', 'gorge', 'gossip', 'gouge', 'govern', 'gown', 'grab', 'grace', 'grade', 'graft', 'grain', 'grant', 'graph', 'grasp', 'grass', 'grate', 'grave', 'gravel', 'graze', 'grease', 'green', 'greet', 'grey', 'grieve', 'grill', 'grin', 'grind', 'grip', 'gripe', 'grit', 'groan', 'groin', 'groom', 'groove', 'grope', 'gross', 'grouch', 'ground', 'group', 'grouse', 'grout', 'grovel', 'grow', 'growl', 'grub', 'grudge', 'grunt', 'guard', 'guess', 'guest', 'guffaw', 'guide', 'guilt', 'guise', 'gulf', 'gull', 'gully', 'gulp', 'gum', 'gun', 'gurgle', 'gush', 'gust', 'gut', 'gutter', 'guy', 'guzzle', 'gyrate', 'habit', 'hack', 'haft', 'haggle', 'hail', 'hale', 'hallo', 'halo', 'halt', 'halter', 'halve', 'ham', 'hammer', 'hamper', 'hand', 'handle', 'hang', 'hanker', 'happen', 'harass', 'harden', 'hark', 'harm', 'harp', 'harrow', 'harry', 'hash', 'hasp', 'hassle', 'haste', 'hasten', 'hat', 'hatch', 'hate', 'haul', 'haunt', 'have', 'haven', 'havoc', 'hawk', 'hay', 'hazard', 'haze', 'head', 'heal', 'heap', 'hear', 'heart', 'heat', 'heave', 'heckle', 'hector', 'hedge', 'heed', 'heel', 'heft', 'hell', 'hello', 'helm', 'help', 'hem', 'herald', 'herd', 'hew', 'hex', 'hiccup', 'hide', 'hijack', 'hike', 'hill', 'hilt', 'hinder', 'hinge', 'hint', 'hip', 'hiss', 'hit', 'hitch', 'hive', 'hoard', 'hoax', 'hob', 'hobble', 'hock', 'hoe', 'hog', 'hoist', 'hold', 'hole', 'hollow', 'home', 'hone', 'honey', 'honk', 'hood', 'hoof', 'hook', 'hoop', 'hoot', 'hop', 'hope', 'horde', 'horn', 'hose', 'host', 'hostel', 'hound', 'house', 'hovel', 'hover', 'howl', 'huddle', 'huff', 'hug', 'hulk', 'hull', 'hum', 'humble', 'humbug', 'hump', 'hunch', 'hunger', 'hunt', 'hurdle', 'hurl', 'hurrah', 'hurry', 'hurt', 'hurtle', 'hush', 'husk', 'hustle', 'hymn', 'hyphen', 'ice', 'id', 'idle', 'ignite', 'ignore', 'image', 'imbibe', 'imbue', 'imp', 'impact', 'impair', 'impale', 'impart', 'impede', 'impel', 'imply', 'import', 'impose', 'impugn', 'impute', 'inch', 'incite', 'incur', 'indent', 'index', 'indict', 'induce', 'induct', 'infect', 'infer', 'infest', 'infix', 'inform', 'infuse', 'ingest', 'inhale', 'inject', 'injure', 'ink', 'inlay', 'inlet', 'input', 'insert', 'inset', 'insist', 'insult', 'insure', 'intend', 'inter', 'intern', 'intone', 'inure', 'invade', 'invent', 'invert', 'invest', 'invite', 'invoke', 'ionize', 'iris', 'iron', 'island', 'isle', 'issue', 'itch', 'item', 'jab', 'jabber', 'jack', 'jade', 'jag', 'jail', 'jam', 'jangle', 'jape', 'jar', 'jargon', 'jaunt', 'jaw', 'jazz', 'jeer', 'jelly', 'jerk', 'jest', 'jet', 'jetty', 'jewel', 'jib', 'jibe', 'jig', 'jigsaw', 'jilt', 'jingle', 'jinx', 'jitter', 'jive', 'job', 'jockey', 'jog', 'join', 'joint', 'joke', 'jolly', 'jolt', 'jostle', 'jot', 'joust', 'joy', 'judge', 'jug', 'juggle', 'juice', 'jumble', 'jump', 'junk', 'junket', 'just', 'jut', 'kayak', 'keel', 'keen', 'keep', 'ken', 'kennel', 'kernel', 'key', 'kick', 'kid', 'kidnap', 'kill', 'kiln', 'kilt', 'kindle', 'king', 'kink', 'kipper', 'kiss', 'kit', 'kite', 'kitten', 'knead', 'knee', 'kneel', 'knell', 'knife', 'knight', 'knit', 'knock', 'knoll', 'knot', 'know', 'kosher', 'kowtow', 'laager', 'label', 'lace', 'lack', 'lackey', 'ladle', 'lag', 'lame', 'lament', 'lance', 'land', 'lap', 'lapse', 'lard', 'lark', 'lash', 'lasso', 'last', 'latch', 'lathe', 'lather', 'laud', 'laugh', 'launch', 'laurel', 'lavish', 'law', 'lay', 'layer', 'laze', 'lazy', 'leach', 'lead', 'leaf', 'league', 'leak', 'lean', 'leap', 'learn', 'lease', 'leash', 'leave', 'leaven', 'lecher', 'leech', 'leer', 'leg', 'lend', 'lesion', 'lessen', 'lesson', 'let', 'letter', 'level', 'lever', 'levy', 'libel', 'lichen', 'lick', 'lid', 'lie', 'lift', 'light', 'like', 'liken', 'lilt', 'limb', 'limber', 'lime', 'limit', 'limp', 'line', 'linger', 'link', 'lip', 'liquor', 'lisp', 'list', 'listen', 'litter', 'live', 'liven', 'load', 'loaf', 'loam', 'loan', 'loathe', 'lob', 'lobby', 'local', 'locate', 'lock', 'lodge', 'loft', 'log', 'loiter', 'loll', 'long', 'look', 'loom', 'loop', 'loose', 'loosen', 'loot', 'lop', 'lope', 'lord', 'lose', 'lot', 'loth', 'lounge', 'louse', 'lout', 'love', 'lower', 'luck', 'lug', 'lull', 'lumber', 'lump', 'lunch', 'lunge', 'lurch', 'lure', 'lurk', 'lust', 'lute', 'lynch', 'mace', 'mad', 'madden', 'mail', 'maim', 'major', 'make', 'malign', 'malt', 'man', 'manage', 'mangle', 'mantle', 'manure', 'map', 'mar', 'marble', 'march', 'margin', 'mark', 'market', 'marl', 'maroon', 'marry', 'martyr', 'marvel', 'mash', 'mask', 'mason', 'mass', 'mast', 'master', 'mat', 'match', 'mate', 'matte', 'matter', 'mature', 'maul', 'maze', 'mean', 'medal', 'meddle', 'meet', 'meld', 'mellow', 'melt', 'menace', 'mend', 'mentor', 'merge', 'merit', 'mesh', 'mess', 'metal', 'meter', 'mew', 'mildew', 'milk', 'mill', 'mimic', 'mince', 'mind', 'mine', 'mingle', 'minor', 'mint', 'minute', 'mire', 'mirror', 'miscue', 'misfit', 'mislay', 'miss', 'mist', 'misuse', 'mitre', 'mix', 'moan', 'mob', 'mock', 'model', 'modem', 'modify', 'molest', 'molten', 'monger', 'monkey', 'moon', 'moor', 'moot', 'mop', 'mope', 'morph', 'morsel', 'mortar', 'mosaic', 'moss', 'mother', 'motion', 'motive', 'motor', 'mould', 'mound', 'mount', 'mourn', 'mouse', 'mousse', 'mouth', 'move', 'mow', 'muck', 'mud', 'muddle', 'muddy', 'muff', 'muffle', 'mug', 'mulch', 'mull', 'mumble', 'mummy', 'munch', 'murder', 'murmur', 'muscle', 'muse', 'mush', 'must', 'muster', 'mutate', 'mute', 'mutiny', 'mutter', 'muzzle', 'nag', 'nail', 'name', 'nap', 'narrow', 'near', 'neaten', 'neck', 'need', 'needle', 'negate', 'neigh', 'nerve', 'nest', 'nestle', 'net', 'nettle', 'neuter', 'nibble', 'niche', 'nick', 'nickel', 'niggle', 'nigh', 'nip', 'nod', 'noise', 'noodle', 'noose', 'nose', 'notch', 'note', 'notice', 'notify', 'nudge', 'null', 'numb', 'number', 'nurse', 'nut', 'nuzzle', 'oar', 'obey', 'object', 'oblige', 'obtain', 'occult', 'occupy', 'occur', 'off', 'offend', 'offer', 'ogle', 'oh', 'oil', 'omen', 'omit', 'ooze', 'open', 'opiate', 'oppose', 'opt', 'option', 'orb', 'orbit', 'ordain', 'order', 'orient', 'orphan', 'oust', 'out', 'outbid', 'outdo', 'outfit', 'outlaw', 'outlay', 'output', 'outrun', 'outwit', 'over', 'overdo', 'owe', 'own', 'oyster', 'pace', 'pacify', 'pack', 'packet', 'pad', 'paddle', 'page', 'pain', 'paint', 'pair', 'pal', 'pale', 'pall', 'pallet', 'palm', 'palsy', 'pamper', 'pan', 'pander', 'panel', 'panic', 'pant', 'paper', 'par', 'parade', 'parcel', 'parch', 'pardon', 'pare', 'parent', 'park', 'parley', 'parody', 'parole', 'parrot', 'parry', 'parse', 'part', 'party', 'pass', 'paste', 'pastor', 'pat', 'patch', 'patent', 'patrol', 'patter', 'pause', 'pave', 'paw', 'pawn', 'pay', 'peace', 'peach', 'peak', 'peal', 'pearl', 'pebble', 'peck', 'pedal', 'peddle', 'peek', 'peel', 'peep', 'peer', 'peg', 'pellet', 'pelt', 'pen', 'pencil', 'people', 'pepper', 'perch', 'peril', 'perish', 'perk', 'perm', 'permit', 'peruse', 'pester', 'pestle', 'pet', 'phase', 'phone', 'phrase', 'pi', 'pick', 'picket', 'pickle', 'picnic', 'pie', 'piece', 'pierce', 'piffle', 'pig', 'pike', 'pile', 'pilfer', 'pill', 'pillar', 'pillow', 'pilot', 'pimp', 'pin', 'pinch', 'pine', 'ping', 'pinion', 'pink', 'pip', 'pipe', 'pique', 'pirate', 'pistol', 'pit', 'pitch', 'pith', 'pity', 'pivot', 'place', 'plague', 'plait', 'plan', 'plane', 'plank', 'plant', 'plat', 'plate', 'play', 'plead', 'please', 'pleat', 'pledge', 'plight', 'plod', 'plop', 'plot', 'plough', 'pluck', 'plug', 'plumb', 'plume', 'plump', 'plunge', 'ply', 'poach', 'pocket', 'pod', 'point', 'poise', 'poison', 'poke', 'pole', 'police', 'polish', 'polka', 'poll', 'pollen', 'pomade', 'pond', 'ponder', 'pony', 'pool', 'pop', 'pore', 'port', 'pose', 'posit', 'post', 'pot', 'potter', 'pouch', 'pounce', 'pound', 'pour', 'pout', 'powder', 'power', 'praise', 'prance', 'prank', 'prawn', 'pray', 'preach', 'preen', 'prefab', 'prefix', 'preset', 'press', 'pretty', 'prey', 'price', 'prick', 'pride', 'priest', 'prim', 'prime', 'print', 'prize', 'probe', 'prod', 'profit', 'prompt', 'prong', 'proof', 'prop', 'propel', 'prose', 'prove', 'prowl', 'prune', 'pry', 'pucker', 'puddle', 'puff', 'pug', 'puke', 'pull', 'pulp', 'pulse', 'pumice', 'pummel', 'pump', 'pun', 'punch', 'punish', 'punt', 'pup', 'purge', 'purify', 'purl', 'purple', 'purr', 'purse', 'pursue', 'push', 'put', 'putt', 'putter', 'putty', 'puzzle', 'quack', 'quaff', 'quake', 'quarry', 'quash', 'quaver', 'queen', 'queer', 'quell', 'quench', 'query', 'quest', 'queue', 'quiet', 'quill', 'quilt', 'quip', 'quit', 'quiver', 'quiz', 'quote', 'rabble', 'race', 'rack', 'racket', 'radio', 'raffle', 'raft', 'rag', 'rage', 'raid', 'rail', 'rain', 'raise', 'rake', 'rally', 'ram', 'ramble', 'ramify', 'ramp', 'ramrod', 'ranch', 'range', 'rank', 'rankle', 'ransom', 'rant', 'rap', 'rasp', 'rat', 'rate', 'ratify', 'ration', 'rattle', 'ravage', 'rave', 'ravel', 'raven', 'ravish', 'ray', 'raze', 'reach', 'react', 'read', 'ready', 'really', 'ream', 'reap', 'rear', 'reason', 'rebate', 'rebel', 'rebind', 'rebook', 'rebuff', 'rebuke', 'rebut', 'recall', 'recant', 'recap', 'recast', 'recede', 'recess', 'recite', 'reckon', 'recode', 'recoil', 'record', 'recur', 'redden', 'redeem', 'redial', 'redo', 'redraw', 'reduce', 'reed', 'reef', 'reek', 'reel', 'reeve', 'refer', 'refile', 'refill', 'refine', 'refit', 'reflex', 'reform', 'refuel', 'refuge', 'refund', 'refuse', 'refute', 'regain', 'regale', 'regard', 'regret', 'rehash', 'reheat', 'reify', 'reign', 'reject', 'rejoin', 'relate', 'relax', 'relay', 'relent', 'relink', 'relish', 'relive', 'rely', 'remain', 'remake', 'remand', 'remap', 'remark', 'remedy', 'remind', 'remit', 'remove', 'rename', 'rend', 'render', 'renege', 'renew', 'rent', 'reopen', 'repack', 'repair', 'repast', 'repay', 'repeal', 'repeat', 'repel', 'repent', 'repine', 'replay', 'reply', 'report', 'repose', 'repute', 'reread', 'rerun', 'rescue', 'resell', 'resend', 'resent', 'reset', 'reshow', 'reside', 'resign', 'resin', 'resist', 'resit', 'resort', 'rest', 'result', 'resume', 'retail', 'retain', 'retake', 'retard', 'retch', 'retell', 'retest', 'retire', 'retort', 'retry', 'retune', 'return', 'retype', 'reuse', 'revamp', 'reveal', 'revel', 'revere', 'revert', 'review', 'revile', 'revive', 'revoke', 'revolt', 'reward', 'rewind', 'reword', 'rework', 'rhyme', 'rib', 'ribbon', 'rice', 'rid', 'riddle', 'ride', 'ridge', 'riff', 'rifle', 'rift', 'rig', 'right', 'rim', 'rime', 'ring', 'rinse', 'riot', 'rip', 'ripen', 'ripple', 'rise', 'risk', 'rival', 'rivet', 'roach', 'roam', 'roar', 'roast', 'rob', 'robe', 'rock', 'rocket', 'rogue', 'roll', 'romp', 'roof', 'rook', 'room', 'roost', 'root', 'rope', 'rosin', 'rot', 'rotate', 'rouge', 'rough', 'round', 'rouse', 'rout', 'route', 'rove', 'row', 'rub', 'ruck', 'rue', 'ruff', 'ruffle', 'ruin', 'rule', 'rumble', 'rumple', 'run', 'rush', 'rust', 'rustle', 'rut', 'sack', 'sadden', 'saddle', 'safari', 'sag', 'sail', 'saint', 'sallow', 'salt', 'salute', 'sample', 'sand', 'sandal', 'sap', 'sash', 'sauce', 'sauna', 'savage', 'save', 'saw', 'say', 'scab', 'scald', 'scale', 'scalp', 'scan', 'scant', 'scape', 'scar', 'scare', 'scarf', 'scathe', 'scent', 'scheme', 'school', 'scoff', 'scold', 'scoop', 'scoot', 'scope', 'scorch', 'score', 'scorn', 'scotch', 'scour', 'scout', 'scowl', 'scrap', 'scrape', 'scrawl', 'scream', 'screen', 'screw', 'scribe', 'script', 'scroll', 'scrub', 'scrum', 'scuba', 'scud', 'scuff', 'scull', 'sculpt', 'scum', 'scurry', 'scythe', 'seal', 'seam', 'sear', 'search', 'season', 'seat', 'secede', 'second', 'sector', 'secure', 'sedate', 'seduce', 'see', 'seed', 'seek', 'seem', 'seep', 'seethe', 'seize', 'select', 'sell', 'send', 'sense', 'serge', 'serve', 'set', 'settle', 'sever', 'sew', 'shack', 'shade', 'shadow', 'shaft', 'shag', 'shake', 'sham', 'shame', 'shank', 'shape', 'share', 'shark', 'sharp', 'shave', 'shear', 'shed', 'sheer', 'shell', 'shelve', 'shield', 'shift', 'shin', 'shine', 'ship', 'shirk', 'shiver', 'shoal', 'shock', 'shoe', 'shoo', 'shoot', 'shop', 'short', 'shot', 'shout', 'shove', 'shovel', 'show', 'shower', 'shred', 'shriek', 'shrill', 'shrimp', 'shrine', 'shrink', 'shroud', 'shrug', 'shun', 'shunt', 'shut', 'shy', 'sicken', 'sickly', 'side', 'sidle', 'siege', 'sieve', 'sift', 'sigh', 'sight', 'sign', 'signal', 'signet', 'silk', 'silo', 'silt', 'silver', 'simmer', 'simper', 'simple', 'sin', 'sinew', 'sing', 'single', 'sink', 'sip', 'siphon', 'sire', 'sit', 'site', 'size', 'sizzle', 'skate', 'sketch', 'skew', 'skewer', 'ski', 'skid', 'skim', 'skimp', 'skin', 'skip', 'skirl', 'skirt', 'skulk', 'skunk', 'sky', 'slab', 'slack', 'slag', 'slake', 'slam', 'slang', 'slant', 'slap', 'slash', 'slat', 'slate', 'slave', 'slaver', 'slay', 'sleaze', 'sled', 'sledge', 'sleek', 'sleep', 'sleet', 'sleeve', 'sleigh', 'sleuth', 'slice', 'slick', 'slide', 'slight', 'slim', 'slime', 'sling', 'slink', 'slip', 'slit', 'sliver', 'slog', 'slop', 'slope', 'slosh', 'slot', 'slouch', 'slough', 'slow', 'slug', 'sluice', 'slum', 'slump', 'slur', 'slurp', 'slurry', 'slush', 'smack', 'smart', 'smash', 'smear', 'smell', 'smelt', 'smile', 'smirk', 'smite', 'smock', 'smoke', 'smooth', 'smudge', 'smut', 'snack', 'snag', 'snake', 'snap', 'snare', 'snarl', 'snatch', 'sneak', 'sneer', 'sneeze', 'snick', 'sniff', 'snip', 'snipe', 'snivel', 'snoop', 'snooze', 'snore', 'snort', 'snow', 'snub', 'snuff', 'snug', 'soak', 'soap', 'soar', 'sob', 'sober', 'sock', 'socket', 'sodden', 'soften', 'soil', 'solace', 'solder', 'sole', 'solo', 'solve', 'soot', 'soothe', 'sop', 'sorrow', 'sort', 'sortie', 'sound', 'soup', 'sour', 'source', 'south', 'sow', 'space', 'spade', 'span', 'spank', 'spar', 'spare', 'spark', 'spat', 'spawn', 'speak', 'spear', 'speck', 'speed', 'spell', 'spend', 'spew', 'sphere', 'spice', 'spike', 'spill', 'spin', 'spiral', 'spire', 'spirit', 'spit', 'spite', 'splash', 'splice', 'splint', 'split', 'spoil', 'spoke', 'sponge', 'spoof', 'spool', 'spoon', 'spoor', 'spore', 'sport', 'spot', 'spout', 'sprain', 'sprawl', 'spray', 'spread', 'sprig', 'spring', 'sprint', 'sprout', 'spruce', 'spud', 'spume', 'spur', 'spurn', 'spurt', 'spy', 'squad', 'squall', 'square', 'squash', 'squat', 'squawk', 'squeak', 'squeal', 'squib', 'squint', 'squire', 'squirm', 'squirt', 'stab', 'stable', 'stack', 'staff', 'stag', 'stage', 'stain', 'stake', 'stale', 'stalk', 'stall', 'stamp', 'stand', 'staple', 'star', 'starch', 'stare', 'start', 'starve', 'state', 'stave', 'stay', 'stead', 'steal', 'steam', 'steel', 'steep', 'steer', 'stem', 'step', 'stet', 'stew', 'stick', 'stiff', 'stifle', 'still', 'stilt', 'sting', 'stink', 'stint', 'stir', 'stitch', 'stock', 'stomp', 'stone', 'stooge', 'stool', 'stoop', 'stop', 'store', 'storm', 'story', 'stow', 'strafe', 'strain', 'strand', 'strap', 'stray', 'streak', 'stream', 'stress', 'strew', 'stride', 'strike', 'string', 'strip', 'stripe', 'strive', 'stroke', 'stroll', 'strop', 'strum', 'strut', 'stub', 'stucco', 'stud', 'study', 'stuff', 'stump', 'stun', 'stunt', 'sturdy', 'sty', 'style', 'stymie', 'subdue', 'submit', 'suck', 'sucker', 'suckle', 'suds', 'sue', 'suede', 'suffer', 'suffix', 'sugar', 'suit', 'sulk', 'sully', 'sum', 'summer', 'summit', 'summon', 'sun', 'suntan', 'sup', 'supple', 'supply', 'surf', 'surge', 'survey', 'suture', 'swab', 'swamp', 'swap', 'swarm', 'swat', 'swathe', 'sway', 'swear', 'sweat', 'sweep', 'swell', 'swerve', 'swill', 'swim', 'swing', 'swipe', 'swirl', 'swish', 'switch', 'swivel', 'swoon', 'swoop', 'swop', 'symbol', 'syrup', 'tab', 'tabby', 'table', 'taboo', 'tack', 'tackle', 'tag', 'tail', 'tailor', 'taint', 'take', 'talk', 'tallow', 'tally', 'tame', 'tamp', 'tamper', 'tan', 'tangle', 'tango', 'tank', 'tap', 'tape', 'taper', 'tar', 'target', 'tariff', 'tarry', 'tart', 'task', 'tassel', 'taste', 'tattle', 'tattoo', 'taunt', 'tax', 'taxi', 'teach', 'team', 'tear', 'tease', 'tee', 'teem', 'teeter', 'teethe', 'telex', 'tell', 'temper', 'tempt', 'tenant', 'tend', 'tender', 'tenon', 'tense', 'tent', 'tenure', 'term', 'test', 'tether', 'thank', 'thatch', 'thaw', 'thieve', 'thin', 'think', 'thirst', 'thorn', 'thou', 'thrall', 'thrash', 'thread', 'threat', 'thresh', 'thrill', 'thrive', 'throat', 'throb', 'throne', 'throng', 'throw', 'thrum', 'thrust', 'thud', 'thumb', 'thump', 'thwack', 'thwart', 'tick', 'ticket', 'tickle', 'tide', 'tidy', 'tie', 'tier', 'tile', 'till', 'tiller', 'tilt', 'timber', 'time', 'tin', 'tinge', 'tingle', 'tinker', 'tinkle', 'tinsel', 'tint', 'tip', 'tipple', 'tiptoe', 'tire', 'tissue', 'tithe', 'title', 'titter', 'toady', 'toast', 'toddle', 'toe', 'toggle', 'toil', 'token', 'toll', 'tomb', 'tomcat', 'tone', 'tongue', 'tool', 'toot', 'tooth', 'tootle', 'top', 'topple', 'torch', 'torque', 'toss', 'tot', 'total', 'totter', 'touch', 'tough', 'tour', 'tout', 'tow', 'towel', 'tower', 'toy', 'trace', 'track', 'trade', 'trail', 'train', 'tram', 'tramp', 'trance', 'trap', 'trash', 'travel', 'trawl', 'tread', 'treat', 'treble', 'tree', 'trek', 'trench', 'trend', 'triage', 'trice', 'trick', 'trill', 'trim', 'trip', 'triple', 'troll', 'troop', 'trot', 'troupe', 'trowel', 'truant', 'truck', 'trudge', 'true', 'truss', 'trust', 'try', 'tub', 'tube', 'tuck', 'tucker', 'tuft', 'tug', 'tumble', 'tun', 'tune', 'tunnel', 'turf', 'turn', 'turtle', 'tusk', 'tussle', 'tutor', 'twang', 'tweak', 'tweet', 'twig', 'twill', 'twin', 'twine', 'twinge', 'twirl', 'twist', 'twitch', 'type', 'typify', 'umpire', 'unable', 'unbend', 'unbolt', 'unclog', 'uncoil', 'undo', 'unfit', 'unfold', 'unfurl', 'unhand', 'unify', 'unite', 'unjam', 'unlace', 'unlink', 'unload', 'unlock', 'unmask', 'unpack', 'unpick', 'unplug', 'unroll', 'unseal', 'unseat', 'untie', 'unveil', 'unwind', 'unwrap', 'unzip', 'up', 'update', 'uphold', 'uplift', 'upload', 'uproot', 'upset', 'upturn', 'urge', 'use', 'usher', 'usurp', 'utter', 'vacate', 'vacuum', 'valet', 'value', 'valve', 'vamp', 'vanish', 'vary', 'vat', 'vault', 'vector', 'veer', 'veil', 'vein', 'vend', 'veneer', 'vent', 'verge', 'verify', 'verse', 'vest', 'vet', 'veto', 'vex', 'vial', 'vice', 'video', 'vie', 'view', 'vilify', 'visa', 'vision', 'visit', 'visor', 'voice', 'void', 'volley', 'vomit', 'voodoo', 'vote', 'vouch', 'vow', 'voyage', 'wad', 'waddle', 'wade', 'wafer', 'waffle', 'waft', 'wag', 'wager', 'waggle', 'wagon', 'wail', 'wait', 'waive', 'wake', 'waken', 'walk', 'wall', 'wallow', 'waltz', 'wan', 'wander', 'wane', 'want', 'wanton', 'war', 'warble', 'ward', 'warm', 'warn', 'warp', 'wash', 'waste', 'watch', 'water', 'wattle', 'wave', 'waver', 'wax', 'waylay', 'weaken', 'wean', 'weapon', 'wear', 'weary', 'weasel', 'weave', 'web', 'wed', 'wedge', 'weed', 'weep', 'weigh', 'weight', 'weld', 'well', 'welt', 'welter', 'wench', 'wend', 'wet', 'whack', 'whale', 'wharf', 'wheel', 'wheeze', 'whelp', 'whet', 'whiff', 'while', 'whine', 'whinny', 'whip', 'whir', 'whirl', 'whirr', 'whisk', 'white', 'whiten', 'whizz', 'whoop', 'whoosh', 'wick', 'widen', 'widow', 'wield', 'wig', 'wiggle', 'wild', 'wile', 'will', 'wilt', 'wimple', 'win', 'wince', 'winch', 'wind', 'window', 'wine', 'wing', 'wink', 'winnow', 'winter', 'wipe', 'wire', 'wish', 'wisp', 'wit', 'witch', 'wither', 'wobble', 'wolf', 'wonder', 'wont', 'woo', 'wood', 'word', 'work', 'worm', 'worry', 'worsen', 'worst', 'wound', 'wow', 'wrack', 'wrap', 'wreak', 'wreath', 'wreck', 'wrench', 'wrest', 'wring', 'write', 'writhe', 'wrong', 'x-ray', 'xerox', 'yacht', 'yak', 'yap', 'yard', 'yaw', 'yawn', 'yearn', 'yeast', 'yell', 'yellow', 'yelp', 'yen', 'yes', 'yield', 'yo-yo', 'yodel', 'yoke', 'zero', 'zigzag', 'zinc', 'zip', 'zipper', 'zone', 'zoom' +] +export const nouns = [ + 'abacus', 'abbey', 'abroad', 'abuse', 'access', 'acid', 'act', 'action', 'actor', 'ad', 'adult', 'advice', 'affair', 'affect', 'age', 'agency', 'agenda', 'agent', 'aglet', 'aid', 'air', 'airbag', 'airbus', 'alarm', 'alb', 'alcove', 'alder', 'alibi', 'alley', 'alloy', 'almond', 'alpaca', 'alpha', 'alto', 'amount', 'analog', 'anger', 'angle', 'angora', 'animal', 'anime', 'ankle', 'anklet', 'annual', 'anorak', 'answer', 'ant', 'antler', 'ape', 'appeal', 'apple', 'apron', 'apse', 'arch', 'archer', 'area', 'arm', 'armor', 'army', 'arrow', 'art', 'ascot', 'ash', 'ashram', 'aside', 'ask', 'aspect', 'assist', 'atom', 'atrium', 'attack', 'attic', 'aunt', 'author', 'avenue', 'award', 'babe', 'baboon', 'baby', 'back', 'bacon', 'bad', 'badge', 'badger', 'bag', 'bagel', 'bail', 'bait', 'bake', 'baker', 'bakery', 'ball', 'ballet', 'bamboo', 'banana', 'band', 'bangle', 'banjo', 'bank', 'banker', 'baobab', 'bar', 'barber', 'barge', 'barium', 'barn', 'base', 'basin', 'basis', 'basket', 'bass', 'bat', 'bath', 'bather', 'batter', 'battle', 'bay', 'bayou', 'beach', 'bead', 'beak', 'beam', 'bean', 'beanie', 'bear', 'beard', 'beast', 'beat', 'beauty', 'beaver', 'bed', 'bee', 'beech', 'beef', 'beer', 'beet', 'beetle', 'beggar', 'behest', 'being', 'belfry', 'belief', 'bell', 'belly', 'belt', 'bench', 'bend', 'bengal', 'beret', 'berry', 'bet', 'beyond', 'bid', 'bidet', 'big', 'bijou', 'bike', 'bikini', 'bill', 'bin', 'birch', 'bird', 'birth', 'bit', 'bite', 'bitter', 'black', 'blade', 'blame', 'blank', 'blazer', 'blight', 'blind', 'block', 'blood', 'bloom', 'blouse', 'blow', 'blue', 'boar', 'board', 'boat', 'bobcat', 'body', 'bog', 'bolero', 'bolt', 'bomb', 'bomber', 'bone', 'bongo', 'bonnet', 'bonsai', 'bonus', 'book', 'boot', 'bootee', 'bootie', 'boots', 'booty', 'border', 'bore', 'bosom', 'boss', 'botany', 'bother', 'bottle', 'bottom', 'bough', 'bow', 'bower', 'bowl', 'bowler', 'bowtie', 'box', 'boxer', 'boy', 'bra', 'brace', 'brain', 'brake', 'branch', 'brand', 'brandy', 'brass', 'brave', 'bread', 'break', 'breast', 'breath', 'breeze', 'brick', 'bridge', 'brief', 'briefs', 'broad', 'broker', 'brome', 'bronco', 'bronze', 'brooch', 'brood', 'brook', 'broom', 'brow', 'brown', 'brush', 'bubble', 'bucket', 'buckle', 'bud', 'buddy', 'budget', 'buffer', 'buffet', 'bug', 'buggy', 'bugle', 'bulb', 'bull', 'bullet', 'bumper', 'bun', 'bunch', 'burn', 'burst', 'bus', 'bush', 'bust', 'bustle', 'butane', 'butter', 'button', 'buy', 'buyer', 'cabana', 'cabin', 'cable', 'cacao', 'cactus', 'caddy', 'cadet', 'cafe', 'caftan', 'cake', 'calf', 'calico', 'call', 'calm', 'camel', 'cameo', 'camera', 'camp', 'can', 'canal', 'cancel', 'cancer', 'candle', 'candy', 'cane', 'cannon', 'canoe', 'canon', 'canopy', 'canvas', 'cap', 'cape', 'capon', 'car', 'carbon', 'card', 'care', 'career', 'cargo', 'carol', 'carp', 'carpet', 'carrot', 'carry', 'cart', 'case', 'cash', 'casino', 'cast', 'castle', 'cat', 'catch', 'catsup', 'cattle', 'cause', 'cave', 'cd', 'celery', 'cell', 'cellar', 'cello', 'cement', 'census', 'cent', 'center', 'cereal', 'chafe', 'chain', 'chair', 'chaise', 'chalet', 'chalk', 'chance', 'change', 'chaos', 'chap', 'chapel', 'chard', 'charge', 'charm', 'chart', 'check', 'cheek', 'chef', 'cheque', 'cherry', 'chess', 'chest', 'chick', 'chief', 'child', 'chill', 'chime', 'chin', 'chino', 'chip', 'chive', 'choice', 'choker', 'chop', 'chord', 'chrome', 'chub', 'chug', 'church', 'churn', 'cicada', 'cinema', 'circle', 'cirrus', 'city', 'claim', 'clam', 'clank', 'clasp', 'class', 'clause', 'clave', 'cleat', 'clef', 'cleric', 'clerk', 'click', 'client', 'cliff', 'climb', 'clip', 'cloak', 'clock', 'clogs', 'close', 'closet', 'cloth', 'cloud', 'cloudy', 'clove', 'clover', 'club', 'clue', 'clutch', 'coach', 'coal', 'coast', 'coat', 'cob', 'cobweb', 'cocoa', 'cod', 'code', 'codon', 'coffee', 'coffin', 'coil', 'coin', 'coke', 'cold', 'collar', 'colon', 'colony', 'color', 'colt', 'column', 'comb', 'combat', 'comic', 'comma', 'common', 'condor', 'cone', 'conga', 'congo', 'consul', 'cook', 'cookie', 'cope', 'copper', 'copy', 'cord', 'cork', 'corn', 'corner', 'cornet', 'corral', 'cost', 'cot', 'cotton', 'couch', 'cougar', 'cough', 'count', 'county', 'couple', 'course', 'court', 'cousin', 'cover', 'cow', 'cowboy', 'crab', 'crack', 'cradle', 'craft', 'crash', 'crate', 'cravat', 'craw', 'crayon', 'crazy', 'cream', 'creche', 'credit', 'creek', 'crest', 'crew', 'crib', 'crime', 'crocus', 'crook', 'crop', 'cross', 'crotch', 'croup', 'crow', 'crowd', 'crown', 'crude', 'crush', 'cry', 'cub', 'cuckoo', 'cup', 'cupola', 'curio', 'curl', 'curler', 'cursor', 'curve', 'cut', 'cutlet', 'cycle', 'cymbal', 'cynic', 'cyst', 'dad', 'dagger', 'dahlia', 'daisy', 'damage', 'dame', 'dance', 'dancer', 'danger', 'daniel', 'dare', 'dark', 'dart', 'dash', 'data', 'date', 'david', 'day', 'daybed', 'dead', 'deal', 'dealer', 'dear', 'death', 'debate', 'debt', 'debtor', 'decade', 'deck', 'deep', 'deer', 'degree', 'delay', 'delete', 'demand', 'demur', 'den', 'denim', 'depth', 'deputy', 'derby', 'desert', 'design', 'desire', 'desk', 'detail', 'device', 'devil', 'dew', 'dhow', 'diadem', 'dibble', 'dickey', 'diet', 'dig', 'digger', 'dill', 'dime', 'dimple', 'diner', 'dinghy', 'dinner', 'dirndl', 'dirt', 'disco', 'dish', 'dishes', 'disk', 'divan', 'diver', 'divide', 'diving', 'dock', 'doctor', 'doe', 'dog', 'doll', 'dollar', 'dolman', 'domain', 'donkey', 'door', 'dory', 'dot', 'double', 'doubt', 'draft', 'drag', 'dragon', 'drain', 'drake', 'drama', 'draw', 'drawer', 'dream', 'dress', 'drill', 'drink', 'drive', 'driver', 'drop', 'drug', 'drum', 'drunk', 'dry', 'dryer', 'duck', 'dud', 'due', 'duffel', 'dugout', 'dump', 'dust', 'duster', 'duty', 'dwarf', 'dynamo', 'eagle', 'ear', 'earth', 'ease', 'easel', 'east', 'eat', 'eave', 'e-book', 'eddy', 'edge', 'edger', 'editor', 'edward', 'eel', 'effect', 'effort', 'egg', 'eggnog', 'eight', 'elbow', 'elixir', 'elk', 'elm', 'emery', 'employ', 'emu', 'end', 'enemy', 'energy', 'engine', 'enigma', 'entry', 'envy', 'epee', 'epoch', 'eponym', 'epoxy', 'equal', 'era', 'error', 'escape', 'ese', 'essay', 'estate', 'ethics', 'europe', 'event', 'exam', 'excuse', 'exile', 'exit', 'expert', 'extent', 'eye', 'eyelid', 'face', 'facet', 'fact', 'factor', 'fail', 'fairy', 'faith', 'fall', 'fame', 'family', 'fan', 'fang', 'fanny', 'farm', 'farmer', 'fascia', 'fat', 'father', 'faucet', 'fault', 'fawn', 'fax', 'fear', 'feast', 'fedora', 'fee', 'feed', 'feel', 'feet', 'felony', 'female', 'fen', 'fence', 'fender', 'ferry', 'few', 'fiber', 'fibre', 'fiddle', 'field', 'fifth', 'fight', 'figure', 'file', 'fill', 'filly', 'film', 'filth', 'final', 'find', 'fine', 'finger', 'finish', 'fir', 'fire', 'fish', 'fix', 'flag', 'flame', 'flare', 'flash', 'flat', 'flavor', 'flax', 'fleck', 'fleece', 'flesh', 'flight', 'flock', 'flood', 'floor', 'flour', 'flow', 'flower', 'flu', 'fluke', 'flute', 'fly', 'foam', 'fob', 'focus', 'fog', 'fold', 'folder', 'fondue', 'font', 'food', 'foot', 'foray', 'force', 'forest', 'fork', 'form', 'formal', 'format', 'former', 'fort', 'forum', 'fowl', 'fox', 'frame', 'freeze', 'freon', 'fresco', 'fridge', 'friend', 'fringe', 'frock', 'frog', 'front', 'frost', 'frown', 'fruit', 'fuel', 'full', 'fun', 'funny', 'fur', 'futon', 'future', 'gaffer', 'gain', 'gale', 'galley', 'gallon', 'galn', 'game', 'gander', 'gap', 'garage', 'garb', 'garden', 'garlic', 'garter', 'gas', 'gate', 'gather', 'gauge', 'gazebo', 'gear', 'geese', 'gem', 'gender', 'gene', 'george', 'gerbil', 'geyser', 'ghost', 'giant', 'gift', 'girdle', 'girl', 'git', 'give', 'glad', 'gland', 'glass', 'glen', 'glider', 'glove', 'gloves', 'glue', 'glut', 'go', 'goal', 'goat', 'god', 'gold', 'golf', 'gong', 'good', 'goodie', 'goose', 'gopher', 'gossip', 'gown', 'grab', 'grade', 'grain', 'gram', 'grand', 'granny', 'grape', 'graph', 'grass', 'gray', 'grease', 'great', 'greek', 'green', 'grey', 'grief', 'grill', 'grip', 'grit', 'ground', 'group', 'grouse', 'growth', 'guard', 'guess', 'guest', 'guide', 'guilt', 'guilty', 'guitar', 'gum', 'gun', 'gutter', 'guy', 'gym', 'gyro', 'habit', 'hail', 'hair', 'half', 'hall', 'hamaki', 'hammer', 'hand', 'handle', 'hang', 'harbor', 'harm', 'harp', 'hat', 'hatbox', 'hate', 'hatred', 'haunt', 'hawk', 'hay', 'head', 'health', 'heart', 'hearth', 'heat', 'heater', 'heaven', 'heavy', 'hedge', 'heel', 'height', 'helen', 'helium', 'hell', 'hello', 'helmet', 'helo', 'help', 'hemp', 'hen', 'herb', 'heron', 'heyday', 'hide', 'high', 'hill', 'hip', 'hire', 'hit', 'hive', 'hobbit', 'hobby', 'hockey', 'hoe', 'hog', 'hold', 'hole', 'home', 'honey', 'hood', 'hoof', 'hook', 'hope', 'hops', 'horn', 'hornet', 'horror', 'horse', 'hose', 'host', 'hostel', 'hot', 'hotel', 'hour', 'house', 'hovel', 'hub', 'hubcap', 'hugger', 'human', 'humor', 'humour', 'hunger', 'hunt', 'hurry', 'hurt', 'hut', 'hutch', 'hyena', 'ice', 'icicle', 'icon', 'idea', 'ideal', 'if', 'igloo', 'image', 'impact', 'inbox', 'inch', 'income', 'index', 'injury', 'ink', 'inlay', 'inn', 'input', 'insect', 'inside', 'invite', 'iris', 'iron', 'irony', 'island', 'issue', 'it', 'item', 'jackal', 'jacket', 'jaguar', 'jail', 'jam', 'james', 'jar', 'jaw', 'jeans', 'jeep', 'jeff', 'jelly', 'jet', 'jewel', 'jiffy', 'job', 'jockey', 'joey', 'join', 'joint', 'joke', 'jot', 'joy', 'judge', 'judo', 'juice', 'jumbo', 'jump', 'jumper', 'junior', 'junk', 'junker', 'junket', 'jury', 'jute', 'kale', 'karate', 'karen', 'kayak', 'kazoo', 'keep', 'kendo', 'ketch', 'kettle', 'key', 'kick', 'kid', 'kidney', 'kill', 'kilt', 'kimono', 'kind', 'king', 'kiosk', 'kiss', 'kite', 'kitten', 'kitty', 'klomps', 'knee', 'knife', 'knight', 'knot', 'koala', 'lab', 'labour', 'lace', 'lack', 'ladder', 'lady', 'lake', 'lamb', 'lamp', 'lan', 'lanai', 'land', 'lap', 'lapdog', 'laptop', 'larch', 'larder', 'lark', 'latex', 'lathe', 'latte', 'laugh', 'lava', 'law', 'lawn', 'lawyer', 'lay', 'layer', 'lead', 'leader', 'leaf', 'league', 'leaker', 'leash', 'leave', 'leaver', 'leek', 'leg', 'legal', 'legume', 'lei', 'lemon', 'lemur', 'length', 'lentil', 'lesson', 'let', 'letter', 'level', 'lever', 'lie', 'lier', 'life', 'lift', 'light', 'lilac', 'lily', 'limit', 'limo', 'line', 'linen', 'liner', 'link', 'lion', 'lip', 'liquid', 'liquor', 'lisa', 'list', 'listen', 'litter', 'liver', 'living', 'lizard', 'llama', 'load', 'loaf', 'loafer', 'loan', 'local', 'lock', 'locker', 'locket', 'locust', 'loft', 'log', 'loggia', 'logic', 'long', 'look', 'loss', 'lot', 'lotion', 'lounge', 'lout', 'love', 'low', 'luck', 'lumber', 'lunch', 'lung', 'lunge', 'lute', 'lycra', 'lye', 'lynx', 'lyre', 'lyric', 'magic', 'maid', 'maiden', 'mail', 'main', 'major', 'make', 'makeup', 'male', 'mall', 'mallet', 'mambo', 'man', 'maniac', 'manner', 'manor', 'mantel', 'mantle', 'mantua', 'manx', 'many', 'map', 'maple', 'maraca', 'marble', 'mare', 'margin', 'mark', 'market', 'marsh', 'mask', 'mass', 'master', 'mat', 'match', 'mate', 'math', 'matter', 'maybe', 'mayor', 'meal', 'meat', 'media', 'medium', 'meet', 'melody', 'member', 'memory', 'men', 'menu', 'mess', 'metal', 'meteor', 'meter', 'method', 'metro', 'mice', 'middle', 'midi', 'might', 'mile', 'milk', 'mime', 'mimosa', 'mind', 'mine', 'mini', 'minion', 'minor', 'mint', 'minute', 'mirror', 'misfit', 'miss', 'mist', 'mister', 'miter', 'mitten', 'mix', 'mixer', 'moat', 'mobile', 'mocha', 'mode', 'model', 'modem', 'mole', 'mom', 'moment', 'money', 'monger', 'monkey', 'month', 'mood', 'moon', 'mop', 'morsel', 'mosque', 'most', 'motel', 'moth', 'mother', 'motion', 'motor', 'mound', 'mouse', 'mouser', 'mousse', 'mouth', 'mouton', 'move', 'mover', 'movie', 'mower', 'mud', 'mug', 'mukluk', 'mule', 'muscle', 'museum', 'music', 'mutt', 'n', 'nail', 'name', 'naming', 'napkin', 'nasty', 'nation', 'native', 'nature', 'neat', 'neck', 'need', 'needle', 'neon', 'nephew', 'nerve', 'nest', 'net', 'news', 'nexus', 'nicety', 'niche', 'nickel', 'niece', 'night', 'nobody', 'node', 'noise', 'noodle', 'normal', 'norse', 'north', 'nose', 'note', 'notice', 'notify', 'nougat', 'novel', 'nudge', 'number', 'nurse', 'nut', 'nylon', 'oak', 'oar', 'oasis', 'obi', 'object', 'oboe', 'ocean', 'ocelot', 'octave', 'octavo', 'octet', 'oeuvre', 'offer', 'office', 'oil', 'okra', 'oldie', 'olive', 'omega', 'omelet', 'one', 'onion', 'open', 'opera', 'opium', 'option', 'orange', 'orator', 'orchid', 'order', 'organ', 'osprey', 'other', 'others', 'ott', 'otter', 'ounce', 'outfit', 'outlay', 'output', 'outset', 'oval', 'ovary', 'oven', 'owl', 'owner', 'ox', 'oxen', 'oxford', 'oxygen', 'oyster', 'pace', 'pack', 'packet', 'pad', 'paddle', 'page', 'pagoda', 'pail', 'pain', 'paint', 'pair', 'pajama', 'palm', 'pan', 'panda', 'panic', 'pansy', 'pantry', 'pants', 'panty', 'paper', 'parade', 'parcel', 'pard', 'parent', 'park', 'parka', 'parrot', 'part', 'party', 'pass', 'past', 'pasta', 'paste', 'pastor', 'pastry', 'patch', 'path', 'patina', 'patio', 'patrol', 'pause', 'paw', 'pay', 'payee', 'pea', 'peace', 'peach', 'peak', 'peanut', 'pear', 'pearl', 'pedal', 'peen', 'peer', 'pelt', 'pen', 'pencil', 'peony', 'people', 'pepper', 'perch', 'period', 'permit', 'perp', 'person', 'pest', 'pet', 'petal', 'pew', 'pha', 'phase', 'phone', 'photo', 'phrase', 'piano', 'pick', 'pickax', 'picket', 'pickle', 'pie', 'piece', 'pier', 'piety', 'pig', 'pigeon', 'pike', 'pile', 'pillow', 'pilot', 'pimp', 'pimple', 'pin', 'pine', 'ping', 'pink', 'pinkie', 'pint', 'pinto', 'pipe', 'piracy', 'piss', 'pitch', 'pith', 'pizza', 'place', 'plain', 'plan', 'plane', 'planet', 'plant', 'plate', 'play', 'player', 'plenty', 'plier', 'plot', 'plough', 'plover', 'plow', 'plume', 'pocket', 'poem', 'poet', 'poetry', 'point', 'poison', 'pole', 'police', 'policy', 'polish', 'polo', 'pompom', 'poncho', 'pond', 'pony', 'poof', 'pool', 'pop', 'poppy', 'porch', 'port', 'porter', 'post', 'poster', 'pot', 'potato', 'potty', 'pouch', 'pound', 'powder', 'power', 'press', 'price', 'pride', 'priest', 'prince', 'print', 'prior', 'prison', 'prize', 'profit', 'prompt', 'proof', 'prose', 'prow', 'pruner', 'public', 'puddle', 'puffin', 'pull', 'pulley', 'puma', 'pump', 'punch', 'pupa', 'pupil', 'puppy', 'purple', 'purse', 'push', 'pusher', 'put', 'pvc', 'pyjama', 'quail', 'quart', 'quartz', 'queen', 'quiet', 'quill', 'quilt', 'quince', 'quit', 'quiver', 'quote', 'rabbi', 'rabbit', 'race', 'racer', 'racing', 'racism', 'racist', 'rack', 'radar', 'radio', 'radish', 'raffle', 'raft', 'rag', 'rage', 'rail', 'rain', 'raise', 'rake', 'ram', 'ramie', 'ranch', 'random', 'range', 'rank', 'rat', 'rate', 'ratio', 'raven', 'raw', 'ray', 'rayon', 'reach', 'read', 'reamer', 'rear', 'reason', 'recess', 'recipe', 'record', 'red', 'reef', 'refund', 'refuse', 'region', 'regret', 'reject', 'relief', 'relish', 'remote', 'remove', 'rent', 'repair', 'repeat', 'reply', 'report', 'resale', 'resist', 'resort', 'rest', 'result', 'retina', 'return', 'reveal', 'review', 'reward', 'rhyme', 'rhythm', 'rice', 'rich', 'riddle', 'ride', 'rider', 'ridge', 'rifle', 'right', 'rim', 'ring', 'rip', 'ripple', 'rise', 'riser', 'risk', 'river', 'road', 'roast', 'robe', 'robin', 'rock', 'rocker', 'rocket', 'rod', 'role', 'roll', 'roller', 'roof', 'room', 'root', 'rope', 'rose', 'rotate', 'rough', 'round', 'route', 'router', 'row', 'royal', 'rub', 'rubber', 'rubric', 'ruckus', 'ruffle', 'rugby', 'ruin', 'rule', 'rum', 'run', 'runner', 'rush', 'ruth', 'ry', 'sabre', 'sack', 'sad', 'saddle', 'safe', 'safety', 'sage', 'sail', 'sailor', 'salad', 'salary', 'sale', 'salmon', 'salon', 'saloon', 'salt', 'sampan', 'sample', 'sand', 'sari', 'sarong', 'sash', 'satin', 'satire', 'sauce', 'save', 'saving', 'savior', 'saw', 'scale', 'scarf', 'scene', 'scent', 'scheme', 'school', 'score', 'scorn', 'scow', 'screen', 'screw', 'scrim', 'scrip', 'script', 'sea', 'seal', 'search', 'season', 'seat', 'second', 'secret', 'sector', 'secure', 'seed', 'seeder', 'select', 'self', 'sell', 'senior', 'sense', 'sepal', 'series', 'serve', 'server', 'set', 'sewer', 'sex', 'shack', 'shade', 'shadow', 'shake', 'shaker', 'shame', 'shanty', 'shape', 'share', 'shark', 'sharon', 'shawl', 'she', 'shears', 'sheath', 'shed', 'sheep', 'sheet', 'shelf', 'shell', 'sherry', 'shield', 'shift', 'shin', 'shine', 'ship', 'shirt', 'shoat', 'shock', 'shoe', 'shoes', 'shofar', 'shoot', 'shop', 'shore', 'shorts', 'shot', 'shovel', 'show', 'shower', 'shred', 'shrimp', 'shrine', 'sick', 'side', 'siding', 'sign', 'signal', 'signet', 'signup', 'silica', 'silk', 'sill', 'silly', 'silo', 'silver', 'simple', 'sing', 'singer', 'single', 'sink', 'sir', 'sister', 'sitar', 'site', 'size', 'skate', 'skiing', 'skill', 'skin', 'skirt', 'skull', 'skunk', 'sky', 'slash', 'slave', 'sled', 'sledge', 'sleep', 'sleet', 'sleuth', 'slice', 'slide', 'slider', 'slime', 'slip', 'slope', 'sloth', 'smash', 'smell', 'smile', 'smock', 'smog', 'smoke', 'snail', 'snake', 'sneeze', 'snob', 'snorer', 'snow', 'soap', 'soccer', 'sock', 'socks', 'soda', 'sofa', 'soft', 'soil', 'solid', 'son', 'song', 'sonnet', 'soot', 'sorbet', 'sorrow', 'sort', 'sound', 'soup', 'source', 'south', 'sow', 'soy', 'space', 'spade', 'spank', 'spare', 'spark', 'spasm', 'spear', 'speech', 'speed', 'spell', 'spend', 'sphere', 'sphynx', 'spider', 'spike', 'spine', 'spiral', 'spirit', 'spite', 'spleen', 'split', 'sponge', 'spoon', 'sport', 'spot', 'spray', 'spread', 'spring', 'sprout', 'spruce', 'spume', 'spur', 'spy', 'square', 'squash', 'squid', 'stable', 'stack', 'staff', 'stag', 'stage', 'stain', 'stair', 'stamen', 'stamp', 'stance', 'stand', 'star', 'start', 'state', 'status', 'stay', 'steak', 'steal', 'steam', 'steel', 'stem', 'step', 'steps', 'stew', 'stick', 'still', 'stitch', 'stock', 'stole', 'stone', 'stool', 'stop', 'store', 'storey', 'storm', 'story', 'stove', 'strain', 'strait', 'strap', 'straw', 'stream', 'street', 'stress', 'strike', 'string', 'strip', 'stroke', 'stud', 'studio', 'study', 'stuff', 'stupid', 'style', 'stylus', 'suburb', 'subway', 'suck', 'suede', 'sugar', 'suit', 'sultan', 'summer', 'sun', 'sunday', 'supply', 'survey', 'sushi', 'SUV', 'swamp', 'swan', 'swath', 'sweat', 'sweats', 'sweet', 'sweets', 'swell', 'swim', 'swing', 'swiss', 'switch', 'swivel', 'sword', 'synod', 'syrup', 'system', 'tabby', 'table', 'tackle', 'tail', 'tailor', 'tale', 'talk', 'tam', 'tandem', 'tank', 'tanker', 'tap', 'tard', 'target', 'task', 'tassel', 'taste', 'tatami', 'tattoo', 'tavern', 'tax', 'taxi', 'tea', 'teach', 'team', 'tear', 'teen', 'teeth', 'tell', 'teller', 'temp', 'temper', 'temple', 'tempo', 'tennis', 'tenor', 'tent', 'tepee', 'term', 'test', 'text', 'thanks', 'thaw', 'theism', 'theme', 'theory', 'thigh', 'thing', 'thirst', 'thomas', 'thong', 'thongs', 'thorn', 'thread', 'thrill', 'throat', 'throne', 'thrush', 'thumb', 'tiara', 'tic', 'ticket', 'tie', 'tiger', 'tight', 'tights', 'tile', 'till', 'timber', 'time', 'timer', 'tin', 'tinkle', 'tip', 'tire', 'tissue', 'title', 'toad', 'toast', 'today', 'toe', 'toga', 'togs', 'toilet', 'tom', 'tomato', 'ton', 'tone', 'tongue', 'tool', 'toot', 'tooth', 'top', 'topic', 'toque', 'torso', 'tosser', 'total', 'tote', 'touch', 'tough', 'tour', 'towel', 'tower', 'town', 'toy', 'track', 'trade', 'trail', 'train', 'tram', 'tramp', 'trash', 'travel', 'tray', 'treat', 'tree', 'tremor', 'trench', 'trial', 'tribe', 'trick', 'trim', 'trip', 'tripod', 'trout', 'trove', 'trowel', 'truck', 'trunk', 'trust', 'truth', 'try', 'tub', 'tuba', 'tube', 'tulip', 'tummy', 'tuna', 'tune', 'tunic', 'tunnel', 'turban', 'turn', 'turnip', 'turret', 'turtle', 'tussle', 'tutu', 'tuxedo', 'tv', 'twig', 'twine', 'twist', 'two', 'type', 'tyvek', 'uncle', 'union', 'unique', 'unit', 'unity', 'upper', 'urn', 'usage', 'use', 'user', 'usher', 'usual', 'vacuum', 'valley', 'value', 'van', 'vane', 'vanity', 'vase', 'vast', 'vault', 'veal', 'veil', 'vein', 'veldt', 'vellum', 'velvet', 'venom', 'verse', 'verve', 'vessel', 'vest', 'vibe', 'video', 'view', 'villa', 'vinyl', 'viola', 'violet', 'violin', 'virtue', 'virus', 'vise', 'vision', 'visit', 'visor', 'visual', 'vixen', 'voice', 'volume', 'voyage', 'wad', 'wafer', 'waffle', 'waist', 'wait', 'waiter', 'wake', 'walk', 'walker', 'wall', 'wallet', 'walnut', 'walrus', 'wampum', 'war', 'warden', 'warmth', 'wash', 'washer', 'wasp', 'waste', 'watch', 'water', 'wave', 'wax', 'way', 'wealth', 'weapon', 'wear', 'weasel', 'web', 'wedge', 'weed', 'weeder', 'week', 'weight', 'weird', 'well', 'west', 'whale', 'wharf', 'wheat', 'wheel', 'while', 'whip', 'white', 'whole', 'whorl', 'width', 'wife', 'will', 'willow', 'win', 'wind', 'window', 'wine', 'wing', 'winner', 'winter', 'wire', 'wisdom', 'wish', 'witch', 'wolf', 'wombat', 'women', 'wonder', 'wood', 'wool', 'woolen', 'word', 'work', 'worker', 'world', 'worm', 'worry', 'worth', 'worthy', 'wound', 'wrap', 'wren', 'wrench', 'wrist', 'writer', 'wrong', 'yacht', 'yak', 'yam', 'yard', 'yarn', 'yawl', 'year', 'yeast', 'yellow', 'yew', 'yin', 'yoga', 'yogurt', 'yoke', 'you', 'young', 'youth', 'yurt', 'zebra', 'zephyr', 'zinc', 'zipper', 'zither', 'zone', 'zoo' +] +export const adverbs = [ + 'ably', 'acidly', 'airily', 'ally', 'amply', 'apply', 'aptly', 'archly', 'avidly', 'badly', 'baldly', 'barely', 'basely', 'belly', 'bodily', 'boldly', 'bubbly', 'bully', 'burly', 'busily', 'calmly', 'chilly', 'coldly', 'comely', 'comply', 'coolly', 'cosily', 'costly', 'coyly', 'cuddly', 'curly', 'curtly', 'daily', 'dally', 'damply', 'darkly', 'deadly', 'dearly', 'deeply', 'deftly', 'dimly', 'direly', 'doily', 'dolly', 'doubly', 'dourly', 'drily', 'dryly', 'dually', 'dully', 'duly', 'dumbly', 'early', 'easily', 'edgily', 'eerily', 'evenly', 'evilly', 'fairly', 'family', 'feebly', 'fiddly', 'filly', 'finely', 'firmly', 'fitly', 'flatly', 'fly', 'folly', 'fondly', 'foully', 'freely', 'frilly', 'fully', 'gadfly', 'gaily', 'gamely', 'gangly', 'gently', 'giggly', 'gladly', 'glibly', 'glumly', 'godly', 'golly', 'goodly', 'googly', 'grimly', 'grisly', 'gully', 'hardly', 'hazily', 'highly', 'hilly', 'holly', 'holy', 'homely', 'homily', 'hotly', 'hourly', 'hugely', 'humbly', 'icily', 'idly', 'imply', 'jangly', 'jelly', 'jokily', 'jolly', 'justly', 'keenly', 'kindly', 'kingly', 'lamely', 'lastly', 'lately', 'lazily', 'likely', 'lily', 'limply', 'lively', 'lolly', 'lonely', 'lordly', 'loudly', 'lovely', 'lowly', 'madly', 'mainly', 'manly', 'mayfly', 'mealy', 'meanly', 'measly', 'meekly', 'merely', 'mildly', 'mostly', 'mutely', 'namely', 'nearly', 'neatly', 'newly', 'nicely', 'nimbly', 'nobly', 'nosily', 'numbly', 'oddly', 'oily', 'only', 'openly', 'orally', 'overly', 'palely', 'partly', 'pearly', 'pebbly', 'pertly', 'pimply', 'ply', 'poorly', 'portly', 'primly', 'purely', 'rally', 'rarely', 'rashly', 'really', 'rely', 'reply', 'richly', 'ripely', 'rosily', 'rudely', 'sadly', 'safely', 'sagely', 'sally', 'sanely', 'scaly', 'seemly', 'shyly', 'sickly', 'silly', 'simply', 'singly', 'slily', 'slowly', 'sly', 'slyly', 'smelly', 'smugly', 'snugly', 'softly', 'solely', 'sorely', 'sourly', 'stably', 'steely', 'subtly', 'sully', 'supply', 'surely', 'surly', 'tally', 'tamely', 'tartly', 'tautly', 'termly', 'thinly', 'tidily', 'timely', 'tingly', 'tinkly', 'triply', 'truly', 'ugly', 'unduly', 'unholy', 'unruly', 'vainly', 'vastly', 'viably', 'vilely', 'waggly', 'wanly', 'warily', 'warmly', 'wavily', 'weakly', 'weekly', 'wetly', 'wholly', 'widely', 'wifely', 'wildly', 'wily', 'wisely', 'wobbly', 'woolly', 'wryly', 'yearly' +] +export const interjections = [ + 'aha', 'ahem', 'ahh', 'ahoy', 'alas', 'arg', 'aw', 'bam', 'bingo', 'blah', 'boo', 'bravo', 'brrr', 'cheers', 'dang', 'drat', 'darn', 'duh', 'eek', 'eh', 'encore', 'eureka', 'gee', 'golly', 'gosh', 'haha', 'hello', 'hey', 'hmm', 'huh', 'humph', 'hurray', 'oh', 'oh my', 'oops', 'ouch', 'ow', 'phew', 'phooey', 'pooh', 'pow', 'rats', 'shh', 'shoo', 'thanks', 'there', 'uh-huh', 'uh-oh', 'ugh', 'wahoo', 'well', 'whoa', 'whoops', 'wow', 'yeah', 'yes', 'yikes', 'yippee', 'yo', 'yuck' +] +export const adjectives = [ + 'abject', 'abrupt', 'absent', 'absurd', 'active', 'acute', 'adept', 'adroit', 'aerial', 'agile', 'airy', 'alert', 'aloof', 'amoral', 'amused', 'angry', 'apt', 'arch', 'ardent', 'artful', 'august', 'aural', 'avowed', 'awful', 'bad', 'banal', 'basic', 'bawdy', 'benign', 'bitter', 'bland', 'blank', 'bleak', 'blind', 'blithe', 'blunt', 'boyish', 'brave', 'breezy', 'brief', 'bright', 'broad', 'broken', 'busy', 'cagy', 'cm', 'candid', 'canny', 'carnal', 'casual', 'catty', 'caudal', 'chaste', 'cheeky', 'clear', 'clever', 'clinic', 'clumsy', 'coarse', 'cocky', 'cogent', 'cold', 'conic', 'coward', 'coy', 'cozy', 'crass', 'craven', 'crazy', 'creepy', 'crude', 'curt', 'cute', 'cynic', 'dainty', 'dark', 'dazed', 'dear', 'decent', 'deep', 'deft', 'demure', 'dense', 'dim', 'dire', 'dismal', 'dizzy', 'dogged', 'droll', 'dry', 'dull', 'eager', 'easy', 'eerie', 'equal', 'erect', 'erotic', 'ethic', 'even', 'evil', 'exact', 'exotic', 'faint', 'false', 'famous', 'fatal', 'faulty', 'feeble', 'firm', 'fishy', 'fixed', 'flabby', 'flashy', 'flat', 'fleet', 'flimsy', 'floppy', 'fluent', 'fluid', 'fond', 'foul', 'frail', 'frank', 'free', 'fresh', 'frisky', 'frugal', 'funny', 'fussy', 'futile', 'fuzzy', 'game', 'garish', 'gauche', 'gaudy', 'gawky', 'genial', 'gent', 'glad', 'glib', 'glum', 'grand', 'grave', 'great', 'greedy', 'grimy', 'groggy', 'gross', 'guilty', 'happy', 'hardy', 'harsh', 'hasty', 'hazy', 'heated', 'hectic', 'heroic', 'hoarse', 'honest', 'hot', 'huge', 'humane', 'humble', 'hungry', 'husky', 'icy', 'inept', 'insane', 'ireful', 'ironic', 'jaded', 'jaunty', 'jerky', 'jocose', 'joking', 'jolly', 'jovial', 'joyful', 'juicy', 'just', 'keen', 'lame', 'lavish', 'lax', 'lazy', 'lewd', 'light', 'limp', 'livid', 'logic', 'loose', 'loud', 'loving', 'loyal', 'lubber', 'lucid', 'lucky', 'lurid', 'lusty', 'mad', 'magic', 'manful', 'marked', 'mature', 'meager', 'mean', 'meek', 'menial', 'merry', 'messy', 'metric', 'mighty', 'mild', 'minute', 'miser', 'modest', 'moist', 'moody', 'moral', 'morbid', 'murky', 'music', 'mute', 'naive', 'naked', 'narrow', 'nasty', 'neat', 'nice', 'nimble', 'noble', 'noisy', 'normal', 'nosy', 'numb', 'oafish', 'opaque', 'pert', 'pesky', 'physic', 'pious', 'pithy', 'placid', 'plain', 'poetic', 'polite', 'poor', 'prim', 'prissy', 'proper', 'proud', 'public', 'pure', 'quaint', 'queer', 'quick', 'quiet', 'rabid', 'racy', 'raging', 'rakish', 'random', 'rank', 'rapid', 'rapt', 'rare', 'rash', 'raving', 'ready', 'regal', 'remote', 'rich', 'right', 'rigid', 'ripe', 'ritual', 'robust', 'rosy', 'rough', 'royal', 'rude', 'rueful', 'rugged', 'sad', 'safe', 'sane', 'saucy', 'savage', 'scant', 'secret', 'secure', 'sedate', 'serene', 'severe', 'sexy', 'sexual', 'shaky', 'sharp', 'shoddy', 'showy', 'shrewd', 'shy', 'silent', 'simple', 'skimpy', 'slack', 'sleazy', 'sleek', 'slick', 'slight', 'slow', 'smart', 'smooth', 'smug', 'snooty', 'snug', 'sober', 'soft', 'soggy', 'solemn', 'somber', 'sordid', 'sore', 'sound', 'sour', 'spry', 'square', 'staid', 'stark', 'static', 'steady', 'stern', 'stiff', 'stingy', 'stoic', 'stolid', 'stormy', 'stout', 'strict', 'strong', 'stuffy', 'stupid', 'suave', 'subtle', 'sudden', 'sudden', 'sulky', 'sullen', 'superb', 'supp', 'sure', 'swanky', 'swift', 'tacit', 'tacky', 'tame', 'tardy', 'tart', 'taut', 'tense', 'tepid', 'terse', 'testy', 'thick', 'thin', 'tidy', 'tight', 'timid', 'tonal', 'tough', 'tragic', 'trim', 'trite', 'true', 'trying', 'turgid', 'uneasy', 'unique', 'unkind', 'unsafe', 'urgent', 'useful', 'vague', 'vain', 'vexed', 'visual', 'vital', 'vivid', 'vocal', 'vulgar', 'wan', 'wanton', 'warm', 'weak', 'weird', 'wicked', 'wide', 'wild', 'wise', 'witty', 'woeful', 'wrong', 'wry' +] +export const verbed = new Proxy(verbs, { + get: (arr, prop) => { + // Check it's not a property + if (!(prop in [])) { + return getPastTense(arr[prop]) + } else { + return arr[prop] + } + } +}) diff --git a/qortal-ui-plugins/package.json b/qortal-ui-plugins/package.json index ad9f149a..4a0c754e 100644 --- a/qortal-ui-plugins/package.json +++ b/qortal-ui-plugins/package.json @@ -46,19 +46,19 @@ "@rollup/plugin-commonjs": "24.0.0", "@rollup/plugin-node-resolve": "15.0.1", "@rollup/plugin-replace": "5.0.2", - "@rollup/plugin-terser": "0.2.1", - "@vaadin/avatar": "23.3.2", - "@vaadin/button": "23.3.2", - "@vaadin/grid": "23.3.2", - "@vaadin/icons": "23.3.2", - "@vaadin/tooltip": "23.3.2", + "@rollup/plugin-terser": "0.3.0", + "@vaadin/avatar": "23.3.3", + "@vaadin/button": "23.3.3", + "@vaadin/grid": "23.3.3", + "@vaadin/icons": "23.3.3", + "@vaadin/tooltip": "23.3.3", "epml": "0.3.3", "file-saver": "2.0.5", "highcharts": "10.3.2", "html-escaper": "3.0.3", - "lit": "2.5.0", + "lit": "2.6.1", "lit-translate": "2.0.1", - "rollup": "3.9.1", + "rollup": "3.10.0", "rollup-plugin-node-globals": "1.4.0", "rollup-plugin-progress": "1.1.2" }, From b6f567c5842616dffa891660d2763b0875e1cff0 Mon Sep 17 00:00:00 2001 From: AlphaX-Projects <77661270+AlphaX-Projects@users.noreply.github.com> Date: Fri, 13 Jan 2023 09:52:14 +0100 Subject: [PATCH 2/5] Cleanup code and preparation for chat reference --- qortal-ui-crypto/api.js | 6 +- qortal-ui-crypto/api/PhraseWallet.js | 334 +++++++++--------- qortal-ui-crypto/api/api.js | 4 - .../api/bitcoin/AltcoinHDWallet.js | 152 ++++---- qortal-ui-crypto/api/constants.js | 283 +++++++-------- qortal-ui-crypto/api/createTransaction.js | 24 +- qortal-ui-crypto/api/createWallet.js | 40 +-- qortal-ui-crypto/api/decryptStoredWallet.js | 32 +- qortal-ui-crypto/api/kdf.js | 64 ++-- qortal-ui-crypto/api/registerUsername.js | 45 +-- qortal-ui-crypto/api/storeWallet.js | 46 ++- qortal-ui-crypto/api/tradeRequest.js | 181 +++++----- .../api/transactions/AirdropTransaction.js | 69 ++-- .../api/transactions/DelegationTransaction.js | 41 +-- .../api/transactions/MessageTransaction.js | 136 +++---- .../api/transactions/PaymentTransaction.js | 121 +++---- .../api/transactions/PublicizeTransaction.js | 36 +- .../api/transactions/TransactionBase.js | 249 ++++++------- .../transactions/TransferPrivsTransaction.js | 52 +-- .../transactions/arbitrary/signArbitrary.js | 43 ++- .../api/transactions/arbitraryV3.js | 67 ++-- .../api/transactions/chat/ChatBase.js | 196 ++++------ .../api/transactions/chat/ChatTransaction.js | 125 ++++--- .../transactions/chat/GroupChatTransaction.js | 93 +++-- .../transactions/chat/decryptChatMessage.js | 27 +- .../api/transactions/chat/signChat.js | 51 ++- .../groups/AddGroupAdminTransaction.js | 88 ++--- .../groups/CancelGroupBanTransaction.js | 88 ++--- .../groups/CancelGroupInviteTransaction.js | 100 +++--- .../groups/CreateGroupTransaction.js | 164 ++++----- .../groups/GroupBanTransaction.js | 112 +++--- .../groups/GroupInviteTransaction.js | 98 ++--- .../groups/GroupKickTransaction.js | 102 +++--- .../groups/JoinGroupTransaction.js | 98 +++-- .../groups/LeaveGroupTransaction.js | 96 +++-- .../groups/RemoveGroupAdminTransaction.js | 88 ++--- .../transactions/names/BuyNameTransacion.js | 114 +++--- .../names/CancelSellNameTransacion.js | 78 ++-- .../names/RegisterNameTransaction.js | 94 ++--- .../transactions/names/SellNameTransacion.js | 104 +++--- .../api/transactions/registerName_dnsthing.js | 65 ++-- .../RemoveRewardShareTransaction.js | 88 ++--- .../reward-share/RewardShareTransaction.js | 115 +++--- .../tradebot/TradeBotCreateRequest.js | 106 +++--- .../tradebot/TradeBotRespondRequest.js | 56 ++- .../tradebot/signTradeBotTransaction.js | 43 +-- .../tradeoffer/DeleteTradeOffer.js | 46 ++- .../tradeoffer/cancelAllOffers.js | 35 +- .../api/transactions/transactions.js | 44 +-- .../api/wallet/base58PublicKeyToAddress.js | 9 +- .../api/wallet/publicKeyToAddress.js | 42 ++- .../api/wallet/validateAddress.js | 12 +- qortal-ui-crypto/config.js | 35 +- .../plugins/core/components/ChatModals.js | 1 + .../plugins/core/components/ChatPage.js | 2 + .../core/components/ChatWelcomePage.js | 1 + .../plugins/core/components/NameMenu.js | 1 + .../core/messaging/q-chat/q-chat.src.js | 1 + 58 files changed, 2197 insertions(+), 2446 deletions(-) diff --git a/qortal-ui-crypto/api.js b/qortal-ui-crypto/api.js index b2cfad3c..cc81dc9e 100644 --- a/qortal-ui-crypto/api.js +++ b/qortal-ui-crypto/api.js @@ -2,9 +2,8 @@ import { Sha256 } from 'asmcrypto.js' import Base58 from './api/deps/Base58' import { base58PublicKeyToAddress } from './api/wallet/base58PublicKeyToAddress' import { validateAddress } from './api/wallet/validateAddress' -import { decryptChatMessage } from './api/transactions/chat/decryptChatMessage'; -import _ from 'lodash'; - +import { decryptChatMessage } from './api/transactions/chat/decryptChatMessage' +import _ from 'lodash' window.Sha256 = Sha256 window.Base58 = Base58 @@ -14,7 +13,6 @@ window.validateAddress = validateAddress window.decryptChatMessage = decryptChatMessage export { initApi, store } from './api_deps.js' - export * from './api/deps/deps.js' export * from './api/api.js' export * from './api/registerUsername.js' diff --git a/qortal-ui-crypto/api/PhraseWallet.js b/qortal-ui-crypto/api/PhraseWallet.js index 64baa02b..41818a28 100644 --- a/qortal-ui-crypto/api/PhraseWallet.js +++ b/qortal-ui-crypto/api/PhraseWallet.js @@ -1,7 +1,7 @@ /* Copyright 2017-2018 @ irontiga and vbcs (original developer) */ -'use strict'; +'use strict' import Base58 from './deps/Base58.js' import { Sha256, Sha512 } from 'asmcrypto.js' import nacl from './deps/nacl-fast.js' @@ -10,200 +10,200 @@ import utils from './deps/utils.js' import { generateSaveWalletData } from './storeWallet.js' import publicKeyToAddress from './wallet/publicKeyToAddress.js' -import AltcoinHDWallet from "./bitcoin/AltcoinHDWallet"; +import AltcoinHDWallet from "./bitcoin/AltcoinHDWallet" export default class PhraseWallet { - constructor(seed, walletVersion) { + constructor(seed, walletVersion) { - this._walletVersion = walletVersion || 2 - this.seed = seed + this._walletVersion = walletVersion || 2 + this.seed = seed - this.savedSeedData = {} - this.hasBeenSaved = false - } + this.savedSeedData = {} + this.hasBeenSaved = false + } - set seed(seed) { - this._byteSeed = seed - this._base58Seed = Base58.encode(seed) + set seed(seed) { + this._byteSeed = seed + this._base58Seed = Base58.encode(seed) - this._addresses = [] + this._addresses = [] - this.genAddress(0) - } + this.genAddress(0) + } - getAddress(nonce) { - return this._addresses[nonce] - } + getAddress(nonce) { + return this._addresses[nonce] + } - get addresses() { - return this._addresses - } + get addresses() { + return this._addresses + } - get addressIDs() { - return this._addresses.map(addr => { - return addr.address - }) - } + get addressIDs() { + return this._addresses.map(addr => { + return addr.address + }) + } - get seed() { - return this._byteSeed - } + get seed() { + return this._byteSeed + } - addressExists(nonce) { - return this._addresses[nonce] != undefined - } + addressExists(nonce) { + return this._addresses[nonce] != undefined + } - _genAddressSeed(seed) { - let newSeed = new Sha512().process(seed).finish().result - newSeed = new Sha512().process(utils.appendBuffer(newSeed, seed)).finish().result - return newSeed - } + _genAddressSeed(seed) { + let newSeed = new Sha512().process(seed).finish().result + newSeed = new Sha512().process(utils.appendBuffer(newSeed, seed)).finish().result + return newSeed + } - genAddress(nonce) { - if (nonce >= this._addresses.length) { - this._addresses.length = nonce + 1 - } + genAddress(nonce) { + if (nonce >= this._addresses.length) { + this._addresses.length = nonce + 1 + } - if (this.addressExists(nonce)) { - return this.addresses[nonce] - } + if (this.addressExists(nonce)) { + return this.addresses[nonce] + } - const nonceBytes = utils.int32ToBytes(nonce) + const nonceBytes = utils.int32ToBytes(nonce) - let addrSeed = new Uint8Array() - addrSeed = utils.appendBuffer(addrSeed, nonceBytes) - addrSeed = utils.appendBuffer(addrSeed, this._byteSeed) - addrSeed = utils.appendBuffer(addrSeed, nonceBytes) + let addrSeed = new Uint8Array() + addrSeed = utils.appendBuffer(addrSeed, nonceBytes) + addrSeed = utils.appendBuffer(addrSeed, this._byteSeed) + addrSeed = utils.appendBuffer(addrSeed, nonceBytes) - if (this._walletVersion == 1) { - addrSeed = new Sha256().process( - new Sha256() - .process(addrSeed) - .finish() - .result - ).finish().result + if (this._walletVersion == 1) { + addrSeed = new Sha256().process( + new Sha256() + .process(addrSeed) + .finish() + .result + ).finish().result - addrSeed = this._byteSeed - } else { - addrSeed = this._genAddressSeed(addrSeed).slice(0, 32) - } + addrSeed = this._byteSeed + } else { + addrSeed = this._genAddressSeed(addrSeed).slice(0, 32) + } - const addrKeyPair = nacl.sign.keyPair.fromSeed(new Uint8Array(addrSeed)); + const addrKeyPair = nacl.sign.keyPair.fromSeed(new Uint8Array(addrSeed)); - const address = publicKeyToAddress(addrKeyPair.publicKey); - const qoraAddress = publicKeyToAddress(addrKeyPair.publicKey, true); + const address = publicKeyToAddress(addrKeyPair.publicKey); + const qoraAddress = publicKeyToAddress(addrKeyPair.publicKey, true); - // Create Bitcoin HD Wallet - const btcSeed = [...addrSeed]; - const btcWallet = new AltcoinHDWallet({ - mainnet: { - private: 0x0488ADE4, - public: 0x0488B21E, - prefix: 0 - }, - testnet: { - private: 0x04358394, - public: 0x043587CF, - prefix: 0x6F - } - }).createWallet(new Uint8Array(btcSeed), false); + // Create Bitcoin HD Wallet + const btcSeed = [...addrSeed]; + const btcWallet = new AltcoinHDWallet({ + mainnet: { + private: 0x0488ADE4, + public: 0x0488B21E, + prefix: 0 + }, + testnet: { + private: 0x04358394, + public: 0x043587CF, + prefix: 0x6F + } + }).createWallet(new Uint8Array(btcSeed), false); - // Create Litecoin HD Wallet - const ltcSeed = [...addrSeed]; - const ltcWallet = new AltcoinHDWallet({ - mainnet: { - private: 0x0488ADE4, - public: 0x0488B21E, - prefix: 0x30 - }, - testnet: { - private: 0x04358394, - public: 0x043587CF, - prefix: 0x6F - } - }).createWallet(new Uint8Array(ltcSeed), false, 'LTC'); + // Create Litecoin HD Wallet + const ltcSeed = [...addrSeed]; + const ltcWallet = new AltcoinHDWallet({ + mainnet: { + private: 0x0488ADE4, + public: 0x0488B21E, + prefix: 0x30 + }, + testnet: { + private: 0x04358394, + public: 0x043587CF, + prefix: 0x6F + } + }).createWallet(new Uint8Array(ltcSeed), false, 'LTC'); - // Create Dogecoin HD Wallet - const dogeSeed = [...addrSeed]; - const dogeWallet = new AltcoinHDWallet({ - mainnet: { - private: 0x02FAC398, - public: 0x02FACAFD, - prefix: 0x1E - }, - testnet: { - private: 0x04358394, - public: 0x043587CF, - prefix: 0x71 - } - }).createWallet(new Uint8Array(dogeSeed), false, 'DOGE'); + // Create Dogecoin HD Wallet + const dogeSeed = [...addrSeed]; + const dogeWallet = new AltcoinHDWallet({ + mainnet: { + private: 0x02FAC398, + public: 0x02FACAFD, + prefix: 0x1E + }, + testnet: { + private: 0x04358394, + public: 0x043587CF, + prefix: 0x71 + } + }).createWallet(new Uint8Array(dogeSeed), false, 'DOGE'); - // Create Digibyte HD Wallet - const dgbSeed = [...addrSeed]; - const dgbWallet = new AltcoinHDWallet({ - mainnet: { - private: 0x0488ADE4, - public: 0x0488B21E, - prefix: 0x1E - }, - testnet: { - private: 0x04358394, - public: 0x043587CF, - prefix: 0x7E - } - }).createWallet(new Uint8Array(dgbSeed), false, 'DGB'); + // Create Digibyte HD Wallet + const dgbSeed = [...addrSeed]; + const dgbWallet = new AltcoinHDWallet({ + mainnet: { + private: 0x0488ADE4, + public: 0x0488B21E, + prefix: 0x1E + }, + testnet: { + private: 0x04358394, + public: 0x043587CF, + prefix: 0x7E + } + }).createWallet(new Uint8Array(dgbSeed), false, 'DGB'); // Create Ravencoin HD Wallet - const rvnSeed = [...addrSeed]; - const rvnWallet = new AltcoinHDWallet({ - mainnet: { - private: 0x0488ADE4, - public: 0x0488B21E, - prefix: 0x3C - }, - testnet: { - private: 0x04358394, - public: 0x043587CF, - prefix: 0x6F - } - }).createWallet(new Uint8Array(rvnSeed), false, 'RVN'); + const rvnSeed = [...addrSeed]; + const rvnWallet = new AltcoinHDWallet({ + mainnet: { + private: 0x0488ADE4, + public: 0x0488B21E, + prefix: 0x3C + }, + testnet: { + private: 0x04358394, + public: 0x043587CF, + prefix: 0x6F + } + }).createWallet(new Uint8Array(rvnSeed), false, 'RVN'); - // Create Pirate Chain HD Wallet - const arrrSeed = [...addrSeed]; - const arrrWallet = new AltcoinHDWallet({ - mainnet: { - private: 0x0488ADE4, - public: 0x0488B21E, - prefix: [0x16, 0x9A] - }, - testnet: { - private: 0x04358394, - public: 0x043587CF, - prefix: [0x14, 0x51] - } - }).createWallet(new Uint8Array(arrrSeed), false, 'ARRR'); + // Create Pirate Chain HD Wallet + const arrrSeed = [...addrSeed]; + const arrrWallet = new AltcoinHDWallet({ + mainnet: { + private: 0x0488ADE4, + public: 0x0488B21E, + prefix: [0x16, 0x9A] + }, + testnet: { + private: 0x04358394, + public: 0x043587CF, + prefix: [0x14, 0x51] + } + }).createWallet(new Uint8Array(arrrSeed), false, 'ARRR'); - this._addresses[nonce] = { - address, - btcWallet, - ltcWallet, - dogeWallet, - dgbWallet, - rvnWallet, - arrrWallet, - qoraAddress, - keyPair: { - publicKey: addrKeyPair.publicKey, - privateKey: addrKeyPair.secretKey - }, - base58PublicKey: Base58.encode(addrKeyPair.publicKey), - seed: addrSeed, - nonce: nonce - } - return this._addresses[nonce] - } + this._addresses[nonce] = { + address, + btcWallet, + ltcWallet, + dogeWallet, + dgbWallet, + rvnWallet, + arrrWallet, + qoraAddress, + keyPair: { + publicKey: addrKeyPair.publicKey, + privateKey: addrKeyPair.secretKey + }, + base58PublicKey: Base58.encode(addrKeyPair.publicKey), + seed: addrSeed, + nonce: nonce + } + return this._addresses[nonce] + } - generateSaveWalletData(...args) { - return generateSaveWalletData(this, ...args) - } + generateSaveWalletData(...args) { + return generateSaveWalletData(this, ...args) + } } diff --git a/qortal-ui-crypto/api/api.js b/qortal-ui-crypto/api/api.js index bf40d58a..98da919b 100644 --- a/qortal-ui-crypto/api/api.js +++ b/qortal-ui-crypto/api/api.js @@ -1,9 +1,5 @@ export { request } from './fetch-request.js' - export { transactionTypes as transactions } from './transactions/transactions.js' - export { processTransaction, createTransaction, computeChatNonce, signChatTransaction, signArbitraryTransaction } 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' diff --git a/qortal-ui-crypto/api/bitcoin/AltcoinHDWallet.js b/qortal-ui-crypto/api/bitcoin/AltcoinHDWallet.js index 0d416d54..421d19fb 100644 --- a/qortal-ui-crypto/api/bitcoin/AltcoinHDWallet.js +++ b/qortal-ui-crypto/api/bitcoin/AltcoinHDWallet.js @@ -1,11 +1,10 @@ 'use strict'; import Base58 from '../deps/Base58.js' import { Sha256, Sha512 } from 'asmcrypto.js' -import jsSHA from "jssha"; +import jsSHA from 'jssha' import RIPEMD160 from '../deps/ripemd160.js' import utils from '../deps/utils.js' -import { EllipticCurve, BigInteger } from './ecbn.js'; - +import { EllipticCurve, BigInteger } from './ecbn.js' export default class AltcoinHDWallet { @@ -101,14 +100,10 @@ export default class AltcoinHDWallet { this._tmasterPublicKey = '' - - - /** * Child Keys Derivation from the Parent Keys */ - /** * Child Private Key - 32 bytes */ @@ -145,13 +140,10 @@ export default class AltcoinHDWallet { this.xPublicChildKey = '' - - /** * Grand Child Keys Derivation from the Child Keys */ - /** * Grand Child Private Key - 32 bytes */ @@ -200,7 +192,6 @@ export default class AltcoinHDWallet { this._tlitecoinLegacyAddress = '' - /** * Wallet - Wallet Object (keys...) */ @@ -250,76 +241,69 @@ export default class AltcoinHDWallet { generateSeedHash(seed, isBIP44, indicator = null) { - - let buffer; + let buffer if (isBIP44) { buffer = utils.appendBuffer(seed.reverse(), utils.int32ToBytes(indicator)) } else { if(indicator !== null) { - const indicatorString = utils.stringtoUTF8Array(indicator); - buffer = utils.appendBuffer(seed.reverse(), indicatorString); + const indicatorString = utils.stringtoUTF8Array(indicator) + buffer = utils.appendBuffer(seed.reverse(), indicatorString) } else { - buffer = seed.reverse(); + buffer = seed.reverse() } } - const _reverseSeedHash = new Sha256().process(buffer).finish().result; - this.seedHash = new Sha512().process(utils.appendBuffer(seed, _reverseSeedHash)).finish().result; + const _reverseSeedHash = new Sha256().process(buffer).finish().result + this.seedHash = new Sha512().process(utils.appendBuffer(seed, _reverseSeedHash)).finish().result } generatePrivateKey(seedHash) { + const SECP256K1_CURVE_ORDER = new BigInteger("0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141") - const SECP256K1_CURVE_ORDER = new BigInteger("0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141"); + const privateKeyHash = seedHash.slice(0, 32) - const privateKeyHash = seedHash.slice(0, 32); - - this.seed58 = Base58.encode(privateKeyHash); + this.seed58 = Base58.encode(privateKeyHash) const _privateKeyHash = [...privateKeyHash] - let privateKeyBigInt = BigInteger.fromByteArrayUnsigned(_privateKeyHash); + let privateKeyBigInt = BigInteger.fromByteArrayUnsigned(_privateKeyHash) const privateKey = (privateKeyBigInt.mod(SECP256K1_CURVE_ORDER.subtract(BigInteger.ONE))).add(BigInteger.ONE) this.privateKey = privateKey.toByteArrayUnsigned() } generateChainCode(seedHash) { - - this.chainCode = new Sha256().process(seedHash.slice(32, 64)).finish().result; + this.chainCode = new Sha256().process(seedHash.slice(32, 64)).finish().result } generatePublicKey(privateKey) { - const _privateKey = [...privateKey] - const privateKeyBigInt = BigInteger.fromByteArrayUnsigned(_privateKey); + const privateKeyBigInt = BigInteger.fromByteArrayUnsigned(_privateKey) - const epCurve = EllipticCurve.getSECCurveByName("secp256k1"); - const curvePoints = epCurve.getG().multiply(privateKeyBigInt); + const epCurve = EllipticCurve.getSECCurveByName("secp256k1") + const curvePoints = epCurve.getG().multiply(privateKeyBigInt) - const x = curvePoints.getX().toBigInteger(); - const y = curvePoints.getY().toBigInteger(); + const x = curvePoints.getX().toBigInteger() + const y = curvePoints.getY().toBigInteger() /** * Deriving Uncompressed Public Key (65 bytes) * - * const publicKeyBytes = EllipticCurve.integerToBytes(x, 32); - * this.publicKey = publicKeyBytes.concat(EllipticCurve.integerToBytes(y, 32)); - * this.publicKey.unshift(0x04); // append point indicator + * const publicKeyBytes = EllipticCurve.integerToBytes(x, 32) + * this.publicKey = publicKeyBytes.concat(EllipticCurve.integerToBytes(y, 32)) + * this.publicKey.unshift(0x04) // append point indicator */ - // Compressed Public Key (33 bytes) this.publicKey = EllipticCurve.integerToBytes(x, 32) if (y.isEven()) { - this.publicKey.unshift(0x02) // append point indicator } else { - this.publicKey.unshift(0x03) // append point indicator } @@ -330,7 +314,6 @@ export default class AltcoinHDWallet { } generateMainnetMasterPrivateKey() { - // Serialization Variable const s = [] @@ -375,7 +358,6 @@ export default class AltcoinHDWallet { } generateMainnetMasterPublicKey() { - // Serialization Variable const s = [] @@ -495,19 +477,19 @@ export default class AltcoinHDWallet { // TODO: Make this more better in the future const path = 'm/0/0' - // let p = path.split('/'); + // let p = path.split('/') // Get Public kEY const derivePublicChildKey = () => { const _privateKey = [...this.childPrivateKey] - const privateKeyBigInt = BigInteger.fromByteArrayUnsigned(_privateKey); + const privateKeyBigInt = BigInteger.fromByteArrayUnsigned(_privateKey) - const epCurve = EllipticCurve.getSECCurveByName("secp256k1"); - const curvePoints = epCurve.getG().multiply(privateKeyBigInt); + const epCurve = EllipticCurve.getSECCurveByName("secp256k1") + const curvePoints = epCurve.getG().multiply(privateKeyBigInt) - const x = curvePoints.getX().toBigInteger(); - const y = curvePoints.getY().toBigInteger(); + const x = curvePoints.getX().toBigInteger() + const y = curvePoints.getY().toBigInteger() // Compressed Public Key (33 bytes) this.childPublicKey = EllipticCurve.integerToBytes(x, 32) @@ -533,15 +515,15 @@ export default class AltcoinHDWallet { const derivePrivateChildKey = (cI) => { - let ib = []; - ib.push((cI >> 24) & 0xff); - ib.push((cI >> 16) & 0xff); - ib.push((cI >> 8) & 0xff); - ib.push(cI & 0xff); + let ib = [] + ib.push((cI >> 24) & 0xff) + ib.push((cI >> 16) & 0xff) + ib.push((cI >> 8) & 0xff) + ib.push(cI & 0xff) - const s = [...this.publicKey].concat(ib); + const s = [...this.publicKey].concat(ib) - const _hmacSha512 = new jsSHA("SHA-512", "UINT8ARRAY", { numRounds: 1, hmacKey: { value: this.chainCode, format: "UINT8ARRAY" } }); + const _hmacSha512 = new jsSHA("SHA-512", "UINT8ARRAY", { numRounds: 1, hmacKey: { value: this.chainCode, format: "UINT8ARRAY" } }) _hmacSha512.update(new Uint8Array(s)) @@ -550,10 +532,10 @@ export default class AltcoinHDWallet { // SECP256k1 init - const epCurve = EllipticCurve.getSECCurveByName("secp256k1"); + const epCurve = EllipticCurve.getSECCurveByName("secp256k1") - const ki = IL.add(BigInteger.fromByteArrayUnsigned(this.privateKey)).mod(epCurve.getN()); // parse256(IL) + kpar (mod n) ==> ki + const ki = IL.add(BigInteger.fromByteArrayUnsigned(this.privateKey)).mod(epCurve.getN()) // parse256(IL) + kpar (mod n) ==> ki this.childPrivateKey = ki.toByteArrayUnsigned() // Call deriveExtendedPrivateChildKey @@ -577,10 +559,10 @@ export default class AltcoinHDWallet { s.push(...(this.publicKeyHash.slice(0, 4))) // Append Child Index - s.push(childIndex >>> 24); - s.push((childIndex >>> 16) & 0xff); - s.push((childIndex >>> 8) & 0xff); - s.push(childIndex & 0xff); + s.push(childIndex >>> 24) + s.push((childIndex >>> 16) & 0xff) + s.push((childIndex >>> 8) & 0xff) + s.push(childIndex & 0xff) // Append Chain Code s.push(...this.childChainCode) @@ -619,10 +601,10 @@ export default class AltcoinHDWallet { s.push(...(this.publicKeyHash.slice(0, 4))) // Append Child Index - s.push(childIndex >>> 24); - s.push((childIndex >>> 16) & 0xff); - s.push((childIndex >>> 8) & 0xff); - s.push(childIndex & 0xff); + s.push(childIndex >>> 24) + s.push((childIndex >>> 16) & 0xff) + s.push((childIndex >>> 8) & 0xff) + s.push(childIndex & 0xff) // Append Chain Code s.push(...this.childChainCode) @@ -654,24 +636,22 @@ export default class AltcoinHDWallet { const derivePublicGrandChildKey = () => { const _privateKey = [...this.grandChildPrivateKey] - const privateKeyBigInt = BigInteger.fromByteArrayUnsigned(_privateKey); + const privateKeyBigInt = BigInteger.fromByteArrayUnsigned(_privateKey) - const epCurve = EllipticCurve.getSECCurveByName("secp256k1"); - const curvePoints = epCurve.getG().multiply(privateKeyBigInt); + const epCurve = EllipticCurve.getSECCurveByName("secp256k1") + const curvePoints = epCurve.getG().multiply(privateKeyBigInt) - const x = curvePoints.getX().toBigInteger(); - const y = curvePoints.getY().toBigInteger(); + const x = curvePoints.getX().toBigInteger() + const y = curvePoints.getY().toBigInteger() // Compressed Public Key (33 bytes) this.grandChildPublicKey = EllipticCurve.integerToBytes(x, 32) if (y.isEven()) { - this.grandChildPublicKey.unshift(0x02) // append point indicator } else { - this.grandChildPublicKey.unshift(0x03) // append point indicator } @@ -729,16 +709,16 @@ export default class AltcoinHDWallet { const derivePrivateGrandChildKey = (cI, i) => { - let ib = []; - ib.push((cI >> 24) & 0xff); - ib.push((cI >> 16) & 0xff); - ib.push((cI >> 8) & 0xff); - ib.push(cI & 0xff); + let ib = [] + ib.push((cI >> 24) & 0xff) + ib.push((cI >> 16) & 0xff) + ib.push((cI >> 8) & 0xff) + ib.push(cI & 0xff) - const s = [...this.childPublicKey].concat(ib); + const s = [...this.childPublicKey].concat(ib) - const _hmacSha512 = new jsSHA("SHA-512", "UINT8ARRAY", { numRounds: 1, hmacKey: { value: this.childChainCode, format: "UINT8ARRAY" } }); + const _hmacSha512 = new jsSHA("SHA-512", "UINT8ARRAY", { numRounds: 1, hmacKey: { value: this.childChainCode, format: "UINT8ARRAY" } }) _hmacSha512.update(new Uint8Array(s)) @@ -746,10 +726,10 @@ export default class AltcoinHDWallet { this.grandChildChainCode = _hmacSha512.getHMAC('UINT8ARRAY').slice(32, 64) // IR according to the SPEC // SECP256k1 init - const epCurve = EllipticCurve.getSECCurveByName("secp256k1"); + const epCurve = EllipticCurve.getSECCurveByName("secp256k1") - const ki = IL.add(BigInteger.fromByteArrayUnsigned(this.childPrivateKey)).mod(epCurve.getN()); // parse256(IL) + kpar (mod n) ==> ki + const ki = IL.add(BigInteger.fromByteArrayUnsigned(this.childPrivateKey)).mod(epCurve.getN()) // parse256(IL) + kpar (mod n) ==> ki this.grandChildPrivateKey = ki.toByteArrayUnsigned() @@ -774,10 +754,10 @@ export default class AltcoinHDWallet { s.push(...(this.childPublicKeyHash.slice(0, 4))) // Append Child Index - s.push(childIndex >>> 24); - s.push((childIndex >>> 16) & 0xff); - s.push((childIndex >>> 8) & 0xff); - s.push(childIndex & 0xff); + s.push(childIndex >>> 24) + s.push((childIndex >>> 16) & 0xff) + s.push((childIndex >>> 8) & 0xff) + s.push(childIndex & 0xff) // Append Chain Code s.push(...this.grandChildChainCode) @@ -816,10 +796,10 @@ export default class AltcoinHDWallet { s.push(...(this.childPublicKeyHash.slice(0, 4))) // Append Child Index - s.push(childIndex >>> 24); - s.push((childIndex >>> 16) & 0xff); - s.push((childIndex >>> 8) & 0xff); - s.push(childIndex & 0xff); + s.push(childIndex >>> 24) + s.push((childIndex >>> 16) & 0xff) + s.push((childIndex >>> 8) & 0xff) + s.push(childIndex & 0xff) // Append Chain Code s.push(...this.grandChildChainCode) diff --git a/qortal-ui-crypto/api/constants.js b/qortal-ui-crypto/api/constants.js index 511ab99e..2bbb349f 100644 --- a/qortal-ui-crypto/api/constants.js +++ b/qortal-ui-crypto/api/constants.js @@ -1,152 +1,152 @@ -"use strict"; +'use strict' // Qortal TX types const TX_TYPES = { - 1: "Genesis", - 2: "Payment", - 3: "Name registration", - 4: "Name update", - 5: "Sell name", - 6: "Cancel sell name", - 7: "Buy name", - 8: "Create poll", - 9: "Vote in poll", - 10: "Arbitrary", - 11: "Issue asset", - 12: "Transfer asset", - 13: "Create asset order", - 14: "Cancel asset order", - 15: "Multi-payment transaction", - 16: "Deploy AT", - 17: "Message", - 18: "Chat", - 19: "Publicize", - 20: "Airdrop", - 21: "AT", - 22: "Create group", - 23: "Update group", - 24: "Add group admin", - 25: "Remove group admin", - 26: "Group ban", - 27: "Cancel group ban", - 28: "Group kick", - 29: "Group invite", - 30: "Cancel group invite", - 31: "Join group", - 32: "Leave group", - 33: "Group approval", - 34: "Set group", - 35: "Update asset", - 36: "Account flags", - 37: "Enable forging", - 38: "Reward share", - 39: "Account level", - 40: "Transfer privs", - 41: "Presence" + 1: "Genesis", + 2: "Payment", + 3: "Name registration", + 4: "Name update", + 5: "Sell name", + 6: "Cancel sell name", + 7: "Buy name", + 8: "Create poll", + 9: "Vote in poll", + 10: "Arbitrary", + 11: "Issue asset", + 12: "Transfer asset", + 13: "Create asset order", + 14: "Cancel asset order", + 15: "Multi-payment transaction", + 16: "Deploy AT", + 17: "Message", + 18: "Chat", + 19: "Publicize", + 20: "Airdrop", + 21: "AT", + 22: "Create group", + 23: "Update group", + 24: "Add group admin", + 25: "Remove group admin", + 26: "Group ban", + 27: "Cancel group ban", + 28: "Group kick", + 29: "Group invite", + 30: "Cancel group invite", + 31: "Join group", + 32: "Leave group", + 33: "Group approval", + 34: "Set group", + 35: "Update asset", + 36: "Account flags", + 37: "Enable forging", + 38: "Reward share", + 39: "Account level", + 40: "Transfer privs", + 41: "Presence" } // Qortal error codes const ERROR_CODES = { - 1: "Valid OK", - 2: "Invalid address", - 3: "Negative amount", - 4: "Nagative fee", - 5: "No balance", - 6: "Invalid reference", - 7: "Invalid time length", - 8: "Invalid value length", - 9: "Name already registered", - 10: "Name does not exist", - 11: "Invalid name owner", - 12: "Name already for sale", - 13: "Name not for sale", - 14: "Name buyer already owner", - 15: "Invalid amount", - 16: "Invalid seller", - 17: "Name not lowercase", - 18: "Invalid description length", - 19: "Invalid options length", - 20: "Invalid option length", - 21: "Duplicate option", - 22: "Poll already created", - 23: "Poll already has votes", - 24: "Poll does not exist", - 25: "Option does not exist", - 26: "Already voted for that option", - 27: "Invalid data length", - 28: "Invalid quantity", - 29: "Asset does not exist", - 30: "Invalid return", - 31: "Have equals want", - 32: "Order does not exist", - 33: "Invalid order creator", - 34: "Invalid payments length", - 35: "Negative price", - 36: "Invalid creation bytes", - 37: "Invalid tags length", - 38: "Invalid type length", - 39: "Invalid AT transaction", - 40: "Insufficient fee", - 41: "Asset does not match AT", + 1: "Valid OK", + 2: "Invalid address", + 3: "Negative amount", + 4: "Nagative fee", + 5: "No balance", + 6: "Invalid reference", + 7: "Invalid time length", + 8: "Invalid value length", + 9: "Name already registered", + 10: "Name does not exist", + 11: "Invalid name owner", + 12: "Name already for sale", + 13: "Name not for sale", + 14: "Name buyer already owner", + 15: "Invalid amount", + 16: "Invalid seller", + 17: "Name not lowercase", + 18: "Invalid description length", + 19: "Invalid options length", + 20: "Invalid option length", + 21: "Duplicate option", + 22: "Poll already created", + 23: "Poll already has votes", + 24: "Poll does not exist", + 25: "Option does not exist", + 26: "Already voted for that option", + 27: "Invalid data length", + 28: "Invalid quantity", + 29: "Asset does not exist", + 30: "Invalid return", + 31: "Have equals want", + 32: "Order does not exist", + 33: "Invalid order creator", + 34: "Invalid payments length", + 35: "Negative price", + 36: "Invalid creation bytes", + 37: "Invalid tags length", + 38: "Invalid type length", + 39: "Invalid AT transaction", + 40: "Insufficient fee", + 41: "Asset does not match AT", - 43: "Asset already exists", - 44: "Missing creator", - 45: "Timestamp too old", - 46: "Timestamp too new", - 47: "Too many unconfirmed", - 48: "Group already exists", - 49: "Group does not exist", - 50: "Invalid group owner", - 51: "Already group memeber", - 52: "Group owner can not leave", - 53: "Not group member", - 54: "Already group admin", - 55: "Not group admin", - 56: "Invalid lifetime", - 57: "Invite unknown", - 58: "Ban exists", - 59: "Ban unknown", - 60: "Banned from group", - 61: "Join request", - 62: "Invalid group approval threshold", - 63: "Group ID mismatch", - 64: "Invalid group ID", - 65: "Transaction unknown", - 66: "Transaction already confirmed", - 67: "Invalid TX group", - 68: "TX group ID mismatch", - 69: "Multiple names forbidden", - 70: "Invalid asset owner", - 71: "AT is finished", - 72: "No flag permission", - 73: "Not minting accout", + 43: "Asset already exists", + 44: "Missing creator", + 45: "Timestamp too old", + 46: "Timestamp too new", + 47: "Too many unconfirmed", + 48: "Group already exists", + 49: "Group does not exist", + 50: "Invalid group owner", + 51: "Already group memeber", + 52: "Group owner can not leave", + 53: "Not group member", + 54: "Already group admin", + 55: "Not group admin", + 56: "Invalid lifetime", + 57: "Invite unknown", + 58: "Ban exists", + 59: "Ban unknown", + 60: "Banned from group", + 61: "Join request", + 62: "Invalid group approval threshold", + 63: "Group ID mismatch", + 64: "Invalid group ID", + 65: "Transaction unknown", + 66: "Transaction already confirmed", + 67: "Invalid TX group", + 68: "TX group ID mismatch", + 69: "Multiple names forbidden", + 70: "Invalid asset owner", + 71: "AT is finished", + 72: "No flag permission", + 73: "Not minting accout", - 77: "Invalid rewardshare percent", - 78: "Public key unknown", - 79: "Invalid public key", - 80: "AT unknown", - 81: "AT already exists", - 82: "Group approval not required", - 83: "Group approval decided", - 84: "Maximum reward shares", - 85: "Transaction already exists", - 86: "No blockchain lock", - 87: "Order already closed", - 88: "Clock not synced", - 89: "Asset not spendable", - 90: "Account can not reward share", - 91: "Self share exists", - 92: "Account already exists", - 93: "Invalid group block delay", - 94: "Incorrect nonce", - 95: "Ivalid timestamp signature", - 96: "Address blocked", - 97: "Name Blocked", - 98: "Group approval required", - 99: "Account not transferable", + 77: "Invalid rewardshare percent", + 78: "Public key unknown", + 79: "Invalid public key", + 80: "AT unknown", + 81: "AT already exists", + 82: "Group approval not required", + 83: "Group approval decided", + 84: "Maximum reward shares", + 85: "Transaction already exists", + 86: "No blockchain lock", + 87: "Order already closed", + 88: "Clock not synced", + 89: "Asset not spendable", + 90: "Account can not reward share", + 91: "Self share exists", + 92: "Account already exists", + 93: "Invalid group block delay", + 94: "Incorrect nonce", + 95: "Ivalid timestamp signature", + 96: "Address blocked", + 97: "Name Blocked", + 98: "Group approval required", + 99: "Account not transferable", - 999: "Ivalid but ok", - 1000: "Not yet released." + 999: "Ivalid but ok", + 1000: "Not yet released." } // Qortal 8 decimals @@ -158,6 +158,9 @@ const ADDRESS_VERSION = 58 // Proxy for api calls const PROXY_URL = "/proxy/" +// Chat reference timestamp +const CHAT_REFERENCE_FEATURE_TRIGGER_TIMESTAMP = 9999999999999 + // Used as a salt for all qora addresses. Salts used for storing your private keys in local storage will be randomly generated const STATIC_SALT = new Uint8Array([54, 190, 201, 206, 65, 29, 123, 129, 147, 231, 180, 166, 171, 45, 95, 165, 78, 200, 208, 194, 44, 207, 221, 146, 45, 238, 68, 68, 69, 102, 62, 6]) const BCRYPT_ROUNDS = 10 // Remember that the total work spent on key derivation is BCRYPT_ROUNDS * KDF_THREADS @@ -165,4 +168,4 @@ const BCRYPT_VERSION = "2a" const STATIC_BCRYPT_SALT = `$${BCRYPT_VERSION}$${BCRYPT_ROUNDS}$IxVE941tXVUD4cW0TNVm.O` const KDF_THREADS = 16 -export { TX_TYPES, ERROR_CODES, QORT_DECIMALS, PROXY_URL, STATIC_SALT, ADDRESS_VERSION, KDF_THREADS, STATIC_BCRYPT_SALT } +export { TX_TYPES, ERROR_CODES, QORT_DECIMALS, PROXY_URL, STATIC_SALT, ADDRESS_VERSION, KDF_THREADS, STATIC_BCRYPT_SALT, CHAT_REFERENCE_FEATURE_TRIGGER_TIMESTAMP } diff --git a/qortal-ui-crypto/api/createTransaction.js b/qortal-ui-crypto/api/createTransaction.js index d876b98a..2a56aa56 100644 --- a/qortal-ui-crypto/api/createTransaction.js +++ b/qortal-ui-crypto/api/createTransaction.js @@ -6,33 +6,33 @@ import signArbitrary from './transactions/arbitrary/signArbitrary.js' export const createTransaction = (type, keyPair, params) => { - const tx = new transactions[type]() - tx.keyPair = keyPair - Object.keys(params).forEach(param => { - tx[param] = params[param] - }) + const tx = new transactions[type]() + tx.keyPair = keyPair + Object.keys(params).forEach(param => { + tx[param] = params[param] + }) - return tx + return tx } // Compute Chat Nonce export const computeChatNonce = bytes => request('/chat/compute', { - method: 'POST', - body: Base58.encode(bytes) + method: 'POST', + body: Base58.encode(bytes) }) // Sign Chat Transactions export const signChatTransaction = (chatBytes, nonce, keyPair) => { - return signChat(chatBytes, nonce, keyPair) + return signChat(chatBytes, nonce, keyPair) } // Sign Arbitrary Transactions export const signArbitraryTransaction = (arbitraryBytesBase58, arbitraryBytesForSigningBase58, nonce, keyPair) => { - return signArbitrary(arbitraryBytesBase58, arbitraryBytesForSigningBase58, nonce, keyPair) + return signArbitrary(arbitraryBytesBase58, arbitraryBytesForSigningBase58, nonce, keyPair) } // Process Transactions export const processTransaction = bytes => request('/transactions/process', { - method: 'POST', - body: Base58.encode(bytes) + method: 'POST', + body: Base58.encode(bytes) }) diff --git a/qortal-ui-crypto/api/createWallet.js b/qortal-ui-crypto/api/createWallet.js index d342c7c3..ed978183 100644 --- a/qortal-ui-crypto/api/createWallet.js +++ b/qortal-ui-crypto/api/createWallet.js @@ -4,26 +4,26 @@ import Base58 from './deps/Base58.js' import { decryptStoredWallet } from './decryptStoredWallet.js' export const createWallet = async (sourceType, source, statusUpdateFn) => { - let version, seed + let version, seed - switch (sourceType) { - case 'phrase': - version = 2 - seed = await kdf(source.seedPhrase, void 0, statusUpdateFn) - break - case 'seed': - version = 1 - seed = Base58.decode(source.seed) - break - case 'storedWallet': - case 'backedUpSeed': - version = source.wallet.version - seed = await decryptStoredWallet(source.password, source.wallet, statusUpdateFn) - break - default: - throw 'sourceType ' + sourceType + ' not recognized' - } + switch (sourceType) { + case 'phrase': + version = 2 + seed = await kdf(source.seedPhrase, void 0, statusUpdateFn) + break + case 'seed': + version = 1 + seed = Base58.decode(source.seed) + break + case 'storedWallet': + case 'backedUpSeed': + version = source.wallet.version + seed = await decryptStoredWallet(source.password, source.wallet, statusUpdateFn) + break + default: + throw 'sourceType ' + sourceType + ' not recognized' + } - const wallet = new PhraseWallet(seed, version) - return wallet + const wallet = new PhraseWallet(seed, version) + return wallet } diff --git a/qortal-ui-crypto/api/decryptStoredWallet.js b/qortal-ui-crypto/api/decryptStoredWallet.js index e47a33b4..f98649cd 100644 --- a/qortal-ui-crypto/api/decryptStoredWallet.js +++ b/qortal-ui-crypto/api/decryptStoredWallet.js @@ -3,21 +3,21 @@ import { kdf } from './kdf.js' import { HmacSha512, AES_CBC } from 'asmcrypto.js' export const decryptStoredWallet = async (password, wallet, statusFn = () => { }) => { - statusFn('Decoding saved data') - const encryptedSeedBytes = Base58.decode(wallet.encryptedSeed) - const iv = Base58.decode(wallet.iv) - const salt = Base58.decode(wallet.salt) - statusFn('Generating decryption key') - const key = await kdf(password, salt, statusFn) - const encryptionKey = key.slice(0, 32) - const macKey = key.slice(32, 63) + statusFn('Decoding saved data') + const encryptedSeedBytes = Base58.decode(wallet.encryptedSeed) + const iv = Base58.decode(wallet.iv) + const salt = Base58.decode(wallet.salt) + statusFn('Generating decryption key') + const key = await kdf(password, salt, statusFn) + const encryptionKey = key.slice(0, 32) + const macKey = key.slice(32, 63) - statusFn('Checking key') - const mac = new HmacSha512(macKey).process(encryptedSeedBytes).finish().result - if (Base58.encode(mac) !== wallet.mac) { - throw new Error('Incorrect password') - } - statusFn('Decrypting') - const decryptedBytes = AES_CBC.decrypt(encryptedSeedBytes, encryptionKey, false, iv) - return decryptedBytes + statusFn('Checking key') + const mac = new HmacSha512(macKey).process(encryptedSeedBytes).finish().result + if (Base58.encode(mac) !== wallet.mac) { + throw new Error('Incorrect password') + } + statusFn('Decrypting') + const decryptedBytes = AES_CBC.decrypt(encryptedSeedBytes, encryptionKey, false, iv) + return decryptedBytes } diff --git a/qortal-ui-crypto/api/kdf.js b/qortal-ui-crypto/api/kdf.js index b94134ac..8c18888a 100644 --- a/qortal-ui-crypto/api/kdf.js +++ b/qortal-ui-crypto/api/kdf.js @@ -4,36 +4,36 @@ import { Sha512 } from 'asmcrypto.js' import utils from '../api/deps/utils.js' export const kdf = async (seed, salt, status = () => { }) => { - const state = store.getState() - const config = state.config - const workers = state.app.workers.workers - status('Waiting for workers to be ready') - await stateAwait(state => state.app.workers.ready) - status('Deriving key parts') - salt = new Uint8Array(salt) - const seedParts = await Promise.all(workers.map((worker, index) => { - const nonce = index - return worker.request('kdf', { - key: seed, - salt, - nonce, - staticSalt: config.crypto.staticSalt, - staticBcryptSalt: config.crypto.staticBcryptSalt - }).then(data => { - let jsonData - try { - jsonData = JSON.parse(data) - data = jsonData - } catch (e) { - // ... - } - if (seed !== data.key) throw new Error('Error, incorrect key. ' + seed + ' !== ' + data.key) - if (nonce !== data.nonce) throw new Error('Error, incorrect nonce') - return data.result - }) - })) - status('Combining key parts') - const result = new Sha512().process(utils.stringtoUTF8Array(config.crypto.staticSalt + seedParts.reduce((a, c) => a + c))).finish().result - status('Key is ready ') - return result + const state = store.getState() + const config = state.config + const workers = state.app.workers.workers + status('Waiting for workers to be ready') + await stateAwait(state => state.app.workers.ready) + status('Deriving key parts') + salt = new Uint8Array(salt) + const seedParts = await Promise.all(workers.map((worker, index) => { + const nonce = index + return worker.request('kdf', { + key: seed, + salt, + nonce, + staticSalt: config.crypto.staticSalt, + staticBcryptSalt: config.crypto.staticBcryptSalt + }).then(data => { + let jsonData + try { + jsonData = JSON.parse(data) + data = jsonData + } catch (e) { + // ... + } + if (seed !== data.key) throw new Error('Error, incorrect key. ' + seed + ' !== ' + data.key) + if (nonce !== data.nonce) throw new Error('Error, incorrect nonce') + return data.result + }) + })) + status('Combining key parts') + const result = new Sha512().process(utils.stringtoUTF8Array(config.crypto.staticSalt + seedParts.reduce((a, c) => a + c))).finish().result + status('Key is ready ') + return result } diff --git a/qortal-ui-crypto/api/registerUsername.js b/qortal-ui-crypto/api/registerUsername.js index c270c209..9715a078 100644 --- a/qortal-ui-crypto/api/registerUsername.js +++ b/qortal-ui-crypto/api/registerUsername.js @@ -8,39 +8,32 @@ const CHECK_LAST_REF_INTERVAL = 30 * 1000 // err 30 seconds const pendingAddresses = {} -// const config = store.getState().config -// const node = config.coin.node.api -// const baseUrl = node.url + node.tail - const checkLastRefs = () => { - Object.entries(pendingAddresses).forEach(([address, fn]) => { - // console.log(fn, address) - request('addresses/lastreference/' + address).then(res => { - if (res === 'false') return - fn(res) - delete pendingAddresses[address] - clearInterval(lastRefInterval) - }) - // fetch(baseUrl + 'addresses/lastreference/' + address) - // .then(async res => res.text()) - }) + Object.entries(pendingAddresses).forEach(([address, fn]) => { + request('addresses/lastreference/' + address).then(res => { + if (res === 'false') return + fn(res) + delete pendingAddresses[address] + clearInterval(lastRefInterval) + }) + }) } const lastRefInterval = setInterval(() => checkLastRefs(), CHECK_LAST_REF_INTERVAL) const callOnLastRef = (address, fn) => { - pendingAddresses[address] = fn + pendingAddresses[address] = fn } export const registerUsername = async ({ name, address, lastRef, keyPair }) => { - callOnLastRef(address, lastreference => { - const txBytes = createTransaction(TX_TYPE, keyPair, { - registrantPublicKey: keyPair.publicKey, - registrantAddress: address, - name, - value: address, - lastReference: lastreference - }) - processTransaction(txBytes).then(res => {}) - }) + callOnLastRef(address, lastreference => { + const txBytes = createTransaction(TX_TYPE, keyPair, { + registrantPublicKey: keyPair.publicKey, + registrantAddress: address, + name, + value: address, + lastReference: lastreference + }) + processTransaction(txBytes).then(res => { }) + }) } diff --git a/qortal-ui-crypto/api/storeWallet.js b/qortal-ui-crypto/api/storeWallet.js index eab5fa99..9d16c8af 100644 --- a/qortal-ui-crypto/api/storeWallet.js +++ b/qortal-ui-crypto/api/storeWallet.js @@ -1,33 +1,29 @@ import { HmacSha512, AES_CBC } from 'asmcrypto.js' import { kdf } from './kdf.js' -// import Base58 from '../qora/deps/Base58.js' import Base58 from './deps/Base58.js' const getRandomValues = window.crypto ? window.crypto.getRandomValues.bind(window.crypto) : window.msCrypto.getRandomValues.bind(window.msCrypto) export const generateSaveWalletData = async (wallet, password, kdfThreads, statusUpdateFn) => { - statusUpdateFn('Generating random values') - let iv = new Uint8Array(16) - getRandomValues(iv) - let salt = new Uint8Array(32) - getRandomValues(salt) // Can actually use a salt this time, as we can store the salt with the wallet - - // const key = PBKDF2_HMAC_SHA512.bytes(utils.stringtoUTF8Array(password), salt, PBKDF2_ROUNDS, 64) // 512bit key to be split in two for mac/encryption - const key = await kdf(password, salt, statusUpdateFn) - statusUpdateFn('Encrypting seed') - const encryptionKey = key.slice(0, 32) - const macKey = key.slice(32, 63) - const encryptedSeed = AES_CBC.encrypt(wallet._byteSeed, encryptionKey, false, iv) - // const mac = HmacSha512.bytes(encryptedSeed, macKey) - statusUpdateFn('Generating mac') - const mac = new HmacSha512(macKey).process(encryptedSeed).finish().result - return { - address0: wallet._addresses[0].address, - encryptedSeed: Base58.encode(encryptedSeed), - salt: Base58.encode(salt), - iv: Base58.encode(iv), - version: wallet._walletVersion, - mac: Base58.encode(mac), - kdfThreads - } + statusUpdateFn('Generating random values') + let iv = new Uint8Array(16) + getRandomValues(iv) + let salt = new Uint8Array(32) + getRandomValues(salt) + const key = await kdf(password, salt, statusUpdateFn) + statusUpdateFn('Encrypting seed') + const encryptionKey = key.slice(0, 32) + const macKey = key.slice(32, 63) + const encryptedSeed = AES_CBC.encrypt(wallet._byteSeed, encryptionKey, false, iv) + statusUpdateFn('Generating mac') + const mac = new HmacSha512(macKey).process(encryptedSeed).finish().result + return { + address0: wallet._addresses[0].address, + encryptedSeed: Base58.encode(encryptedSeed), + salt: Base58.encode(salt), + iv: Base58.encode(iv), + version: wallet._walletVersion, + mac: Base58.encode(mac), + kdfThreads + } } diff --git a/qortal-ui-crypto/api/tradeRequest.js b/qortal-ui-crypto/api/tradeRequest.js index f3ae00f0..797cbe5b 100644 --- a/qortal-ui-crypto/api/tradeRequest.js +++ b/qortal-ui-crypto/api/tradeRequest.js @@ -1,145 +1,140 @@ // Trade Bot -import TradeBotCreateRequest from './transactions/trade-portal/tradebot/TradeBotCreateRequest.js'; -import TradeBotRespondRequest from './transactions/trade-portal/tradebot/TradeBotRespondRequest.js'; +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' - -// Trade Offer -import DeleteTradeOffer from './transactions/trade-portal/tradeoffer/DeleteTradeOffer.js'; - +import DeleteTradeOffer from './transactions/trade-portal/tradeoffer/DeleteTradeOffer.js' import { request } from './fetch-request' - // TradeBotCreateRequest export const tradeBotCreateRequest = (requestObject) => { - const txn = new TradeBotCreateRequest().createTransaction(requestObject) - const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node]; + const txn = new TradeBotCreateRequest().createTransaction(requestObject) + const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node] - return request(`/crosschain/tradebot/create?apiKey=${myNode.apiKey}`, { - method: 'POST', - headers: { - 'Accept': 'text/plain', - 'Content-Type': 'application/json' - }, - body: JSON.stringify(txn) - }) + return request(`/crosschain/tradebot/create?apiKey=${myNode.apiKey}`, { + method: 'POST', + headers: { + 'Accept': 'text/plain', + 'Content-Type': 'application/json' + }, + body: JSON.stringify(txn) + }) } // TradeBotRespondRequest export const tradeBotRespondRequest = (requestObject) => { - const txn = new TradeBotRespondRequest().createTransaction(requestObject) - const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node]; + const txn = new TradeBotRespondRequest().createTransaction(requestObject) + const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node] - return request(`/crosschain/tradebot/respond?apiKey=${myNode.apiKey}`, { - method: 'POST', - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json' - }, - body: JSON.stringify(txn) - }) + return request(`/crosschain/tradebot/respond?apiKey=${myNode.apiKey}`, { + method: 'POST', + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json' + }, + body: JSON.stringify(txn) + }) } - // Sign Trade Transactions export const signTradeBotTxn = (unsignedTxn, keyPair) => { - return signTradeBotTransaction(unsignedTxn, keyPair) + return signTradeBotTransaction(unsignedTxn, keyPair) } // Delete Trade Offer export const deleteTradeOffer = (requestObject) => { - const txn = new DeleteTradeOffer().createTransaction(requestObject) - const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node]; + const txn = new DeleteTradeOffer().createTransaction(requestObject) + const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node] - return request(`/crosschain/tradeoffer?apiKey=${myNode.apiKey}`, { - method: 'DELETE', - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json' - }, - body: JSON.stringify(txn) - }) + return request(`/crosschain/tradeoffer?apiKey=${myNode.apiKey}`, { + method: 'DELETE', + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json' + }, + body: JSON.stringify(txn) + }) } // Send BTC export const sendBtc = (requestObject) => { - const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node]; + const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node] - return request(`/crosschain/btc/send?apiKey=${myNode.apiKey}`, { - method: 'POST', - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json' - }, - body: JSON.stringify(requestObject) - }) + return request(`/crosschain/btc/send?apiKey=${myNode.apiKey}`, { + method: 'POST', + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json' + }, + body: JSON.stringify(requestObject) + }) } // Send LTC export const sendLtc = (requestObject) => { - const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node]; + const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node] - return request(`/crosschain/ltc/send?apiKey=${myNode.apiKey}`, { - method: 'POST', - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json' - }, - body: JSON.stringify(requestObject) - }) + return request(`/crosschain/ltc/send?apiKey=${myNode.apiKey}`, { + method: 'POST', + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json' + }, + body: JSON.stringify(requestObject) + }) } // Send DOGE export const sendDoge = (requestObject) => { - const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node]; + const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node] - return request(`/crosschain/doge/send?apiKey=${myNode.apiKey}`, { - method: 'POST', - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json' - }, - body: JSON.stringify(requestObject) - }) + return request(`/crosschain/doge/send?apiKey=${myNode.apiKey}`, { + method: 'POST', + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json' + }, + body: JSON.stringify(requestObject) + }) } // Send DGB export const sendDgb = (requestObject) => { - const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node]; + const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node] - return request(`/crosschain/dgb/send?apiKey=${myNode.apiKey}`, { - method: 'POST', - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json' - }, - body: JSON.stringify(requestObject) - }) + return request(`/crosschain/dgb/send?apiKey=${myNode.apiKey}`, { + method: 'POST', + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json' + }, + body: JSON.stringify(requestObject) + }) } // Send RVN export const sendRvn = (requestObject) => { - const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node]; + const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node] - return request(`/crosschain/rvn/send?apiKey=${myNode.apiKey}`, { - method: 'POST', - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json' - }, - body: JSON.stringify(requestObject) - }) + return request(`/crosschain/rvn/send?apiKey=${myNode.apiKey}`, { + method: 'POST', + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json' + }, + body: JSON.stringify(requestObject) + }) } // Send ARRR export const sendArrr = (requestObject) => { - const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node]; + const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node] - return request(`/crosschain/arrr/send?apiKey=${myNode.apiKey}`, { - method: 'POST', - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json' - }, - body: JSON.stringify(requestObject) - }) + return request(`/crosschain/arrr/send?apiKey=${myNode.apiKey}`, { + method: 'POST', + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json' + }, + body: JSON.stringify(requestObject) + }) } diff --git a/qortal-ui-crypto/api/transactions/AirdropTransaction.js b/qortal-ui-crypto/api/transactions/AirdropTransaction.js index 552e42e8..e23029a8 100644 --- a/qortal-ui-crypto/api/transactions/AirdropTransaction.js +++ b/qortal-ui-crypto/api/transactions/AirdropTransaction.js @@ -1,50 +1,35 @@ -'use strict'; +'use strict' import TransactionBase from './TransactionBase.js' import { QORT_DECIMALS } from '../constants.js' -// import { Sha256 } from 'asmcrypto.js/dist_es5/entry-export_all.js' export default class PaymentTransaction extends TransactionBase { - constructor () { - super() - this.type = 20 - this.amount = 42 * Math.pow(10, 8) - this.tests.push( - () => { - if (!(this._amount >= 0)) { - return 'Invalid amount ' + this._amount / QORT_DECIMALS - } - return true - }, - () => { - if (!(this._recipient instanceof Uint8Array && this._recipient.length == 25)) { - return 'Invalid recipient ' + Base58.encode(this._recipient) - } - return true - } - ) - } + constructor() { + super() + this.type = 20 + } - set recipient (recipient) { // Always Base58 encoded. Accepts Uint8Array or Base58 string. - this._recipient = recipient instanceof Uint8Array ? recipient : this.constructor.Base58.decode(recipient) - } - set amount (amount) { - this._amount = amount * QORT_DECIMALS - this._amountBytes = this.constructor.utils.int64ToBytes(amount) - } + set recipient(recipient) { + this._recipient = recipient instanceof Uint8Array ? recipient : this.constructor.Base58.decode(recipient) + } - set reference (seed) { - const sha = seed => new Sha512().process(seed).finish().result - let reference = sha(sha(seed)) - reference += reference - } + set amount(amount) { + this._amount = amount * QORT_DECIMALS + this._amountBytes = this.constructor.utils.int64ToBytes(amount) + } - get params () { - const params = super.params - params.push( - this._recipient, - this._amountBytes, - this._feeBytes - ) - return params - } + set reference(seed) { + const sha = seed => new Sha512().process(seed).finish().result + let reference = sha(sha(seed)) + reference += reference + } + + get params() { + const params = super.params + params.push( + this._recipient, + this._amountBytes, + this._feeBytes + ) + return params + } } diff --git a/qortal-ui-crypto/api/transactions/DelegationTransaction.js b/qortal-ui-crypto/api/transactions/DelegationTransaction.js index bc74502a..d2b670b8 100644 --- a/qortal-ui-crypto/api/transactions/DelegationTransaction.js +++ b/qortal-ui-crypto/api/transactions/DelegationTransaction.js @@ -1,31 +1,22 @@ -'use strict'; +'use strict' import TransactionBase from './TransactionBase.js' -// import { QORT_DECIMALS } from "../constants.js" // Not needed, no amount export default class DelegationTransaction extends TransactionBase { - constructor () { - super() - this.type = 18 - this.tests.push( - () => { - if (!(this._superNodeAddress instanceof Uint8Array && this._superNodeAddress.length == 25)) { - return 'Invalid recipient ' + Base58.encode(this._superNodeAddress) - } - return true - } - ) - } + constructor() { + super() + this.type = 18 + } - set superNodeAddress (superNodeAddress) { // Always Base58 encoded. Accepts Uint8Array or Base58 string. - this._superNodeAddress = superNodeAddress instanceof Uint8Array ? superNodeAddress : this.constructor.Base58.decode(superNodeAddress) - } + set superNodeAddress(superNodeAddress) { + this._superNodeAddress = superNodeAddress instanceof Uint8Array ? superNodeAddress : this.constructor.Base58.decode(superNodeAddress) + } - get params () { - const params = super.params - params.push( - this._superNodeAddress, - this._feeBytes - ) - return params - } + get params() { + const params = super.params + params.push( + this._superNodeAddress, + this._feeBytes + ) + return params + } } diff --git a/qortal-ui-crypto/api/transactions/MessageTransaction.js b/qortal-ui-crypto/api/transactions/MessageTransaction.js index f28a25fe..ea0e4079 100644 --- a/qortal-ui-crypto/api/transactions/MessageTransaction.js +++ b/qortal-ui-crypto/api/transactions/MessageTransaction.js @@ -1,95 +1,47 @@ -"use strict"; -import PaymentTransaction from "./PaymentTransaction.js" -import { QORT_DECIMALS } from "../constants.js" +'use strict' +import PaymentTransaction from './PaymentTransaction.js' +import { QORT_DECIMALS } from '../constants.js' -/* ==================================== -EXTEND THE PAYMENT TRANSACTION YOU CLOWN -====================================== */ +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 + } -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 - } - - set message(message /* UTF8 String */){ - // ...yes? no? - this.messageText = message; - - // Not sure about encoding here... - //this._message = message instanceof Uint8Array ? message : this.constructor.Base58.decode(message); - this._message = this.constructor.utils.stringtoUTF8Array(message) - this._messageLength = this.constructor.utils.int64ToBytes(this._message.length) - } - set isEncrypted(isEncrypted){ - this._isEncrypted[0] = isEncrypted; - } - set isText(isText){ - this._isText[0] = isText; - } - get _params(){ - // dont extend super because paymentTrasaction is different - //const params = super.params; - return [ - this._typeBytes, - this._timestampBytes, - this._lastReference, - this._keyPair.publicKey, - this._recipient, - this._key, - this._amountBytes, - this._messageLength, - this._message, - this._isEncrypted, - this._isText, - this._feeBytes - ] - } + set message(message /* UTF8 String */) { + // ...yes? no? + this.messageText = message + + // Not sure about encoding here... + this._message = this.constructor.utils.stringtoUTF8Array(message) + this._messageLength = this.constructor.utils.int64ToBytes(this._message.length) + } + + set isEncrypted(isEncrypted) { + this._isEncrypted[0] = isEncrypted + } + + set isText(isText) { + this._isText[0] = isText + } + + get _params() { + return [ + this._typeBytes, + this._timestampBytes, + this._lastReference, + this._keyPair.publicKey, + this._recipient, + this._key, + this._amountBytes, + this._messageLength, + this._message, + this._isEncrypted, + this._isText, + this._feeBytes + ] + } } - -//"use strict"; -//function generateSignatureMessageTransaction(keyPair, lastReference, recipient, amount, fee, timestamp, message, isText, isEncrypted) => { -// const data = generateMessageTransactionBase(keyPair.publicKey, lastReference, recipient, amount, fee, timestamp, message, isText, isEncrypted); -// return nacl.sign.detached(data, keyPair.privateKey); -//} -// -//function generateMessageTransaction(keyPair, lastReference, recipient, amount, fee, timestamp, message, isText, isEncrypted, signature) => { -// return appendBuffer(generateMessageTransactionBase(keyPair.publicKey, lastReference, recipient, amount, fee, timestamp, message, isText, isEncrypted), -// signature); -//} -//function generateMessageTransactionBase(publicKey, lastReference, recipient, amount, fee, timestamp, message, isText, isEncrypted) => { -// txType = TYPES.MESSAGE_TRANSACTION; -// -// const typeBytes = int32ToBytes(txType); -// const timestampBytes = int64ToBytes(timestamp); -// const amountBytes = int64ToBytes(amount * 100000000); -// const feeBytes = int64ToBytes(fee * 100000000); -// const messageLength = int32ToBytes(message.length); -// const key = int64ToBytes(0); -// -// isTextB = new Uint8Array(1); -// isTextB[0] = isText; -// -// isEncryptedB = new Uint8Array(1); -// isEncryptedB[0] = isEncrypted; -// -// let data = new Uint8Array(); -// -// data = appendBuffer(data, typeBytes); -// data = appendBuffer(data, timestampBytes); -// data = appendBuffer(data, lastReference); -// data = appendBuffer(data, publicKey); -// data = appendBuffer(data, recipient); -// data = appendBuffer(data, key); -// data = appendBuffer(data, amountBytes); -// data = appendBuffer(data, messageLength); -// data = appendBuffer(data, message); -// data = appendBuffer(data, isEncryptedB); -// data = appendBuffer(data, isTextB); -// data = appendBuffer(data, feeBytes); -// -// return data; -//} \ No newline at end of file diff --git a/qortal-ui-crypto/api/transactions/PaymentTransaction.js b/qortal-ui-crypto/api/transactions/PaymentTransaction.js index 655ac285..bde396eb 100644 --- a/qortal-ui-crypto/api/transactions/PaymentTransaction.js +++ b/qortal-ui-crypto/api/transactions/PaymentTransaction.js @@ -1,80 +1,63 @@ -'use strict'; +'use strict' import TransactionBase from './TransactionBase.js' import Base58 from '../deps/Base58.js' import { store } from '../../api.js' export default class PaymentTransaction extends TransactionBase { - constructor() { - super() - this.type = 2 - this.tests.push( - () => { - if (!(this._amount >= 0)) { - return 'Invalid amount ' + this._amount / store.getState().config.coin.decimals - } - return true - }, - () => { - if (!(this._recipient instanceof Uint8Array && this._recipient.length == 25)) { - return 'Invalid recipient ' + Base58.encode(this._recipient) - } - return true - } - ) - } + constructor() { + super() + this.type = 2 + } - set recipient(recipient) { // Always Base58 encoded. Accepts Uint8Array or Base58 string. - this._recipient = recipient instanceof Uint8Array ? recipient : this.constructor.Base58.decode(recipient) - } + render(html) { + const conf = store.getState().config + return html` + + + + + + + + + ${this.recipientName ? html` + + + + + ` : ''} + + + + +
${this._dialogto}:
${this.dialogAddress} ${' '}-${Base58.encode(this._recipient)}
${this.dialogName} ${' '}-${this.recipientName}
${this._dialogamount}${this._amount / conf.coin.decimals} ${conf.coin.symbol}
+ ` + } - set dialogto(dialogto) { - this._dialogto = dialogto - } + set recipient(recipient) { + this._recipient = recipient instanceof Uint8Array ? recipient : this.constructor.Base58.decode(recipient) + } - set dialogamount(dialogamount) { - this._dialogamount = dialogamount - } - - set amount(amount) { - this._amount = Math.round(amount * store.getState().config.coin.decimals) - this._amountBytes = this.constructor.utils.int64ToBytes(this._amount) - } + set dialogto(dialogto) { + this._dialogto = dialogto + } - get params() { - const params = super.params - params.push( - this._recipient, - this._amountBytes, - this._feeBytes - ) - return params - } + set dialogamount(dialogamount) { + this._dialogamount = dialogamount + } - render(html) { - const conf = store.getState().config - return html` - - - - - - - - - - - ${this.recipientName ? html` - - - - - ` : ''} - - - - - -
${this._dialogto}:
${this.dialogAddress} ${' '}-${Base58.encode(this._recipient)}
${this.dialogName} ${' '}-${this.recipientName}
${this._dialogamount}${this._amount / conf.coin.decimals} ${conf.coin.symbol}
- ` - } + set amount(amount) { + this._amount = Math.round(amount * store.getState().config.coin.decimals) + this._amountBytes = this.constructor.utils.int64ToBytes(this._amount) + } + + get params() { + const params = super.params + params.push( + this._recipient, + this._amountBytes, + this._feeBytes + ) + return params + } } diff --git a/qortal-ui-crypto/api/transactions/PublicizeTransaction.js b/qortal-ui-crypto/api/transactions/PublicizeTransaction.js index d4982bcb..0243901c 100644 --- a/qortal-ui-crypto/api/transactions/PublicizeTransaction.js +++ b/qortal-ui-crypto/api/transactions/PublicizeTransaction.js @@ -1,23 +1,23 @@ -"use strict"; -import ChatBase from "./chat/ChatBase.js" +'use strict' +import ChatBase from './chat/ChatBase.js' export default class PublicizeTransaction extends ChatBase { - constructor() { - super(); - this.type = 19 - this.fee = 0 - } + constructor() { + super() + this.type = 19 + this.fee = 0 + } - set proofOfWorkNonce(proofOfWorkNonce) { - this._proofOfWorkNonce = this.constructor.utils.int32ToBytes(proofOfWorkNonce) - } + set proofOfWorkNonce(proofOfWorkNonce) { + this._proofOfWorkNonce = this.constructor.utils.int32ToBytes(proofOfWorkNonce) + } - get params() { - const params = super.params; - params.push( - this._proofOfWorkNonce, - this._feeBytes - ) - return params; - } + get params() { + const params = super.params + params.push( + this._proofOfWorkNonce, + this._feeBytes + ) + return params + } } diff --git a/qortal-ui-crypto/api/transactions/TransactionBase.js b/qortal-ui-crypto/api/transactions/TransactionBase.js index f61f1834..ae5f613e 100644 --- a/qortal-ui-crypto/api/transactions/TransactionBase.js +++ b/qortal-ui-crypto/api/transactions/TransactionBase.js @@ -1,166 +1,121 @@ -'use strict'; +'use strict' import { TX_TYPES, QORT_DECIMALS } from '../constants.js' import nacl from '../deps/nacl-fast.js' import Base58 from '../deps/Base58.js' import utils from '../deps/utils.js' export default class TransactionBase { - static get utils() { - return utils - } - static get nacl() { - return nacl - } - static get Base58() { - return Base58 - } + static get utils() { + return utils + } + static get nacl() { + return nacl + } + static get Base58() { + return Base58 + } - constructor() { - // Defaults - this.fee = 0 - this.groupID = 0 - this.timestamp = Date.now() - 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)) { - if (this._lastReference == 0) { - // No prior transactions exist - return 'Invalid last reference. Please ensure that you have at least 0.001 QORT for the transaction fee.' - } - 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 - } - ] - } + constructor() { + this.fee = 0 + this.groupID = 0 + this.timestamp = Date.now() + } - set keyPair(keyPair) { - this._keyPair = keyPair - } - set type(type) { - this.typeText = TX_TYPES[type] - this._type = type - this._typeBytes = this.constructor.utils.int32ToBytes(this._type) - } - set groupID(groupID) { - this._groupID = groupID - this._groupIDBytes = this.constructor.utils.int32ToBytes(this._groupID) - } - set timestamp(timestamp) { - this._timestamp = timestamp - this._timestampBytes = this.constructor.utils.int64ToBytes(this._timestamp) - } - set fee(fee) { - this._fee = fee * QORT_DECIMALS - this._feeBytes = this.constructor.utils.int64ToBytes(this._fee) - } - set lastReference(lastReference) { // Always Base58 encoded. Accepts Uint8Array or Base58 string. - // lastReference could be a string or an Uint8Array - this._lastReference = lastReference instanceof Uint8Array ? lastReference : this.constructor.Base58.decode(lastReference) - } - get params() { - return [ - this._typeBytes, - this._timestampBytes, - this._groupIDBytes, - this._lastReference, - this._keyPair.publicKey - ] - } - get signedBytes() { - if (!this._signedBytes) { - this.sign() - } - return this._signedBytes - } + render(html) { + return html`render method to display requested transaction info` + } - // render function but NOT lit element - render(html) { - return html`render method to display requested transaction info` - } + set keyPair(keyPair) { + this._keyPair = keyPair + } - validParams() { - let finalResult = { - valid: true - } - // const valid = - this.tests.some(test => { - const result = test() - if (result !== true) { - finalResult = { - valid: false, - message: result - } - return true // exists the loop - } - }) - return finalResult - } + set type(type) { + this.typeText = TX_TYPES[type] + this._type = type + this._typeBytes = this.constructor.utils.int32ToBytes(this._type) + } - generateBase() { - const isValid = this.validParams() - if (!isValid.valid) { - throw new Error(isValid.message) - } - let result = new Uint8Array() + set groupID(groupID) { + this._groupID = groupID + this._groupIDBytes = this.constructor.utils.int32ToBytes(this._groupID) + } - this.params.forEach(item => { - result = this.constructor.utils.appendBuffer(result, item) - }) + set timestamp(timestamp) { + this._timestamp = timestamp + this._timestampBytes = this.constructor.utils.int64ToBytes(this._timestamp) + } - this._base = result - return result - } + set fee(fee) { + this._fee = fee * QORT_DECIMALS + this._feeBytes = this.constructor.utils.int64ToBytes(this._fee) + } - sign() { - if (!this._keyPair) { - throw new Error('keyPair not defined') - } + set lastReference(lastReference) { + this._lastReference = lastReference instanceof Uint8Array ? lastReference : this.constructor.Base58.decode(lastReference) + } - if (!this._base) { - this.generateBase() - } + get params() { + return [ + this._typeBytes, + this._timestampBytes, + this._groupIDBytes, + this._lastReference, + this._keyPair.publicKey + ] + } - this._signature = this.constructor.nacl.sign.detached(this._base, this._keyPair.privateKey) + get signedBytes() { + if (!this._signedBytes) { + this.sign() + } + return this._signedBytes + } - this._signedBytes = this.constructor.utils.appendBuffer(this._base, this._signature) + validParams() { + let finalResult = { + valid: true + } + this.tests.some(test => { + const result = test() + if (result !== true) { + finalResult = { + valid: false, + message: result + } + return true // exists the loop + } + }) + return finalResult + } - return this._signature - } + generateBase() { + const isValid = this.validParams() + if (!isValid.valid) { + throw new Error(isValid.message) + } + let result = new Uint8Array() + + this.params.forEach(item => { + result = this.constructor.utils.appendBuffer(result, item) + }) + + this._base = result + return result + } + + sign() { + if (!this._keyPair) { + throw new Error('keyPair not defined') + } + + if (!this._base) { + this.generateBase() + } + + this._signature = this.constructor.nacl.sign.detached(this._base, this._keyPair.privateKey) + + this._signedBytes = this.constructor.utils.appendBuffer(this._base, this._signature) + + return this._signature + } } diff --git a/qortal-ui-crypto/api/transactions/TransferPrivsTransaction.js b/qortal-ui-crypto/api/transactions/TransferPrivsTransaction.js index f12d837f..858ac26a 100644 --- a/qortal-ui-crypto/api/transactions/TransferPrivsTransaction.js +++ b/qortal-ui-crypto/api/transactions/TransferPrivsTransaction.js @@ -1,42 +1,42 @@ -'use strict'; +'use strict' import TransactionBase from './TransactionBase.js' import Base58 from '../deps/Base58.js' import { store } from '../../api.js' import { QORT_DECIMALS } from '../constants.js' export default class TransferPrivsTransaction extends TransactionBase { - constructor() { - super() - this.type = 40 - } + constructor() { + super() + this.type = 40 + } - render(html) { - const conf = store.getState().config - return html` + render(html) { + const conf = store.getState().config + return html` Are you sure to transfer privileges to this account ?
${this.theRecipient}
On pressing confirm, the transfer privileges request will be sent! ` - } + } - set recipient(recipient) { - this._recipient = recipient instanceof Uint8Array ? recipient : this.constructor.Base58.decode(recipient) - this.theRecipient = recipient - } + set recipient(recipient) { + this._recipient = recipient instanceof Uint8Array ? recipient : this.constructor.Base58.decode(recipient) + this.theRecipient = recipient + } - set fee(fee) { - this._fee = fee * QORT_DECIMALS - this._feeBytes = this.constructor.utils.int64ToBytes(this._fee) - } + 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._recipient, - this._feeBytes - ) - return params - } -} \ No newline at end of file + get params() { + const params = super.params + params.push( + this._recipient, + this._feeBytes + ) + return params + } +} diff --git a/qortal-ui-crypto/api/transactions/arbitrary/signArbitrary.js b/qortal-ui-crypto/api/transactions/arbitrary/signArbitrary.js index 47f37f81..84ed0638 100644 --- a/qortal-ui-crypto/api/transactions/arbitrary/signArbitrary.js +++ b/qortal-ui-crypto/api/transactions/arbitrary/signArbitrary.js @@ -2,38 +2,37 @@ import nacl from '../../deps/nacl-fast.js' import utils from '../../deps/utils.js' import Base58 from '../../deps/Base58.js' - const signArbitrary = (arbitraryBytesBase58, arbitraryBytesForSigningBase58, nonce, keyPair) => { - if (!arbitraryBytesBase58) { - throw new Error('ArbitraryBytesBase58 not defined') - } + if (!arbitraryBytesBase58) { + throw new Error('ArbitraryBytesBase58 not defined') + } - if (!nonce) { - throw new Error('Nonce not defined') - } + if (!nonce) { + throw new Error('Nonce not defined') + } - if (!keyPair) { - throw new Error('keyPair not defined') - } + if (!keyPair) { + throw new Error('keyPair not defined') + } - const arbitraryBytes = Base58.decode(arbitraryBytesBase58) - const _arbitraryBytesBuffer = Object.keys(arbitraryBytes).map(function (key) { return arbitraryBytes[key]; }); - const arbitraryBytesBuffer = new Uint8Array(_arbitraryBytesBuffer) + 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 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) + const _nonce = utils.int32ToBytes(nonce) + arbitraryBytesBuffer.set(_nonce, 112) + arbitraryBytesForSigningBuffer.set(_nonce, 112) - const signature = nacl.sign.detached(arbitraryBytesForSigningBuffer, keyPair.privateKey) + const signature = nacl.sign.detached(arbitraryBytesForSigningBuffer, keyPair.privateKey) - const signedBytes = utils.appendBuffer(arbitraryBytesBuffer, signature) + const signedBytes = utils.appendBuffer(arbitraryBytesBuffer, signature) - return signedBytes + return signedBytes } export default signArbitrary diff --git a/qortal-ui-crypto/api/transactions/arbitraryV3.js b/qortal-ui-crypto/api/transactions/arbitraryV3.js index 5d62000a..2c2536af 100644 --- a/qortal-ui-crypto/api/transactions/arbitraryV3.js +++ b/qortal-ui-crypto/api/transactions/arbitraryV3.js @@ -1,42 +1,37 @@ -"use strict"; -/* -TO DO -*/ +'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) + // 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) - 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); - - return data; - } -}()) \ No newline at end of file + return data + } + }()) diff --git a/qortal-ui-crypto/api/transactions/chat/ChatBase.js b/qortal-ui-crypto/api/transactions/chat/ChatBase.js index 3a81d3f2..783176ed 100644 --- a/qortal-ui-crypto/api/transactions/chat/ChatBase.js +++ b/qortal-ui-crypto/api/transactions/chat/ChatBase.js @@ -1,137 +1,97 @@ -'use strict'; +'use strict' import { TX_TYPES, QORT_DECIMALS } from '../../constants.js' import nacl from '../../deps/nacl-fast.js' import Base58 from '../../deps/Base58.js' import utils from '../../deps/utils.js' export default class ChatBase { - static get utils() { - return utils - } - static get nacl() { - return nacl - } - static get Base58() { - return Base58 - } + static get utils() { + return utils + } + static get nacl() { + return nacl + } + static get Base58() { + return Base58 + } - 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 - } - ] - } + constructor() { + this.fee = 0 + this.groupID = 0 + } - set keyPair(keyPair) { - this._keyPair = keyPair - } - set type(type) { - this.typeText = TX_TYPES[type] - this._type = type - this._typeBytes = this.constructor.utils.int32ToBytes(this._type) - } - set groupID(groupID) { - this._groupID = groupID - this._groupIDBytes = this.constructor.utils.int32ToBytes(this._groupID) - } - set timestamp(timestamp) { - this._timestamp = timestamp - this._timestampBytes = this.constructor.utils.int64ToBytes(this._timestamp) - } - set fee(fee) { - this._fee = fee * QORT_DECIMALS - this._feeBytes = this.constructor.utils.int64ToBytes(this._fee) - } - set lastReference(lastReference) { - this._lastReference = lastReference instanceof Uint8Array ? lastReference : this.constructor.Base58.decode(lastReference) - } - get params() { + set keyPair(keyPair) { + this._keyPair = keyPair + } - return [ - this._typeBytes, - this._timestampBytes, - this._groupIDBytes, - this._lastReference, - this._keyPair.publicKey - ] - } + set type(type) { + this.typeText = TX_TYPES[type] + this._type = type + this._typeBytes = this.constructor.utils.int32ToBytes(this._type) + } - get chatBytes() { + set groupID(groupID) { + this._groupID = groupID + this._groupIDBytes = this.constructor.utils.int32ToBytes(this._groupID) + } - const isValid = this.validParams() - if (!isValid.valid) { - throw new Error(isValid.message) - } + set timestamp(timestamp) { + this._timestamp = timestamp + this._timestampBytes = this.constructor.utils.int64ToBytes(this._timestamp) + } - let result = new Uint8Array() + set fee(fee) { + this._fee = fee * QORT_DECIMALS + this._feeBytes = this.constructor.utils.int64ToBytes(this._fee) + } - this.params.forEach(item => { - result = this.constructor.utils.appendBuffer(result, item) - }) + set lastReference(lastReference) { + this._lastReference = lastReference instanceof Uint8Array ? lastReference : this.constructor.Base58.decode(lastReference) + } - this._chatBytes = result + get params() { + return [ + this._typeBytes, + this._timestampBytes, + this._groupIDBytes, + this._lastReference, + this._keyPair.publicKey + ] + } - return this._chatBytes - } + get chatBytes() { + const isValid = this.validParams() + if (!isValid.valid) { + throw new Error(isValid.message) + } - validParams() { - let finalResult = { - valid: true - } + let result = new Uint8Array() - this.tests.some(test => { - const result = test() - if (result !== true) { - finalResult = { - valid: false, - message: result - } - return true - } - }) - return finalResult - } + this.params.forEach(item => { + result = this.constructor.utils.appendBuffer(result, item) + }) + + this._chatBytes = result + + 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 + } } diff --git a/qortal-ui-crypto/api/transactions/chat/ChatTransaction.js b/qortal-ui-crypto/api/transactions/chat/ChatTransaction.js index 6e6dcfd4..642ff744 100644 --- a/qortal-ui-crypto/api/transactions/chat/ChatTransaction.js +++ b/qortal-ui-crypto/api/transactions/chat/ChatTransaction.js @@ -1,77 +1,92 @@ -"use strict"; +'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' export default class ChatTransaction extends ChatBase { - constructor() { - super(); - this.type = 18 - this.fee = 0 - } + constructor() { + super() + this.type = 18 + this.fee = 0 + } - set recipientPublicKey(recipientPublicKey) { - this._base58RecipientPublicKey = recipientPublicKey instanceof Uint8Array ? this.constructor.Base58.encode(recipientPublicKey) : recipientPublicKey - this._recipientPublicKey = this.constructor.Base58.decode(this._base58RecipientPublicKey) + set recipientPublicKey(recipientPublicKey) { + this._base58RecipientPublicKey = recipientPublicKey instanceof Uint8Array ? this.constructor.Base58.encode(recipientPublicKey) : recipientPublicKey + this._recipientPublicKey = this.constructor.Base58.decode(this._base58RecipientPublicKey) + } - } + set proofOfWorkNonce(proofOfWorkNonce) { + this._proofOfWorkNonce = this.constructor.utils.int32ToBytes(proofOfWorkNonce) + } - set proofOfWorkNonce(proofOfWorkNonce) { - this._proofOfWorkNonce = this.constructor.utils.int32ToBytes(proofOfWorkNonce) - } + set recipient(recipient) { + this._recipient = recipient instanceof Uint8Array ? recipient : this.constructor.Base58.decode(recipient) + this._hasReceipient = new Uint8Array(1) + this._hasReceipient[0] = 1 + } + set hasChatReference(hasChatReference) { + this._hasChatReference = new Uint8Array(1) + this._hasChatReference[0] = hasChatReference + } - set recipient(recipient) { - this._recipient = recipient instanceof Uint8Array ? recipient : this.constructor.Base58.decode(recipient) - this._hasReceipient = new Uint8Array(1) - this._hasReceipient[0] = 1 - } + set chatReference(chatReference) { + this._chatReference = chatReference instanceof Uint8Array ? chatReference : this.constructor.Base58.decode(chatReference) + } - set message(message) { + set message(message) { + this.messageText = message; + this._message = this.constructor.utils.stringtoUTF8Array(message) + this._messageLength = this.constructor.utils.int32ToBytes(this._message.length) + } - this.messageText = message; + set isEncrypted(isEncrypted) { + this._isEncrypted = new Uint8Array(1) + this._isEncrypted[0] = isEncrypted - this._message = this.constructor.utils.stringtoUTF8Array(message) - this._messageLength = this.constructor.utils.int32ToBytes(this._message.length) - } + if (isEncrypted === 1) { + 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) - set isEncrypted(isEncrypted) { - this._isEncrypted = new Uint8Array(1); - this._isEncrypted[0] = isEncrypted; + this._chatEncryptionSeed = new Sha256().process(sharedSecret).finish().result + this._encryptedMessage = nacl.secretbox(this._message, this._lastReference.slice(0, 24), this._chatEncryptionSeed) + } - if (isEncrypted === 1) { - 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); + this._myMessage = isEncrypted === 1 ? this._encryptedMessage : this._message + this._myMessageLenth = isEncrypted === 1 ? this.constructor.utils.int32ToBytes(this._myMessage.length) : this._messageLength + } - this._chatEncryptionSeed = new Sha256().process(sharedSecret).finish().result - this._encryptedMessage = nacl.secretbox(this._message, this._lastReference.slice(0, 24), this._chatEncryptionSeed) - } + set isText(isText) { + this._isText = new Uint8Array(1) + this._isText[0] = isText + } - this._myMessage = isEncrypted === 1 ? this._encryptedMessage : this._message - this._myMessageLenth = isEncrypted === 1 ? this.constructor.utils.int32ToBytes(this._myMessage.length) : this._messageLength - } + get params() { + const params = super.params; + params.push( + this._proofOfWorkNonce, + this._hasReceipient, + this._recipient, + this._myMessageLenth, + this._myMessage, + this._isEncrypted, + this._isText, + this._feeBytes + ) - set isText(isText) { - this._isText = new Uint8Array(1); - this._isText[0] = isText; - } + // After the feature trigger timestamp we need to include chat reference + if (new Date(this._timestamp).getTime() >= CHAT_REFERENCE_FEATURE_TRIGGER_TIMESTAMP) { + params.push(this._hasChatReference) - get params() { - const params = super.params; - params.push( - this._proofOfWorkNonce, - this._hasReceipient, - this._recipient, - this._myMessageLenth, - this._myMessage, - this._isEncrypted, - this._isText, - this._feeBytes - ) - return params; - } + if (this._hasChatReference[0] == 1) { + params.push(this._chatReference) + } + } + return params + } } diff --git a/qortal-ui-crypto/api/transactions/chat/GroupChatTransaction.js b/qortal-ui-crypto/api/transactions/chat/GroupChatTransaction.js index efbd97b0..e414d10b 100644 --- a/qortal-ui-crypto/api/transactions/chat/GroupChatTransaction.js +++ b/qortal-ui-crypto/api/transactions/chat/GroupChatTransaction.js @@ -1,52 +1,67 @@ -"use strict"; +'use strict' import ChatBase from "./ChatBase.js" export default class GroupChatTransaction extends ChatBase { - constructor() { - super(); - this.type = 18 - this.fee = 0 - } + constructor() { + super(); + this.type = 18 + this.fee = 0 + } - set proofOfWorkNonce(proofOfWorkNonce) { - this._proofOfWorkNonce = this.constructor.utils.int32ToBytes(proofOfWorkNonce) - } + set proofOfWorkNonce(proofOfWorkNonce) { + this._proofOfWorkNonce = this.constructor.utils.int32ToBytes(proofOfWorkNonce) + } + set hasReceipient(hasReceipient) { + this._hasReceipient = new Uint8Array(1) + this._hasReceipient[0] = hasReceipient + } - set hasReceipient(hasReceipient) { - this._hasReceipient = new Uint8Array(1) - this._hasReceipient[0] = hasReceipient - } + set message(message) { + this.messageText = message + this._message = this.constructor.utils.stringtoUTF8Array(message) + this._messageLength = this.constructor.utils.int32ToBytes(this._message.length) + } - set message(message) { + set hasChatReference(hasChatReference) { + this._hasChatReference = new Uint8Array(1) + this._hasChatReference[0] = hasChatReference + } - this.messageText = message; + set chatReference(chatReference) { + this._chatReference = chatReference instanceof Uint8Array ? chatReference : this.constructor.Base58.decode(chatReference) + } - this._message = this.constructor.utils.stringtoUTF8Array(message) - this._messageLength = this.constructor.utils.int32ToBytes(this._message.length) - } + set isEncrypted(isEncrypted) { + this._isEncrypted = new Uint8Array(1); + this._isEncrypted[0] = isEncrypted + } - set isEncrypted(isEncrypted) { - this._isEncrypted = new Uint8Array(1); - this._isEncrypted[0] = isEncrypted; // Set to false... - } + set isText(isText) { + this._isText = new Uint8Array(1) + this._isText[0] = isText + } - set isText(isText) { - this._isText = new Uint8Array(1); - this._isText[0] = isText; // Set to true - } + get params() { + const params = super.params; + params.push( + this._proofOfWorkNonce, + this._hasReceipient, + this._messageLength, + this._message, + this._isEncrypted, + this._isText, + this._feeBytes + ) - get params() { - const params = super.params; - params.push( - this._proofOfWorkNonce, - this._hasReceipient, - this._messageLength, - this._message, - this._isEncrypted, - this._isText, - this._feeBytes - ) - return params; - } + // After the feature trigger timestamp we need to include chat reference + if (new Date(this._timestamp).getTime() >= CHAT_REFERENCE_FEATURE_TRIGGER_TIMESTAMP) { + params.push(this._hasChatReference) + + if (this._hasChatReference[0] == 1) { + params.push(this._chatReference) + } + } + return params + } } diff --git a/qortal-ui-crypto/api/transactions/chat/decryptChatMessage.js b/qortal-ui-crypto/api/transactions/chat/decryptChatMessage.js index 5ea06ec8..038db155 100644 --- a/qortal-ui-crypto/api/transactions/chat/decryptChatMessage.js +++ b/qortal-ui-crypto/api/transactions/chat/decryptChatMessage.js @@ -3,25 +3,24 @@ import Base58 from '../../deps/Base58.js' import ed2curve from '../../deps/ed2curve.js' import { Sha256 } from 'asmcrypto.js' - export const decryptChatMessage = (encryptedMessage, privateKey, recipientPublicKey, lastReference) => { - let _encryptedMessage = Base58.decode(encryptedMessage) + let _encryptedMessage = Base58.decode(encryptedMessage) - const _base58RecipientPublicKey = recipientPublicKey instanceof Uint8Array ? Base58.encode(recipientPublicKey) : recipientPublicKey - const _recipientPublicKey = Base58.decode(_base58RecipientPublicKey) + const _base58RecipientPublicKey = recipientPublicKey instanceof Uint8Array ? Base58.encode(recipientPublicKey) : recipientPublicKey + const _recipientPublicKey = Base58.decode(_base58RecipientPublicKey) - const _lastReference = lastReference instanceof Uint8Array ? lastReference : Base58.decode(lastReference) + const _lastReference = lastReference instanceof Uint8Array ? lastReference : Base58.decode(lastReference) - const convertedPrivateKey = ed2curve.convertSecretKey(privateKey) - const convertedPublicKey = ed2curve.convertPublicKey(_recipientPublicKey) - const sharedSecret = new Uint8Array(32); - nacl.lowlevel.crypto_scalarmult(sharedSecret, convertedPrivateKey, convertedPublicKey); + const convertedPrivateKey = ed2curve.convertSecretKey(privateKey) + const convertedPublicKey = ed2curve.convertPublicKey(_recipientPublicKey) + 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(_encryptedMessage, _lastReference.slice(0, 24), _chatEncryptionSeed) + const _chatEncryptionSeed = new Sha256().process(sharedSecret).finish().result + const _decryptedMessage = nacl.secretbox.open(_encryptedMessage, _lastReference.slice(0, 24), _chatEncryptionSeed) - let decryptedMessage = '' + let decryptedMessage = '' - _decryptedMessage === false ? decryptedMessage : decryptedMessage = new TextDecoder('utf-8').decode(_decryptedMessage); - return decryptedMessage + _decryptedMessage === false ? decryptedMessage : decryptedMessage = new TextDecoder('utf-8').decode(_decryptedMessage) + return decryptedMessage } diff --git a/qortal-ui-crypto/api/transactions/chat/signChat.js b/qortal-ui-crypto/api/transactions/chat/signChat.js index 2c8428da..6760dac5 100644 --- a/qortal-ui-crypto/api/transactions/chat/signChat.js +++ b/qortal-ui-crypto/api/transactions/chat/signChat.js @@ -1,46 +1,43 @@ import nacl from '../../deps/nacl-fast.js' import utils from '../../deps/utils.js' - const signChat = (chatBytes, nonce, keyPair) => { - if (!chatBytes) { - throw new Error('Chat Bytes not defined') - } + if (!chatBytes) { + throw new Error('Chat Bytes not defined') + } - if (!nonce) { - throw new Error('Nonce not defined') - } + if (!nonce) { + throw new Error('Nonce not defined') + } - if (!keyPair) { - throw new Error('keyPair not defined') - } + if (!keyPair) { + throw new Error('keyPair not defined') + } - const _nonce = utils.int32ToBytes(nonce) + const _nonce = utils.int32ToBytes(nonce) - if (chatBytes.length === undefined) { - const _chatBytesBuffer = Object.keys(chatBytes).map(function (key) { return chatBytes[key]; }); + if (chatBytes.length === undefined) { + const _chatBytesBuffer = Object.keys(chatBytes).map(function (key) { return chatBytes[key]; }) - const chatBytesBuffer = new Uint8Array(_chatBytesBuffer) - chatBytesBuffer.set(_nonce, 112) + const chatBytesBuffer = new Uint8Array(_chatBytesBuffer) + chatBytesBuffer.set(_nonce, 112) + const signature = nacl.sign.detached(chatBytesBuffer, keyPair.privateKey) - const signature = nacl.sign.detached(chatBytesBuffer, keyPair.privateKey) + const signedBytes = utils.appendBuffer(chatBytesBuffer, signature) - const signedBytes = utils.appendBuffer(chatBytesBuffer, signature) + return signedBytes + } else { + const chatBytesBuffer = new Uint8Array(chatBytes) + chatBytesBuffer.set(_nonce, 112) - return signedBytes - } else { - const chatBytesBuffer = new Uint8Array(chatBytes) - chatBytesBuffer.set(_nonce, 112) + const signature = nacl.sign.detached(chatBytesBuffer, keyPair.privateKey) + const signedBytes = utils.appendBuffer(chatBytesBuffer, signature) - const signature = nacl.sign.detached(chatBytesBuffer, keyPair.privateKey) - - const signedBytes = utils.appendBuffer(chatBytesBuffer, signature) - - return signedBytes - } + return signedBytes + } } export default signChat diff --git a/qortal-ui-crypto/api/transactions/groups/AddGroupAdminTransaction.js b/qortal-ui-crypto/api/transactions/groups/AddGroupAdminTransaction.js index b4d6c120..4f5bf090 100644 --- a/qortal-ui-crypto/api/transactions/groups/AddGroupAdminTransaction.js +++ b/qortal-ui-crypto/api/transactions/groups/AddGroupAdminTransaction.js @@ -1,53 +1,53 @@ -'use strict'; -import TransactionBase from "../TransactionBase.js" -import { QORT_DECIMALS } from "../../constants.js" +'use strict' +import TransactionBase from '../TransactionBase.js' +import { QORT_DECIMALS } from '../../constants.js' export default class AddGroupAdminTransaction extends TransactionBase { - constructor() { - super() - this.type = 24 - } + constructor() { + super() + this.type = 24 + } - render(html) { - return html` - ${this._addAdminDialog1} -
- ${this.theRecipient} -
- ${this._addAdminDialog2} - ` - } + render(html) { + return html` + ${this._addAdminDialog1} +
+ ${this.theRecipient} +
+ ${this._addAdminDialog2} + ` + } - set addAdminDialog1(addAdminDialog1) { - this._addAdminDialog1 = addAdminDialog1 - } + set addAdminDialog1(addAdminDialog1) { + this._addAdminDialog1 = addAdminDialog1 + } - set addAdminDialog2(addAdminDialog2) { - this._addAdminDialog2 = addAdminDialog2 - } + set addAdminDialog2(addAdminDialog2) { + this._addAdminDialog2 = addAdminDialog2 + } - set rGroupId(rGroupId) { - this._rGroupId = rGroupId; - this._rGroupIdBytes = this.constructor.utils.int32ToBytes(this._rGroupId) - } + set rGroupId(rGroupId) { + this._rGroupId = rGroupId + this._rGroupIdBytes = this.constructor.utils.int32ToBytes(this._rGroupId) + } - set recipient(recipient) { - this._recipient = recipient instanceof Uint8Array ? recipient : this.constructor.Base58.decode(recipient) - this.theRecipient = recipient - } + set recipient(recipient) { + this._recipient = recipient instanceof Uint8Array ? recipient : this.constructor.Base58.decode(recipient) + this.theRecipient = recipient + } - set fee(fee) { - this._fee = fee * QORT_DECIMALS - this._feeBytes = this.constructor.utils.int64ToBytes(this._fee) - } + 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._rGroupIdBytes, - this._recipient, - this._feeBytes - ) - return params - } -} \ No newline at end of file + get params() { + const params = super.params + params.push( + this._rGroupIdBytes, + this._recipient, + this._feeBytes + ) + return params + } +} diff --git a/qortal-ui-crypto/api/transactions/groups/CancelGroupBanTransaction.js b/qortal-ui-crypto/api/transactions/groups/CancelGroupBanTransaction.js index 3e36be23..61de1e34 100644 --- a/qortal-ui-crypto/api/transactions/groups/CancelGroupBanTransaction.js +++ b/qortal-ui-crypto/api/transactions/groups/CancelGroupBanTransaction.js @@ -1,53 +1,53 @@ -'use strict'; -import TransactionBase from "../TransactionBase.js" -import { QORT_DECIMALS } from "../../constants.js" +'use strict' +import TransactionBase from '../TransactionBase.js' +import { QORT_DECIMALS } from '../../constants.js' export default class CancelGroupBanTransaction extends TransactionBase { - constructor() { - super() - this.type = 27 - } + constructor() { + super() + this.type = 27 + } - render(html) { - return html` - ${this._cancelBanMemberDialog1} -
- ${this.theRecipient} -
- ${this._cancelBanMemberDialog2} - ` - } + render(html) { + return html` + ${this._cancelBanMemberDialog1} +
+ ${this.theRecipient} +
+ ${this._cancelBanMemberDialog2} + ` + } - set cancelBanMemberDialog1(cancelBanMemberDialog1) { - this._cancelBanMemberDialog1= cancelBanMemberDialog1 - } + set cancelBanMemberDialog1(cancelBanMemberDialog1) { + this._cancelBanMemberDialog1 = cancelBanMemberDialog1 + } - set cancelBanMemberDialog2(cancelBanMemberDialog2) { - this._cancelBanMemberDialog2 = cancelBanMemberDialog2 - } + set cancelBanMemberDialog2(cancelBanMemberDialog2) { + this._cancelBanMemberDialog2 = cancelBanMemberDialog2 + } - set rGroupId(rGroupId) { - this._rGroupId = rGroupId - this._rGroupIdBytes = this.constructor.utils.int32ToBytes(this._rGroupId) - } + set rGroupId(rGroupId) { + this._rGroupId = rGroupId + this._rGroupIdBytes = this.constructor.utils.int32ToBytes(this._rGroupId) + } - set recipient(recipient) { - this._recipient = recipient instanceof Uint8Array ? recipient : this.constructor.Base58.decode(recipient) - this.theRecipient = recipient - } + set recipient(recipient) { + this._recipient = recipient instanceof Uint8Array ? recipient : this.constructor.Base58.decode(recipient) + this.theRecipient = recipient + } - set fee(fee) { - this._fee = fee * QORT_DECIMALS - this._feeBytes = this.constructor.utils.int64ToBytes(this._fee) - } + 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._rGroupIdBytes, - this._recipient, - this._feeBytes - ) - return params - } -} \ No newline at end of file + get params() { + const params = super.params + params.push( + this._rGroupIdBytes, + this._recipient, + this._feeBytes + ) + return params + } +} diff --git a/qortal-ui-crypto/api/transactions/groups/CancelGroupInviteTransaction.js b/qortal-ui-crypto/api/transactions/groups/CancelGroupInviteTransaction.js index 79d24656..10bb800b 100644 --- a/qortal-ui-crypto/api/transactions/groups/CancelGroupInviteTransaction.js +++ b/qortal-ui-crypto/api/transactions/groups/CancelGroupInviteTransaction.js @@ -1,60 +1,60 @@ -'use strict'; -import TransactionBase from "../TransactionBase.js" -import { QORT_DECIMALS } from "../../constants.js" +'use strict' +import TransactionBase from '../TransactionBase.js' +import { QORT_DECIMALS } from '../../constants.js' export default class CancelGroupInviteTransaction extends TransactionBase { - constructor() { - super() - this.type = 30 - } + constructor() { + super() + this.type = 30 + } - render(html) { - return html` - ${this._cancelInviteDialog1} -
- ${this._memberName} -
-
- ${this.theRecipient} -
- ${this._cancelInviteDialog2} - ` - } + render(html) { + return html` + ${this._cancelInviteDialog1} +
+ ${this._memberName} +
+
+ ${this.theRecipient} +
+ ${this._cancelInviteDialog2} + ` + } - set memberName(memberName) { - this._memberName = memberName - } + set memberName(memberName) { + this._memberName = memberName + } - set cancelInviteDialog1(cancelInviteDialog1) { - this._cancelInviteDialog1 = cancelInviteDialog1 - } + set cancelInviteDialog1(cancelInviteDialog1) { + this._cancelInviteDialog1 = cancelInviteDialog1 + } - set cancelInviteDialog2(cancelInviteDialog2) { - this._cancelInviteDialog2 = cancelInviteDialog2 - } + set cancelInviteDialog2(cancelInviteDialog2) { + this._cancelInviteDialog2 = cancelInviteDialog2 + } - set rGroupId(rGroupId) { - this._rGroupId = rGroupId; - this._rGroupIdBytes = this.constructor.utils.int32ToBytes(this._rGroupId) - } + set rGroupId(rGroupId) { + this._rGroupId = rGroupId + this._rGroupIdBytes = this.constructor.utils.int32ToBytes(this._rGroupId) + } - set recipient(recipient) { - this._recipient = recipient instanceof Uint8Array ? recipient : this.constructor.Base58.decode(recipient) - this.theRecipient = recipient - } + set recipient(recipient) { + this._recipient = recipient instanceof Uint8Array ? recipient : this.constructor.Base58.decode(recipient) + this.theRecipient = recipient + } - set fee(fee) { - this._fee = fee * QORT_DECIMALS - this._feeBytes = this.constructor.utils.int64ToBytes(this._fee) - } + 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._rGroupIdBytes, - this._recipient, - this._feeBytes - ) - return params - } -} \ No newline at end of file + get params() { + const params = super.params + params.push( + this._rGroupIdBytes, + this._recipient, + this._feeBytes + ) + return params + } +} diff --git a/qortal-ui-crypto/api/transactions/groups/CreateGroupTransaction.js b/qortal-ui-crypto/api/transactions/groups/CreateGroupTransaction.js index 909b46bd..0b76ead0 100644 --- a/qortal-ui-crypto/api/transactions/groups/CreateGroupTransaction.js +++ b/qortal-ui-crypto/api/transactions/groups/CreateGroupTransaction.js @@ -1,98 +1,98 @@ -"use strict"; -import TransactionBase from "../TransactionBase.js" -import { QORT_DECIMALS } from "../../constants.js" +'use strict' +import TransactionBase from '../TransactionBase.js' +import { QORT_DECIMALS } from '../../constants.js' export default class CreateGroupTransaction extends TransactionBase { - constructor() { - super() - this.type = 22 - } + constructor() { + super() + this.type = 22 + } - render(html) { - return html` - ${this._groupdialog5} -
-
${this._groupdialog7}: ${this._rGroupName}
-
-
${this._groupdialog8}: ${this._rGroupDesc}
-
-
${this._groupdialog9}: ${this.myGroupType === 1 ? "Public" : "Private"}
-
- ${this._groupdialog6} - ` - } + render(html) { + return html` + ${this._groupdialog5} +
+
${this._groupdialog7}: ${this._rGroupName}
+
+
${this._groupdialog8}: ${this._rGroupDesc}
+
+
${this._groupdialog9}: ${this.myGroupType === 1 ? "Public" : "Private"}
+
+ ${this._groupdialog6} + ` + } - set groupdialog5(groupdialog5) { - this._groupdialog5 = groupdialog5 - } + set groupdialog5(groupdialog5) { + this._groupdialog5 = groupdialog5 + } - set groupdialog6(groupdialog6) { - this._groupdialog6 = groupdialog6 - } + set groupdialog6(groupdialog6) { + this._groupdialog6 = groupdialog6 + } - set groupdialog7(groupdialog7) { - this._groupdialog7 = groupdialog7 - } + set groupdialog7(groupdialog7) { + this._groupdialog7 = groupdialog7 + } - set groupdialog8(groupdialog8) { - this._groupdialog8 = groupdialog8 - } + set groupdialog8(groupdialog8) { + this._groupdialog8 = groupdialog8 + } - set groupdialog9(groupdialog9) { - this._groupdialog9 = groupdialog9 - } + set groupdialog9(groupdialog9) { + this._groupdialog9 = groupdialog9 + } - set fee(fee) { - this._fee = fee * QORT_DECIMALS - this._feeBytes = this.constructor.utils.int64ToBytes(this._fee) - } + set fee(fee) { + this._fee = fee * QORT_DECIMALS + this._feeBytes = this.constructor.utils.int64ToBytes(this._fee) + } - set rGroupName(rGroupName) { - this._rGroupName = rGroupName; - this._rGroupNameBytes = this.constructor.utils.stringtoUTF8Array(this._rGroupName.toLocaleLowerCase()) - this._rGroupNameLength = this.constructor.utils.int32ToBytes(this._rGroupNameBytes.length) - } + set rGroupName(rGroupName) { + this._rGroupName = rGroupName + this._rGroupNameBytes = this.constructor.utils.stringtoUTF8Array(this._rGroupName.toLocaleLowerCase()) + 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._rGroupDescLength = this.constructor.utils.int32ToBytes(this._rGroupDescBytes.length) - } + set rGroupDesc(rGroupDesc) { + this._rGroupDesc = rGroupDesc + this._rGroupDescBytes = this.constructor.utils.stringtoUTF8Array(this._rGroupDesc.toLocaleLowerCase()) + this._rGroupDescLength = this.constructor.utils.int32ToBytes(this._rGroupDescBytes.length) + } - set rGroupType(rGroupType) { - this.myGroupType = rGroupType; - this._rGroupType = new Uint8Array(1) - this._rGroupType[0] = rGroupType; - } + set rGroupType(rGroupType) { + this.myGroupType = rGroupType + this._rGroupType = new Uint8Array(1) + this._rGroupType[0] = rGroupType + } - set rGroupApprovalThreshold(rGroupApprovalThreshold) { - this._rGroupApprovalThreshold = new Uint8Array(1) - this._rGroupApprovalThreshold[0] = rGroupApprovalThreshold; - } + set rGroupApprovalThreshold(rGroupApprovalThreshold) { + this._rGroupApprovalThreshold = new Uint8Array(1) + this._rGroupApprovalThreshold[0] = rGroupApprovalThreshold + } - set rGroupMinimumBlockDelay(rGroupMinimumBlockDelay) { - this._rGroupMinimumBlockDelay = rGroupMinimumBlockDelay; - this._rGroupMinimumBlockDelayBytes = this.constructor.utils.int32ToBytes(this._rGroupMinimumBlockDelay) - } + set rGroupMinimumBlockDelay(rGroupMinimumBlockDelay) { + this._rGroupMinimumBlockDelay = rGroupMinimumBlockDelay + this._rGroupMinimumBlockDelayBytes = this.constructor.utils.int32ToBytes(this._rGroupMinimumBlockDelay) + } - set rGroupMaximumBlockDelay(rGroupMaximumBlockDelay) { - this._rGroupMaximumBlockDelay = rGroupMaximumBlockDelay; - this._rGroupMaximumBlockDelayBytes = this.constructor.utils.int32ToBytes(this._rGroupMaximumBlockDelay) - } + set rGroupMaximumBlockDelay(rGroupMaximumBlockDelay) { + this._rGroupMaximumBlockDelay = rGroupMaximumBlockDelay + this._rGroupMaximumBlockDelayBytes = this.constructor.utils.int32ToBytes(this._rGroupMaximumBlockDelay) + } - get params() { - const params = super.params; - params.push( - this._rGroupNameLength, - this._rGroupNameBytes, - this._rGroupDescLength, - this._rGroupDescBytes, - this._rGroupType, - this._rGroupApprovalThreshold, - this._rGroupMinimumBlockDelayBytes, - this._rGroupMaximumBlockDelayBytes, - this._feeBytes - ) - return params; - } -} \ No newline at end of file + get params() { + const params = super.params + params.push( + this._rGroupNameLength, + this._rGroupNameBytes, + this._rGroupDescLength, + this._rGroupDescBytes, + this._rGroupType, + this._rGroupApprovalThreshold, + this._rGroupMinimumBlockDelayBytes, + this._rGroupMaximumBlockDelayBytes, + this._feeBytes + ) + return params + } +} diff --git a/qortal-ui-crypto/api/transactions/groups/GroupBanTransaction.js b/qortal-ui-crypto/api/transactions/groups/GroupBanTransaction.js index 2d6e2d9c..101cb364 100644 --- a/qortal-ui-crypto/api/transactions/groups/GroupBanTransaction.js +++ b/qortal-ui-crypto/api/transactions/groups/GroupBanTransaction.js @@ -1,67 +1,67 @@ -'use strict'; -import TransactionBase from "../TransactionBase.js" -import { QORT_DECIMALS } from "../../constants.js" +'use strict' +import TransactionBase from '../TransactionBase.js' +import { QORT_DECIMALS } from '../../constants.js' export default class GroupBanTransaction extends TransactionBase { - constructor() { - super() - this.type = 26 - } + constructor() { + super() + this.type = 26 + } - render(html) { - return html` - ${this._banMemberDialog1} -
- ${this.theRecipient} -
- ${this._banMemberDialog2} - ` - } + render(html) { + return html` + ${this._banMemberDialog1} +
+ ${this.theRecipient} +
+ ${this._banMemberDialog2} + ` + } - set banMemberDialog1(banMemberDialog1) { - this._banMemberDialog1= banMemberDialog1 - } + set banMemberDialog1(banMemberDialog1) { + this._banMemberDialog1 = banMemberDialog1 + } - set banMemberDialog2(banMemberDialog2) { - this._banMemberDialog2 = banMemberDialog2 - } + set banMemberDialog2(banMemberDialog2) { + this._banMemberDialog2 = banMemberDialog2 + } - set rGroupId(rGroupId) { - this._rGroupId = rGroupId; - this._rGroupIdBytes = this.constructor.utils.int32ToBytes(this._rGroupId) - } + set rGroupId(rGroupId) { + this._rGroupId = rGroupId + this._rGroupIdBytes = this.constructor.utils.int32ToBytes(this._rGroupId) + } - set rBanReason(rBanReason) { - this._rBanReason = rBanReason - this._rBanReasonBytes = this.constructor.utils.stringtoUTF8Array(this._rBanReason.toLocaleLowerCase()) - this._rBanReasonLength = this.constructor.utils.int32ToBytes(this._rBanReasonBytes.length) - } + set rBanReason(rBanReason) { + this._rBanReason = rBanReason + this._rBanReasonBytes = this.constructor.utils.stringtoUTF8Array(this._rBanReason.toLocaleLowerCase()) + this._rBanReasonLength = this.constructor.utils.int32ToBytes(this._rBanReasonBytes.length) + } - set rBanTime(rBanTime) { - this._rBanTime = rBanTime - this._rBanTimeBytes = this.constructor.utils.int32ToBytes(this._rBanTime) - } + set rBanTime(rBanTime) { + this._rBanTime = rBanTime + this._rBanTimeBytes = this.constructor.utils.int32ToBytes(this._rBanTime) + } - set recipient(recipient) { - this._recipient = recipient instanceof Uint8Array ? recipient : this.constructor.Base58.decode(recipient) - this.theRecipient = recipient - } + set recipient(recipient) { + this._recipient = recipient instanceof Uint8Array ? recipient : this.constructor.Base58.decode(recipient) + this.theRecipient = recipient + } - set fee(fee) { - this._fee = fee * QORT_DECIMALS - this._feeBytes = this.constructor.utils.int64ToBytes(this._fee) - } + 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._rGroupIdBytes, - this._recipient, - this._rBanReasonLength, - this._rBanReasonBytes, - this._rBanTimeBytes, - this._feeBytes - ) - return params - } -} \ No newline at end of file + get params() { + const params = super.params + params.push( + this._rGroupIdBytes, + this._recipient, + this._rBanReasonLength, + this._rBanReasonBytes, + this._rBanTimeBytes, + this._feeBytes + ) + return params + } +} diff --git a/qortal-ui-crypto/api/transactions/groups/GroupInviteTransaction.js b/qortal-ui-crypto/api/transactions/groups/GroupInviteTransaction.js index 123ab820..62a89633 100644 --- a/qortal-ui-crypto/api/transactions/groups/GroupInviteTransaction.js +++ b/qortal-ui-crypto/api/transactions/groups/GroupInviteTransaction.js @@ -1,59 +1,59 @@ -'use strict'; -import TransactionBase from "../TransactionBase.js" -import { QORT_DECIMALS } from "../../constants.js" +'use strict' +import TransactionBase from '../TransactionBase.js' +import { QORT_DECIMALS } from '../../constants.js' export default class GroupInviteTransaction extends TransactionBase { - constructor() { - super() - this.type = 29 - } + constructor() { + super() + this.type = 29 + } - render(html) { - return html` - ${this._inviteMemberDialog1} -
- ${this.theRecipient} -
- ${this._inviteMemberDialog2} - ` - } + render(html) { + return html` + ${this._inviteMemberDialog1} +
+ ${this.theRecipient} +
+ ${this._inviteMemberDialog2} + ` + } - set inviteMemberDialog1(inviteMemberDialog1) { - this._inviteMemberDialog1= inviteMemberDialog1 - } + set inviteMemberDialog1(inviteMemberDialog1) { + this._inviteMemberDialog1 = inviteMemberDialog1 + } - set inviteMemberDialog2(inviteMemberDialog2) { - this._inviteMemberDialog2 = inviteMemberDialog2 - } + set inviteMemberDialog2(inviteMemberDialog2) { + this._inviteMemberDialog2 = inviteMemberDialog2 + } - set rGroupId(rGroupId) { - this._rGroupId = rGroupId; - this._rGroupIdBytes = this.constructor.utils.int32ToBytes(this._rGroupId) - } + set rGroupId(rGroupId) { + this._rGroupId = rGroupId + this._rGroupIdBytes = this.constructor.utils.int32ToBytes(this._rGroupId) + } - set rInviteTime(rInviteTime) { - this._rInviteTime = rInviteTime - this._rInviteTimeBytes = this.constructor.utils.int32ToBytes(this._rInviteTime) - } + set rInviteTime(rInviteTime) { + this._rInviteTime = rInviteTime + this._rInviteTimeBytes = this.constructor.utils.int32ToBytes(this._rInviteTime) + } - set recipient(recipient) { - this._recipient = recipient instanceof Uint8Array ? recipient : this.constructor.Base58.decode(recipient) - this.theRecipient = recipient - } + set recipient(recipient) { + this._recipient = recipient instanceof Uint8Array ? recipient : this.constructor.Base58.decode(recipient) + this.theRecipient = recipient + } - set fee(fee) { - this._fee = fee * QORT_DECIMALS - this._feeBytes = this.constructor.utils.int64ToBytes(this._fee) - } + 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._rGroupIdBytes, - this._recipient, - this._rInviteTimeBytes, - this._feeBytes - ) - return params - } -} \ No newline at end of file + get params() { + const params = super.params + params.push( + this._rGroupIdBytes, + this._recipient, + this._rInviteTimeBytes, + this._feeBytes + ) + return params + } +} diff --git a/qortal-ui-crypto/api/transactions/groups/GroupKickTransaction.js b/qortal-ui-crypto/api/transactions/groups/GroupKickTransaction.js index 12e6d276..4a2af2c2 100644 --- a/qortal-ui-crypto/api/transactions/groups/GroupKickTransaction.js +++ b/qortal-ui-crypto/api/transactions/groups/GroupKickTransaction.js @@ -1,61 +1,61 @@ -'use strict'; -import TransactionBase from "../TransactionBase.js" -import { QORT_DECIMALS } from "../../constants.js" +'use strict' +import TransactionBase from '../TransactionBase.js' +import { QORT_DECIMALS } from '../../constants.js' export default class GroupKickTransaction extends TransactionBase { - constructor() { - super() - this.type = 28 - } + constructor() { + super() + this.type = 28 + } - render(html) { - return html` - ${this._kickMemberDialog1} -
- ${this.theRecipient} -
- ${this._kickMemberDialog2} - ` - } + render(html) { + return html` + ${this._kickMemberDialog1} +
+ ${this.theRecipient} +
+ ${this._kickMemberDialog2} + ` + } - set kickMemberDialog1(kickMemberDialog1) { - this._kickMemberDialog1= kickMemberDialog1 - } + set kickMemberDialog1(kickMemberDialog1) { + this._kickMemberDialog1 = kickMemberDialog1 + } - set kickMemberDialog2(kickMemberDialog2) { - this._kickMemberDialog2 = kickMemberDialog2 - } + set kickMemberDialog2(kickMemberDialog2) { + this._kickMemberDialog2 = kickMemberDialog2 + } - set rGroupId(rGroupId) { - this._rGroupId = rGroupId; - this._rGroupIdBytes = this.constructor.utils.int32ToBytes(this._rGroupId) - } + set rGroupId(rGroupId) { + this._rGroupId = rGroupId + this._rGroupIdBytes = this.constructor.utils.int32ToBytes(this._rGroupId) + } - set rBanReason(rBanReason) { - this._rBanReason = rBanReason - this._rBanReasonBytes = this.constructor.utils.stringtoUTF8Array(this._rBanReason.toLocaleLowerCase()) - this._rBanReasonLength = this.constructor.utils.int32ToBytes(this._rBanReasonBytes.length) - } + set rBanReason(rBanReason) { + this._rBanReason = rBanReason + this._rBanReasonBytes = this.constructor.utils.stringtoUTF8Array(this._rBanReason.toLocaleLowerCase()) + this._rBanReasonLength = this.constructor.utils.int32ToBytes(this._rBanReasonBytes.length) + } - set recipient(recipient) { - this._recipient = recipient instanceof Uint8Array ? recipient : this.constructor.Base58.decode(recipient) - this.theRecipient = recipient - } + set recipient(recipient) { + this._recipient = recipient instanceof Uint8Array ? recipient : this.constructor.Base58.decode(recipient) + this.theRecipient = recipient + } - set fee(fee) { - this._fee = fee * QORT_DECIMALS - this._feeBytes = this.constructor.utils.int64ToBytes(this._fee) - } + 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._rGroupIdBytes, - this._recipient, - this._rBanReasonLength, - this._rBanReasonBytes, - this._feeBytes - ) - return params - } -} \ No newline at end of file + get params() { + const params = super.params + params.push( + this._rGroupIdBytes, + this._recipient, + this._rBanReasonLength, + this._rBanReasonBytes, + this._feeBytes + ) + return params + } +} diff --git a/qortal-ui-crypto/api/transactions/groups/JoinGroupTransaction.js b/qortal-ui-crypto/api/transactions/groups/JoinGroupTransaction.js index 126730ff..57a42bb5 100644 --- a/qortal-ui-crypto/api/transactions/groups/JoinGroupTransaction.js +++ b/qortal-ui-crypto/api/transactions/groups/JoinGroupTransaction.js @@ -1,63 +1,55 @@ -"use strict"; -import TransactionBase from "../TransactionBase.js" -import { QORT_DECIMALS } from "../../constants.js" +'use strict' +import TransactionBase from '../TransactionBase.js' +import { QORT_DECIMALS } from '../../constants.js' export default class JoinGroupTransaction extends TransactionBase { - constructor() { - super() - this.type = 31 - this.tests.push( - () => { - if (!(this._registrantAddress instanceof Uint8Array && this._registrantAddress.length == 25)) { - return "Invalid Registrant " + Base58.encode(this._registrantAddress) - } - return true - } - ) - } + constructor() { + super() + this.type = 31 + } - render(html) { - return html` - ${this._groupdialog1} -
- ${this._rGroupName} -
- ${this._groupdialog2} - ` - } + render(html) { + return html` + ${this._groupdialog1} +
+ ${this._rGroupName} +
+ ${this._groupdialog2} + ` + } - set groupdialog1(groupdialog1) { - this._groupdialog1 = groupdialog1 - } + set groupdialog1(groupdialog1) { + this._groupdialog1 = groupdialog1 + } - set groupdialog2(groupdialog2) { - this._groupdialog2 = groupdialog2 - } + set groupdialog2(groupdialog2) { + this._groupdialog2 = groupdialog2 + } - set fee(fee) { - this._fee = fee * QORT_DECIMALS - this._feeBytes = this.constructor.utils.int64ToBytes(this._fee) - } + set fee(fee) { + this._fee = fee * QORT_DECIMALS + this._feeBytes = this.constructor.utils.int64ToBytes(this._fee) + } - set registrantAddress(registrantAddress) {// Always Base58 encoded. Accepts Uint8Array or Base58 string. - this._registrantAddress = registrantAddress instanceof Uint8Array ? registrantAddress : this.constructor.Base58.decode(registrantAddress); - } + set registrantAddress(registrantAddress) { + this._registrantAddress = registrantAddress instanceof Uint8Array ? registrantAddress : this.constructor.Base58.decode(registrantAddress) + } - set rGroupId(rGroupId) { - this._rGroupId = rGroupId; - this._rGroupIdBytes = this.constructor.utils.int32ToBytes(this._rGroupId) - } + set rGroupId(rGroupId) { + this._rGroupId = rGroupId + this._rGroupIdBytes = this.constructor.utils.int32ToBytes(this._rGroupId) + } - set rGroupName(rGroupName) { - this._rGroupName = rGroupName; - } + set rGroupName(rGroupName) { + this._rGroupName = rGroupName + } - get params() { - const params = super.params; - params.push( - this._rGroupIdBytes, - this._feeBytes - ) - return params; - } -} \ No newline at end of file + get params() { + const params = super.params + params.push( + this._rGroupIdBytes, + this._feeBytes + ) + return params + } +} diff --git a/qortal-ui-crypto/api/transactions/groups/LeaveGroupTransaction.js b/qortal-ui-crypto/api/transactions/groups/LeaveGroupTransaction.js index 0a3939f0..988d768c 100644 --- a/qortal-ui-crypto/api/transactions/groups/LeaveGroupTransaction.js +++ b/qortal-ui-crypto/api/transactions/groups/LeaveGroupTransaction.js @@ -1,63 +1,55 @@ -"use strict"; -import TransactionBase from "../TransactionBase.js" -import { QORT_DECIMALS } from "../../constants.js" +'use strict' +import TransactionBase from '../TransactionBase.js' +import { QORT_DECIMALS } from '../../constants.js' export default class LeaveGroupTransaction extends TransactionBase { - constructor() { - super() - this.type = 32 - this.tests.push( - () => { - if (!(this._registrantAddress instanceof Uint8Array && this._registrantAddress.length == 25)) { - return "Invalid Registrant " + Base58.encode(this._registrantAddress) - } - return true - } - ) - } + constructor() { + super() + this.type = 32 + } - render(html) { - return html` - ${this._groupdialog3} -
- ${this._rGroupName} -
- ${this._groupdialog4} - ` - } + render(html) { + return html` + ${this._groupdialog3} +
+ ${this._rGroupName} +
+ ${this._groupdialog4} + ` + } - set groupdialog3(groupdialog3) { - this._groupdialog3 = groupdialog3 - } + set groupdialog3(groupdialog3) { + this._groupdialog3 = groupdialog3 + } - set groupdialog4(groupdialog4) { - this._groupdialog4 = groupdialog4 - } + set groupdialog4(groupdialog4) { + this._groupdialog4 = groupdialog4 + } - set fee(fee) { - this._fee = fee * QORT_DECIMALS - this._feeBytes = this.constructor.utils.int64ToBytes(this._fee) - } + set fee(fee) { + this._fee = fee * QORT_DECIMALS + this._feeBytes = this.constructor.utils.int64ToBytes(this._fee) + } - set registrantAddress(registrantAddress) {// Always Base58 encoded. Accepts Uint8Array or Base58 string. - this._registrantAddress = registrantAddress instanceof Uint8Array ? registrantAddress : this.constructor.Base58.decode(registrantAddress); - } + set registrantAddress(registrantAddress) { + this._registrantAddress = registrantAddress instanceof Uint8Array ? registrantAddress : this.constructor.Base58.decode(registrantAddress) + } - set rGroupId(rGroupId) { - this._rGroupId = rGroupId; - this._rGroupIdBytes = this.constructor.utils.int32ToBytes(this._rGroupId) - } + set rGroupId(rGroupId) { + this._rGroupId = rGroupId + this._rGroupIdBytes = this.constructor.utils.int32ToBytes(this._rGroupId) + } - set rGroupName(rGroupName) { - this._rGroupName = rGroupName; - } + set rGroupName(rGroupName) { + this._rGroupName = rGroupName + } - get params() { - const params = super.params; - params.push( - this._rGroupIdBytes, - this._feeBytes - ) - return params; - } + get params() { + const params = super.params + params.push( + this._rGroupIdBytes, + this._feeBytes + ) + return params + } } diff --git a/qortal-ui-crypto/api/transactions/groups/RemoveGroupAdminTransaction.js b/qortal-ui-crypto/api/transactions/groups/RemoveGroupAdminTransaction.js index 502c6166..05af0da9 100644 --- a/qortal-ui-crypto/api/transactions/groups/RemoveGroupAdminTransaction.js +++ b/qortal-ui-crypto/api/transactions/groups/RemoveGroupAdminTransaction.js @@ -1,53 +1,53 @@ -'use strict'; -import TransactionBase from "../TransactionBase.js" -import { QORT_DECIMALS } from "../../constants.js" +'use strict' +import TransactionBase from '../TransactionBase.js' +import { QORT_DECIMALS } from '../../constants.js' export default class RemoveGroupAdminTransaction extends TransactionBase { - constructor() { - super() - this.type = 25 - } + constructor() { + super() + this.type = 25 + } - render(html) { - return html` - ${this._kickAdminDialog1} -
- ${this.theRecipient} -
- ${this._kickAdminDialog2} - ` - } + render(html) { + return html` + ${this._kickAdminDialog1} +
+ ${this.theRecipient} +
+ ${this._kickAdminDialog2} + ` + } - set kickAdminDialog1(kickAdminDialog1) { - this._kickAdminDialog1 = kickAdminDialog1 - } + set kickAdminDialog1(kickAdminDialog1) { + this._kickAdminDialog1 = kickAdminDialog1 + } - set kickAdminDialog2(kickAdminDialog2) { - this._kickAdminDialog2 = kickAdminDialog2 - } + set kickAdminDialog2(kickAdminDialog2) { + this._kickAdminDialog2 = kickAdminDialog2 + } - set rGroupId(rGroupId) { - this._rGroupId = rGroupId; - this._rGroupIdBytes = this.constructor.utils.int32ToBytes(this._rGroupId) - } + set rGroupId(rGroupId) { + this._rGroupId = rGroupId + this._rGroupIdBytes = this.constructor.utils.int32ToBytes(this._rGroupId) + } - set recipient(recipient) { - this._recipient = recipient instanceof Uint8Array ? recipient : this.constructor.Base58.decode(recipient) - this.theRecipient = recipient - } + set recipient(recipient) { + this._recipient = recipient instanceof Uint8Array ? recipient : this.constructor.Base58.decode(recipient) + this.theRecipient = recipient + } - set fee(fee) { - this._fee = fee * QORT_DECIMALS - this._feeBytes = this.constructor.utils.int64ToBytes(this._fee) - } + 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._rGroupIdBytes, - this._recipient, - this._feeBytes - ) - return params - } -} \ No newline at end of file + get params() { + const params = super.params + params.push( + this._rGroupIdBytes, + this._recipient, + this._feeBytes + ) + return params + } +} diff --git a/qortal-ui-crypto/api/transactions/names/BuyNameTransacion.js b/qortal-ui-crypto/api/transactions/names/BuyNameTransacion.js index 36aa7d60..48671a2a 100644 --- a/qortal-ui-crypto/api/transactions/names/BuyNameTransacion.js +++ b/qortal-ui-crypto/api/transactions/names/BuyNameTransacion.js @@ -1,70 +1,70 @@ -'use strict'; +'use strict' import TransactionBase from '../TransactionBase.js' import { QORT_DECIMALS } from '../../constants.js' export default class BuyNameTransacion extends TransactionBase { - constructor() { - super() - this.type = 7 - } + constructor() { + super() + this.type = 7 + } - render(html) { - return html` - ${this._buyNameDialog1} -
- ${this.nameText} -
- ${this._buyNameDialog2} -
- ${this.showSellPrice} -
- ${this._buyNameDialog3} - ` - } + render(html) { + return html` + ${this._buyNameDialog1} +
+ ${this.nameText} +
+ ${this._buyNameDialog2} +
+ ${this.showSellPrice} +
+ ${this._buyNameDialog3} + ` + } - set buyNameDialog1(buyNameDialog1) { - this._buyNameDialog1 = buyNameDialog1 - } + set buyNameDialog1(buyNameDialog1) { + this._buyNameDialog1 = buyNameDialog1 + } - set buyNameDialog2(buyNameDialog2) { - this._buyNameDialog2 = buyNameDialog2 - } + set buyNameDialog2(buyNameDialog2) { + this._buyNameDialog2 = buyNameDialog2 + } - set buyNameDialog3(buyNameDialog3) { - this._buyNameDialog3 = buyNameDialog3 - } + set buyNameDialog3(buyNameDialog3) { + this._buyNameDialog3 = buyNameDialog3 + } - set fee(fee) { - this._fee = fee * QORT_DECIMALS - this._feeBytes = this.constructor.utils.int64ToBytes(this._fee) - } + set fee(fee) { + this._fee = fee * QORT_DECIMALS + this._feeBytes = this.constructor.utils.int64ToBytes(this._fee) + } - set name(name) { - this.nameText = name - this._nameBytes = this.constructor.utils.stringtoUTF8Array(name) - this._nameLength = this.constructor.utils.int32ToBytes(this._nameBytes.length) - } + set name(name) { + this.nameText = name + this._nameBytes = this.constructor.utils.stringtoUTF8Array(name) + this._nameLength = this.constructor.utils.int32ToBytes(this._nameBytes.length) + } - set sellPrice(sellPrice) { - this.showSellPrice = sellPrice - this._sellPrice = sellPrice * QORT_DECIMALS - this._sellPriceBytes = this.constructor.utils.int64ToBytes(this._sellPrice) - } + set sellPrice(sellPrice) { + this.showSellPrice = sellPrice + this._sellPrice = sellPrice * QORT_DECIMALS + this._sellPriceBytes = this.constructor.utils.int64ToBytes(this._sellPrice) + } - set recipient(recipient) { - this._recipient = recipient instanceof Uint8Array ? recipient : this.constructor.Base58.decode(recipient) - this.theRecipient = recipient - } + set recipient(recipient) { + this._recipient = recipient instanceof Uint8Array ? recipient : this.constructor.Base58.decode(recipient) + this.theRecipient = recipient + } - get params() { - const params = super.params - params.push( - this._nameLength, - this._nameBytes, - this._sellPriceBytes, - this._recipient, - this._feeBytes - ) - return params - } -} \ No newline at end of file + get params() { + const params = super.params + params.push( + this._nameLength, + this._nameBytes, + this._sellPriceBytes, + this._recipient, + this._feeBytes + ) + return params + } +} diff --git a/qortal-ui-crypto/api/transactions/names/CancelSellNameTransacion.js b/qortal-ui-crypto/api/transactions/names/CancelSellNameTransacion.js index bc5a69b3..da8f98bb 100644 --- a/qortal-ui-crypto/api/transactions/names/CancelSellNameTransacion.js +++ b/qortal-ui-crypto/api/transactions/names/CancelSellNameTransacion.js @@ -1,49 +1,49 @@ -'use strict'; +'use strict' import TransactionBase from '../TransactionBase.js' import { QORT_DECIMALS } from '../../constants.js' export default class CancelSellNameTransacion extends TransactionBase { - constructor() { - super() - this.type = 6 - } + constructor() { + super() + this.type = 6 + } - render(html) { - return html` - ${this._cancelSellNameDialog1} -
- ${this.nameText} -
- ${this._cancelSellNameDialog2} - ` - } + render(html) { + return html` + ${this._cancelSellNameDialog1} +
+ ${this.nameText} +
+ ${this._cancelSellNameDialog2} + ` + } - set cancelSellNameDialog1(cancelSellNameDialog1) { - this._cancelSellNameDialog1 = cancelSellNameDialog1 - } + set cancelSellNameDialog1(cancelSellNameDialog1) { + this._cancelSellNameDialog1 = cancelSellNameDialog1 + } - set cancelSellNameDialog2(cancelSellNameDialog2) { - this._cancelSellNameDialog2 = cancelSellNameDialog2 - } + set cancelSellNameDialog2(cancelSellNameDialog2) { + this._cancelSellNameDialog2 = cancelSellNameDialog2 + } - set fee(fee) { - this._fee = fee * QORT_DECIMALS - this._feeBytes = this.constructor.utils.int64ToBytes(this._fee) - } + set fee(fee) { + this._fee = fee * QORT_DECIMALS + this._feeBytes = this.constructor.utils.int64ToBytes(this._fee) + } - set name(name) { - this.nameText = name - this._nameBytes = this.constructor.utils.stringtoUTF8Array(name) - this._nameLength = this.constructor.utils.int32ToBytes(this._nameBytes.length) - } + set name(name) { + this.nameText = name + this._nameBytes = this.constructor.utils.stringtoUTF8Array(name) + this._nameLength = this.constructor.utils.int32ToBytes(this._nameBytes.length) + } - get params() { - const params = super.params - params.push( - this._nameLength, - this._nameBytes, - this._feeBytes - ) - return params - } -} \ No newline at end of file + get params() { + const params = super.params + params.push( + this._nameLength, + this._nameBytes, + this._feeBytes + ) + return params + } +} diff --git a/qortal-ui-crypto/api/transactions/names/RegisterNameTransaction.js b/qortal-ui-crypto/api/transactions/names/RegisterNameTransaction.js index dac9f69e..6076e7c3 100644 --- a/qortal-ui-crypto/api/transactions/names/RegisterNameTransaction.js +++ b/qortal-ui-crypto/api/transactions/names/RegisterNameTransaction.js @@ -1,57 +1,57 @@ -"use strict"; -import TransactionBase from "../TransactionBase.js" -import { QORT_DECIMALS } from "../../constants.js" +'use strict' +import TransactionBase from '../TransactionBase.js' +import { QORT_DECIMALS } from '../../constants.js' export default class RegisterNameTransaction extends TransactionBase { - constructor() { - super() - this.type = 3 - } + constructor() { + super() + this.type = 3 + } - render(html) { - return html` - ${this._dialogyou} -
- ${this.nameText} -
- ${this._dialogonpress} - ` - } + render(html) { + return html` + ${this._dialogyou} +
+ ${this.nameText} +
+ ${this._dialogonpress} + ` + } - set dialogyou(dialogyou) { - this._dialogyou = dialogyou - } + set dialogyou(dialogyou) { + this._dialogyou = dialogyou + } - set dialogonpress(dialogonpress) { - this._dialogonpress = dialogonpress - } + set dialogonpress(dialogonpress) { + this._dialogonpress = dialogonpress + } - set fee(fee) { - this._fee = fee * QORT_DECIMALS - this._feeBytes = this.constructor.utils.int64ToBytes(this._fee) - } + set fee(fee) { + this._fee = fee * QORT_DECIMALS + this._feeBytes = this.constructor.utils.int64ToBytes(this._fee) + } - set name(name) { - this.nameText = name; - this._nameBytes = this.constructor.utils.stringtoUTF8Array(name) - this._nameLength = this.constructor.utils.int32ToBytes(this._nameBytes.length) - } + set name(name) { + this.nameText = name + this._nameBytes = this.constructor.utils.stringtoUTF8Array(name) + this._nameLength = this.constructor.utils.int32ToBytes(this._nameBytes.length) + } - set value(value) { - this.valueText = value.length === 0 ? "Registered Name on the Qortal Chain" : value; - this._valueBytes = this.constructor.utils.stringtoUTF8Array(this.valueText) - this._valueLength = this.constructor.utils.int32ToBytes(this._valueBytes.length) - } + set value(value) { + this.valueText = value.length === 0 ? "Registered Name on the Qortal Chain" : value + this._valueBytes = this.constructor.utils.stringtoUTF8Array(this.valueText) + this._valueLength = this.constructor.utils.int32ToBytes(this._valueBytes.length) + } - get params() { - const params = super.params; - params.push( - this._nameLength, - this._nameBytes, - this._valueLength, - this._valueBytes, - this._feeBytes - ) - return params; - } + get params() { + const params = super.params + params.push( + this._nameLength, + this._nameBytes, + this._valueLength, + this._valueBytes, + this._feeBytes + ) + return params + } } diff --git a/qortal-ui-crypto/api/transactions/names/SellNameTransacion.js b/qortal-ui-crypto/api/transactions/names/SellNameTransacion.js index aeb8b72e..8659edf7 100644 --- a/qortal-ui-crypto/api/transactions/names/SellNameTransacion.js +++ b/qortal-ui-crypto/api/transactions/names/SellNameTransacion.js @@ -1,64 +1,64 @@ -'use strict'; +'use strict' import TransactionBase from '../TransactionBase.js' import { QORT_DECIMALS } from '../../constants.js' export default class SellNameTransacion extends TransactionBase { - constructor() { - super() - this.type = 5 - } + constructor() { + super() + this.type = 5 + } - render(html) { - return html` - ${this._sellNameDialog1} -
- ${this.nameText} -
- ${this._sellNameDialog2} -
- ${this.showSellPrice} -
- ${this._sellNameDialog3} - ` - } + render(html) { + return html` + ${this._sellNameDialog1} +
+ ${this.nameText} +
+ ${this._sellNameDialog2} +
+ ${this.showSellPrice} +
+ ${this._sellNameDialog3} + ` + } - set sellNameDialog1(sellNameDialog1) { - this._sellNameDialog1 = sellNameDialog1 - } + set sellNameDialog1(sellNameDialog1) { + this._sellNameDialog1 = sellNameDialog1 + } - set sellNameDialog2(sellNameDialog2) { - this._sellNameDialog2 = sellNameDialog2 - } + set sellNameDialog2(sellNameDialog2) { + this._sellNameDialog2 = sellNameDialog2 + } - set sellNameDialog3(sellNameDialog3) { - this._sellNameDialog3 = sellNameDialog3 - } + set sellNameDialog3(sellNameDialog3) { + this._sellNameDialog3 = sellNameDialog3 + } - set fee(fee) { - this._fee = fee * QORT_DECIMALS - this._feeBytes = this.constructor.utils.int64ToBytes(this._fee) - } + set fee(fee) { + this._fee = fee * QORT_DECIMALS + this._feeBytes = this.constructor.utils.int64ToBytes(this._fee) + } - set name(name) { - this.nameText = name - this._nameBytes = this.constructor.utils.stringtoUTF8Array(name) - this._nameLength = this.constructor.utils.int32ToBytes(this._nameBytes.length) - } + set name(name) { + this.nameText = name + this._nameBytes = this.constructor.utils.stringtoUTF8Array(name) + this._nameLength = this.constructor.utils.int32ToBytes(this._nameBytes.length) + } - set sellPrice(sellPrice) { - this.showSellPrice = sellPrice - this._sellPrice = sellPrice * QORT_DECIMALS - this._sellPriceBytes = this.constructor.utils.int64ToBytes(this._sellPrice) - } + set sellPrice(sellPrice) { + this.showSellPrice = sellPrice + this._sellPrice = sellPrice * QORT_DECIMALS + this._sellPriceBytes = this.constructor.utils.int64ToBytes(this._sellPrice) + } - get params() { - const params = super.params - params.push( - this._nameLength, - this._nameBytes, - this._sellPriceBytes, - this._feeBytes - ) - return params - } -} \ No newline at end of file + get params() { + const params = super.params + params.push( + this._nameLength, + this._nameBytes, + this._sellPriceBytes, + this._feeBytes + ) + return params + } +} diff --git a/qortal-ui-crypto/api/transactions/registerName_dnsthing.js b/qortal-ui-crypto/api/transactions/registerName_dnsthing.js index 08e7713c..06210cc4 100644 --- a/qortal-ui-crypto/api/transactions/registerName_dnsthing.js +++ b/qortal-ui-crypto/api/transactions/registerName_dnsthing.js @@ -1,39 +1,36 @@ -"use strict"; -/* - TO DO -*/ -(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); - } +'use strict' - function generateRegisterNameTransaction(keyPair, lastReference, owner, name, value, fee, timestamp, signature) => { - return appendBuffer( generateRegisterNameTransactionBase(keyPair.publicKey, lastReference, owner, name, value, fee, timestamp), - signature ); - } + (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 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 generateRegisterNameTransaction(keyPair, lastReference, owner, name, value, fee, timestamp, signature) => { + return appendBuffer(generateRegisterNameTransactionBase(keyPair.publicKey, lastReference, owner, name, value, fee, timestamp), signature) + } - let data = new Uint8Array(); + 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) - 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); + let data = new Uint8Array() - return data; - } -}()) \ No newline at end of file + 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 + } + }()) diff --git a/qortal-ui-crypto/api/transactions/reward-share/RemoveRewardShareTransaction.js b/qortal-ui-crypto/api/transactions/reward-share/RemoveRewardShareTransaction.js index d8ca9480..5610830e 100644 --- a/qortal-ui-crypto/api/transactions/reward-share/RemoveRewardShareTransaction.js +++ b/qortal-ui-crypto/api/transactions/reward-share/RemoveRewardShareTransaction.js @@ -1,55 +1,55 @@ -"use strict"; -import TransactionBase from "../TransactionBase.js" +'use strict' +import TransactionBase from '../TransactionBase.js' import publicKeyToAddress from '../../wallet/publicKeyToAddress.js' -import { Base58 } from "../../deps/deps.js"; +import { Base58 } from '../../deps/deps.js' export default class RemoveRewardShareTransaction extends TransactionBase { - constructor() { - super() - this.type = 38 - } + constructor() { + super() + this.type = 38 + } - render(html) { - return html` - ${this._rewarddialog5} -
- ${this.constructor.Base58.encode(this._recipient)} -
- ${this._rewarddialog6} - ` - } + render(html) { + return html` + ${this._rewarddialog5} +
+ ${this.constructor.Base58.encode(this._recipient)} +
+ ${this._rewarddialog6} + ` + } - set rewarddialog5(rewarddialog5) { - this._rewarddialog5 = rewarddialog5; - } + set rewarddialog5(rewarddialog5) { + this._rewarddialog5 = rewarddialog5 + } - set rewarddialog6(rewarddialog6) { - this._rewarddialog6 = rewarddialog6; - } + set rewarddialog6(rewarddialog6) { + this._rewarddialog6 = rewarddialog6 + } - set rewardShareKeyPairPublicKey(rewardShareKeyPairPublicKey) { - this._rewardShareKeyPairPublicKey = Base58.decode(rewardShareKeyPairPublicKey) - } + set rewardShareKeyPairPublicKey(rewardShareKeyPairPublicKey) { + this._rewardShareKeyPairPublicKey = Base58.decode(rewardShareKeyPairPublicKey) + } - set recipient(recipient) { - const _address = publicKeyToAddress(this._keyPair.publicKey) - this._recipient = recipient instanceof Uint8Array ? recipient : this.constructor.Base58.decode(recipient) - this.fee = _address === recipient ? 0 : 0.001 - } + set recipient(recipient) { + const _address = publicKeyToAddress(this._keyPair.publicKey) + this._recipient = recipient instanceof Uint8Array ? recipient : this.constructor.Base58.decode(recipient) + this.fee = _address === recipient ? 0 : 0.001 + } - set percentageShare(share) { - this._percentageShare = share * 100 - this._percentageShareBytes = this.constructor.utils.int64ToBytes(this._percentageShare) - } + set percentageShare(share) { + this._percentageShare = share * 100 + this._percentageShareBytes = this.constructor.utils.int64ToBytes(this._percentageShare) + } - get params() { - const params = super.params - params.push( - this._recipient, - this._rewardShareKeyPairPublicKey, - this._percentageShareBytes, - this._feeBytes - ) - return params; - } + get params() { + const params = super.params + params.push( + this._recipient, + this._rewardShareKeyPairPublicKey, + this._percentageShareBytes, + this._feeBytes + ) + return params + } } diff --git a/qortal-ui-crypto/api/transactions/reward-share/RewardShareTransaction.js b/qortal-ui-crypto/api/transactions/reward-share/RewardShareTransaction.js index cc67356a..939552f9 100644 --- a/qortal-ui-crypto/api/transactions/reward-share/RewardShareTransaction.js +++ b/qortal-ui-crypto/api/transactions/reward-share/RewardShareTransaction.js @@ -1,4 +1,4 @@ -"use strict"; +'use strict' import publicKeyToAddress from '../../wallet/publicKeyToAddress.js' import TransactionBase from "../TransactionBase.js" import nacl from '../../deps/nacl-fast.js' @@ -6,74 +6,73 @@ import ed2curve from '../../deps/ed2curve.js' import { Sha256 } from 'asmcrypto.js' export default class RewardShareTransaction extends TransactionBase { - constructor() { - super() - this.type = 38 - } + constructor() { + super() + this.type = 38 + } - render(html) { - return html` - ${this._rewarddialog1} ${this._percentageShare / 1e8}% ${this._rewarddialog2} ${this.constructor.Base58.encode(this._recipient)}? - ${this._rewarddialog3} -
- ${this._base58RewardShareSeed} -
- ${this._rewarddialog4} - ` - } + render(html) { + return html` + ${this._rewarddialog1} ${this._percentageShare / 1e8}% ${this._rewarddialog2} ${this.constructor.Base58.encode(this._recipient)}? + ${this._rewarddialog3} +
+ ${this._base58RewardShareSeed} +
+ ${this._rewarddialog4} + ` + } - set rewarddialog1(rewarddialog1) { - this._rewarddialog1 = rewarddialog1; - } + set rewarddialog1(rewarddialog1) { + this._rewarddialog1 = rewarddialog1 + } - set rewarddialog2(rewarddialog2) { - this._rewarddialog2 = rewarddialog2; - } + set rewarddialog2(rewarddialog2) { + this._rewarddialog2 = rewarddialog2 + } - set rewarddialog3(rewarddialog3) { - this._rewarddialog3 = rewarddialog3; - } + set rewarddialog3(rewarddialog3) { + this._rewarddialog3 = rewarddialog3 + } - set rewarddialog4(rewarddialog4) { - this._rewarddialog4 = rewarddialog4; - } + set rewarddialog4(rewarddialog4) { + this._rewarddialog4 = rewarddialog4 + } - set recipientPublicKey(recipientPublicKey) { - this._base58RecipientPublicKey = recipientPublicKey instanceof Uint8Array ? this.constructor.Base58.encode(recipientPublicKey) : recipientPublicKey - this._recipientPublicKey = this.constructor.Base58.decode(this._base58RecipientPublicKey) + 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.recipient = publicKeyToAddress(this._recipientPublicKey) - this.fee = (recipientPublicKey === this.constructor.Base58.encode(this._keyPair.publicKey) ? 0 : 0.001) + this.fee = (recipientPublicKey === this.constructor.Base58.encode(this._keyPair.publicKey) ? 0 : 0.001) - // Reward share keys - 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); - this._rewardShareSeed = new Sha256().process(sharedSecret).finish().result - this._base58RewardShareSeed = this.constructor.Base58.encode(this._rewardShareSeed) + 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); + this._rewardShareSeed = new Sha256().process(sharedSecret).finish().result + this._base58RewardShareSeed = this.constructor.Base58.encode(this._rewardShareSeed) - this._rewardShareKeyPair = nacl.sign.keyPair.fromSeed(this._rewardShareSeed) - } + this._rewardShareKeyPair = nacl.sign.keyPair.fromSeed(this._rewardShareSeed) + } - set recipient(recipient) { // Always Base58 encoded. Accepts Uint8Array or Base58 string. - this._recipient = recipient instanceof Uint8Array ? recipient : this.constructor.Base58.decode(recipient) - } + set recipient(recipient) { + this._recipient = recipient instanceof Uint8Array ? recipient : this.constructor.Base58.decode(recipient) + } - set percentageShare(share) { - this._percentageShare = share * 100 - this._percentageShareBytes = this.constructor.utils.int64ToBytes(this._percentageShare) - } + set percentageShare(share) { + this._percentageShare = share * 100 + this._percentageShareBytes = this.constructor.utils.int64ToBytes(this._percentageShare) + } - get params() { - const params = super.params - params.push( - this._recipient, - this._rewardShareKeyPair.publicKey, - this._percentageShareBytes, - this._feeBytes - ) - return params; - } + get params() { + const params = super.params + params.push( + this._recipient, + this._rewardShareKeyPair.publicKey, + this._percentageShareBytes, + this._feeBytes + ) + return params + } } diff --git a/qortal-ui-crypto/api/transactions/trade-portal/tradebot/TradeBotCreateRequest.js b/qortal-ui-crypto/api/transactions/trade-portal/tradebot/TradeBotCreateRequest.js index 85d5867c..05178976 100644 --- a/qortal-ui-crypto/api/transactions/trade-portal/tradebot/TradeBotCreateRequest.js +++ b/qortal-ui-crypto/api/transactions/trade-portal/tradebot/TradeBotCreateRequest.js @@ -5,75 +5,59 @@ */ export default class TradeBotCreateRequest { - constructor() { - // ... - } + constructor() { + // ... + } - createTransaction(txnReq) { + createTransaction(txnReq) { + this.creatorPublicKey(txnReq.creatorPublicKey) + this.qortAmount(txnReq.qortAmount) + this.fundingQortAmount(txnReq.fundingQortAmount) + this.foreignBlockchain(txnReq.foreignBlockchain) + this.foreignAmount(txnReq.foreignAmount) + this.tradeTimeout(txnReq.tradeTimeout) + this.receivingAddress(txnReq.receivingAddress) - this.creatorPublicKey(txnReq.creatorPublicKey); + return this.txnRequest() + } - this.qortAmount(txnReq.qortAmount); + creatorPublicKey(creatorPublicKey) { + this._creatorPublicKey = creatorPublicKey + } - this.fundingQortAmount(txnReq.fundingQortAmount); + qortAmount(qortAmount) { + this._qortAmount = qortAmount + } - this.foreignBlockchain(txnReq.foreignBlockchain); + fundingQortAmount(fundingQortAmount) { + this._fundingQortAmount = fundingQortAmount + } - this.foreignAmount(txnReq.foreignAmount); + foreignBlockchain(foreignBlockchain) { + this._foreignBlockchain = foreignBlockchain + } - this.tradeTimeout(txnReq.tradeTimeout); + foreignAmount(foreignAmount) { + this._foreignAmount = foreignAmount + } - this.receivingAddress(txnReq.receivingAddress); + tradeTimeout(tradeTimeout) { + this._tradeTimeout = tradeTimeout + } - return this.txnRequest(); - } + receivingAddress(receivingAddress) { + this._receivingAddress = receivingAddress + } - creatorPublicKey(creatorPublicKey) { - - this._creatorPublicKey = creatorPublicKey; - - } - - qortAmount(qortAmount) { - this._qortAmount = qortAmount; - } - - - fundingQortAmount(fundingQortAmount) { - - this._fundingQortAmount = fundingQortAmount; - } - - foreignBlockchain(foreignBlockchain) { - - this._foreignBlockchain = foreignBlockchain; - } - - foreignAmount(foreignAmount) { - - this._foreignAmount = foreignAmount; - } - - tradeTimeout(tradeTimeout) { - - this._tradeTimeout = tradeTimeout; - } - - receivingAddress(receivingAddress) { - - this._receivingAddress = receivingAddress; - } - - txnRequest() { - - return { - creatorPublicKey: this._creatorPublicKey, - qortAmount: this._qortAmount, - fundingQortAmount: this._fundingQortAmount, - foreignBlockchain: this._foreignBlockchain, - foreignAmount: this._foreignAmount, - tradeTimeout: this._tradeTimeout, - receivingAddress: this._receivingAddress - } - } + txnRequest() { + return { + creatorPublicKey: this._creatorPublicKey, + qortAmount: this._qortAmount, + fundingQortAmount: this._fundingQortAmount, + foreignBlockchain: this._foreignBlockchain, + foreignAmount: this._foreignAmount, + tradeTimeout: this._tradeTimeout, + receivingAddress: this._receivingAddress + } + } } diff --git a/qortal-ui-crypto/api/transactions/trade-portal/tradebot/TradeBotRespondRequest.js b/qortal-ui-crypto/api/transactions/trade-portal/tradebot/TradeBotRespondRequest.js index 773ea336..4380b46b 100644 --- a/qortal-ui-crypto/api/transactions/trade-portal/tradebot/TradeBotRespondRequest.js +++ b/qortal-ui-crypto/api/transactions/trade-portal/tradebot/TradeBotRespondRequest.js @@ -5,41 +5,35 @@ */ export default class TradeBotRespondRequest { - constructor() { - // ... - } + constructor() { + // ... + } - createTransaction(txnReq) { + createTransaction(txnReq) { + this.atAddress(txnReq.atAddress) + this.foreignKey(txnReq.foreignKey) + this.receivingAddress(txnReq.receivingAddress) - this.atAddress(txnReq.atAddress) + return this.txnRequest() + } - this.foreignKey(txnReq.foreignKey) + atAddress(atAddress) { + this._atAddress = atAddress + } - this.receivingAddress(txnReq.receivingAddress) + foreignKey(foreignKey) { + this._foreignKey = foreignKey + } - return this.txnRequest() - } + receivingAddress(receivingAddress) { + this._receivingAddress = receivingAddress + } - atAddress(atAddress) { - - this._atAddress = atAddress - } - - foreignKey(foreignKey) { - this._foreignKey = foreignKey - } - - receivingAddress(receivingAddress) { - - this._receivingAddress = receivingAddress - } - - txnRequest() { - - return { - atAddress: this._atAddress, - foreignKey: this._foreignKey, - receivingAddress: this._receivingAddress - } - } + txnRequest() { + return { + atAddress: this._atAddress, + foreignKey: this._foreignKey, + receivingAddress: this._receivingAddress + } + } } diff --git a/qortal-ui-crypto/api/transactions/trade-portal/tradebot/signTradeBotTransaction.js b/qortal-ui-crypto/api/transactions/trade-portal/tradebot/signTradeBotTransaction.js index 3671183a..bce40ed8 100644 --- a/qortal-ui-crypto/api/transactions/trade-portal/tradebot/signTradeBotTransaction.js +++ b/qortal-ui-crypto/api/transactions/trade-portal/tradebot/signTradeBotTransaction.js @@ -2,37 +2,30 @@ import Base58 from '../../../deps/Base58.js' import nacl from '../../../deps/nacl-fast.js' import utils from '../../../deps/utils.js' - const signTradeBotTransaction = (unsignedTxn, keyPair) => { + if (!unsignedTxn) { + throw new Error('Unsigned Transaction Bytes not defined') + } - if (!unsignedTxn) { - throw new Error('Unsigned Transaction Bytes not defined') - } + if (!keyPair) { + throw new Error('keyPair not defined') + } - if (!keyPair) { - throw new Error('keyPair not defined') - } + const txnBuffer = Base58.decode(unsignedTxn) - const txnBuffer = Base58.decode(unsignedTxn) + if (keyPair.privateKey.length === undefined) { + const _privateKey = Object.keys(keyPair.privateKey).map(function (key) { return keyPair.privateKey[key]; }) + const privateKey = new Uint8Array(_privateKey) + const signature = nacl.sign.detached(txnBuffer, privateKey) + const signedBytes = utils.appendBuffer(txnBuffer, signature) - if (keyPair.privateKey.length === undefined) { + return signedBytes + } else { + const signature = nacl.sign.detached(txnBuffer, keyPair.privateKey) + const signedBytes = utils.appendBuffer(txnBuffer, signature) - const _privateKey = Object.keys(keyPair.privateKey).map(function (key) { return keyPair.privateKey[key]; }); - const privateKey = new Uint8Array(_privateKey) - - const signature = nacl.sign.detached(txnBuffer, privateKey) - - const signedBytes = utils.appendBuffer(txnBuffer, signature) - - return signedBytes - } else { - - const signature = nacl.sign.detached(txnBuffer, keyPair.privateKey) - - const signedBytes = utils.appendBuffer(txnBuffer, signature) - - return signedBytes - } + return signedBytes + } } export default signTradeBotTransaction diff --git a/qortal-ui-crypto/api/transactions/trade-portal/tradeoffer/DeleteTradeOffer.js b/qortal-ui-crypto/api/transactions/trade-portal/tradeoffer/DeleteTradeOffer.js index c7b3f0e1..982d2423 100644 --- a/qortal-ui-crypto/api/transactions/trade-portal/tradeoffer/DeleteTradeOffer.js +++ b/qortal-ui-crypto/api/transactions/trade-portal/tradeoffer/DeleteTradeOffer.js @@ -5,35 +5,29 @@ */ export default class DeleteTradeOffer { - constructor() { - // ... - } + constructor() { + // ... + } - createTransaction(txnReq) { + createTransaction(txnReq) { + this.creatorPublicKey(txnReq.creatorPublicKey) + this.atAddress(txnReq.atAddress) - this.creatorPublicKey(txnReq.creatorPublicKey) + return this.txnRequest() + } - this.atAddress(txnReq.atAddress) + creatorPublicKey(creatorPublicKey) { + this._creatorPublicKey = creatorPublicKey + } - return this.txnRequest() - } + atAddress(atAddress) { + this._atAddress = atAddress + } - creatorPublicKey(creatorPublicKey) { - - this._creatorPublicKey = creatorPublicKey - - } - - atAddress(atAddress) { - - this._atAddress = atAddress - } - - txnRequest() { - - return { - creatorPublicKey: this._creatorPublicKey, - atAddress: this._atAddress - } - } + txnRequest() { + return { + creatorPublicKey: this._creatorPublicKey, + atAddress: this._atAddress + } + } } diff --git a/qortal-ui-crypto/api/transactions/trade-portal/tradeoffer/cancelAllOffers.js b/qortal-ui-crypto/api/transactions/trade-portal/tradeoffer/cancelAllOffers.js index 425c2684..e3011a59 100644 --- a/qortal-ui-crypto/api/transactions/trade-portal/tradeoffer/cancelAllOffers.js +++ b/qortal-ui-crypto/api/transactions/trade-portal/tradeoffer/cancelAllOffers.js @@ -1,24 +1,25 @@ import { request } from '../../../fetch-request.js' -import { deleteTradeOffer, signTradeBotTxn } from '../../../tradeRequest.js'; +import { deleteTradeOffer, signTradeBotTxn } from '../../../tradeRequest.js' import { processTransaction } from '../../../createTransaction.js' export const cancelAllOffers = async (requestObject) => { - const keyPair = requestObject.keyPair; - const publicKey = requestObject.base58PublicKey; - const address = requestObject.address; + const keyPair = requestObject.keyPair + const publicKey = requestObject.base58PublicKey + const address = requestObject.address - const getMyOpenOffers = async () => { - const res = await request('/crosschain/tradeoffers'); - const myOpenTradeOrders = await res.filter(order => order.mode === "OFFERING" && order.qortalCreator === address); - return myOpenTradeOrders; - } + const getMyOpenOffers = async () => { + const res = await request('/crosschain/tradeoffers') + const myOpenTradeOrders = await res.filter(order => order.mode === "OFFERING" && order.qortalCreator === address) + return myOpenTradeOrders + } - const myOpenOffers = await getMyOpenOffers(); - let response = true; - myOpenOffers.forEach( async (openOffer) => { - let unsignedTxn = await deleteTradeOffer({ creatorPublicKey: publicKey, atAddress: openOffer.qortalAtAddress }); - let signedTxnBytes = await signTradeBotTxn(unsignedTxn, keyPair); - await processTransaction(signedTxnBytes); - }); - return response + const myOpenOffers = await getMyOpenOffers() + let response = true + + myOpenOffers.forEach(async (openOffer) => { + let unsignedTxn = await deleteTradeOffer({ creatorPublicKey: publicKey, atAddress: openOffer.qortalAtAddress }) + let signedTxnBytes = await signTradeBotTxn(unsignedTxn, keyPair) + await processTransaction(signedTxnBytes) + }) + return response } diff --git a/qortal-ui-crypto/api/transactions/transactions.js b/qortal-ui-crypto/api/transactions/transactions.js index 84f2759b..b9387184 100644 --- a/qortal-ui-crypto/api/transactions/transactions.js +++ b/qortal-ui-crypto/api/transactions/transactions.js @@ -22,26 +22,26 @@ import RemoveRewardShareTransaction from './reward-share/RemoveRewardShareTransa import TransferPrivsTransaction from './TransferPrivsTransaction.js' export const transactionTypes = { - 2: PaymentTransaction, - 3: RegisterNameTransaction, - 5: SellNameTransacion, - 6: CancelSellNameTransacion, - 7: BuyNameTransacion, - 17: MessageTransaction, - 18: ChatTransaction, - 181: GroupChatTransaction, - 19: PublicizeTransaction, - 22: CreateGroupTransaction, - 24: AddGroupAdminTransaction, - 25: RemoveGroupAdminTransaction, - 26: GroupBanTransaction, - 27: CancelGroupBanTransaction, - 28: GroupKickTransaction, - 29: GroupInviteTransaction, - 30: CancelGroupInviteTransaction, - 31: JoinGroupTransaction, - 32: LeaveGroupTransaction, - 38: RewardShareTransaction, - 381: RemoveRewardShareTransaction, - 40: TransferPrivsTransaction + 2: PaymentTransaction, + 3: RegisterNameTransaction, + 5: SellNameTransacion, + 6: CancelSellNameTransacion, + 7: BuyNameTransacion, + 17: MessageTransaction, + 18: ChatTransaction, + 181: GroupChatTransaction, + 19: PublicizeTransaction, + 22: CreateGroupTransaction, + 24: AddGroupAdminTransaction, + 25: RemoveGroupAdminTransaction, + 26: GroupBanTransaction, + 27: CancelGroupBanTransaction, + 28: GroupKickTransaction, + 29: GroupInviteTransaction, + 30: CancelGroupInviteTransaction, + 31: JoinGroupTransaction, + 32: LeaveGroupTransaction, + 38: RewardShareTransaction, + 381: RemoveRewardShareTransaction, + 40: TransferPrivsTransaction } diff --git a/qortal-ui-crypto/api/wallet/base58PublicKeyToAddress.js b/qortal-ui-crypto/api/wallet/base58PublicKeyToAddress.js index 914a67e0..dbbae27d 100644 --- a/qortal-ui-crypto/api/wallet/base58PublicKeyToAddress.js +++ b/qortal-ui-crypto/api/wallet/base58PublicKeyToAddress.js @@ -1,11 +1,8 @@ import publicKeyToAddress from './publicKeyToAddress' import Base58 from '../deps/Base58.js' - export const base58PublicKeyToAddress = (base58pubkey, qora = false) => { - const decodePubKey = Base58.decode(base58pubkey) - - const address = publicKeyToAddress(decodePubKey, qora) - - return address + const decodePubKey = Base58.decode(base58pubkey) + const address = publicKeyToAddress(decodePubKey, qora) + return address } diff --git a/qortal-ui-crypto/api/wallet/publicKeyToAddress.js b/qortal-ui-crypto/api/wallet/publicKeyToAddress.js index cd484903..1839a05b 100644 --- a/qortal-ui-crypto/api/wallet/publicKeyToAddress.js +++ b/qortal-ui-crypto/api/wallet/publicKeyToAddress.js @@ -1,37 +1,35 @@ -import RIPEMD160 from '../deps/ripemd160.js' +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 utils from '../deps/utils.js' -import Base58 from '../deps/Base58.js' -import { Buffer } from 'buffer' - -import { ADDRESS_VERSION } from '../constants.js' - const repeatSHA256 = (passphrase, hashes) => { - let hash = passphrase - for (let i = 0; i < hashes; i++) { - hash = new Sha256().process(hash).finish().result - } - return hash + let hash = passphrase + for (let i = 0; i < hashes; i++) { + hash = new Sha256().process(hash).finish().result + } + return hash } const publicKeyToAddress = (publicKey, qora = false) => { - const publicKeySha256 = new Sha256().process(publicKey).finish().result - const _publicKeyHash = qora ? new BROKEN_RIPEMD160().digest(publicKeySha256) : new RIPEMD160().update(Buffer.from(publicKeySha256)).digest('hex') + const publicKeySha256 = new Sha256().process(publicKey).finish().result + const _publicKeyHash = qora ? new BROKEN_RIPEMD160().digest(publicKeySha256) : new RIPEMD160().update(Buffer.from(publicKeySha256)).digest('hex') + const publicKeyHash = qora ? _publicKeyHash : _publicKeyHash - const publicKeyHash = qora ? _publicKeyHash : _publicKeyHash - let address = new Uint8Array() + let address = new Uint8Array() - address = utils.appendBuffer(address, [ADDRESS_VERSION]) - address = utils.appendBuffer(address, publicKeyHash) + address = utils.appendBuffer(address, [ADDRESS_VERSION]) + address = utils.appendBuffer(address, publicKeyHash) - const checkSum = repeatSHA256(address, 2) - address = utils.appendBuffer(address, checkSum.subarray(0, 4)) + const checkSum = repeatSHA256(address, 2) + address = utils.appendBuffer(address, checkSum.subarray(0, 4)) - address = Base58.encode(address) + address = Base58.encode(address) - return address + return address } export default publicKeyToAddress diff --git a/qortal-ui-crypto/api/wallet/validateAddress.js b/qortal-ui-crypto/api/wallet/validateAddress.js index 515773b1..e487a55e 100644 --- a/qortal-ui-crypto/api/wallet/validateAddress.js +++ b/qortal-ui-crypto/api/wallet/validateAddress.js @@ -1,12 +1,10 @@ import Base58 from '../deps/Base58.js' - export const validateAddress = (address) => { - const decodePubKey = Base58.decode(address) - - if (!(decodePubKey instanceof Uint8Array && decodePubKey.length == 25)) { - return false - } - return true + const decodePubKey = Base58.decode(address) + if (!(decodePubKey instanceof Uint8Array && decodePubKey.length == 25)) { + return false + } + return true } diff --git a/qortal-ui-crypto/config.js b/qortal-ui-crypto/config.js index 6fccb8cc..e17ca4f2 100644 --- a/qortal-ui-crypto/config.js +++ b/qortal-ui-crypto/config.js @@ -6,33 +6,32 @@ const configWatchers = [] const waitingForConfig = [] const subscribeToStore = () => { - if (!store) return setTimeout(() => subscribeToStore(), 50) // 0.05s + if (!store) return setTimeout(() => subscribeToStore(), 50) - store.subscribe(() => { - const cA = store.getState().app - const c = store.getState().config - if (!c.loaded) return - if (!loaded) waitingForConfig.forEach(r => r(cA)) - configWatchers.forEach(fn => fn(cA)) - config = cA - }) + store.subscribe(() => { + const cA = store.getState().app + const c = store.getState().config + if (!c.loaded) return + if (!loaded) waitingForConfig.forEach(r => r(cA)) + configWatchers.forEach(fn => fn(cA)) + config = cA + }) } subscribeToStore() export function getConfig() { - return config + return config } export function watchConfig(fn) { - // config ? fn(config) : void 0 - fn(config) - configWatchers.push(fn) + fn(config) + configWatchers.push(fn) } export function waitForConfig() { - return new Promise((resolve, reject) => { - if (config) return resolve(config) - waitingForConfig.push(resolve) - }) -} \ No newline at end of file + return new Promise((resolve, reject) => { + if (config) return resolve(config) + waitingForConfig.push(resolve) + }) +} diff --git a/qortal-ui-plugins/plugins/core/components/ChatModals.js b/qortal-ui-plugins/plugins/core/components/ChatModals.js index d6cf6aba..62e9b4e6 100644 --- a/qortal-ui-plugins/plugins/core/components/ChatModals.js +++ b/qortal-ui-plugins/plugins/core/components/ChatModals.js @@ -183,6 +183,7 @@ class ChatModals extends LitElement { timestamp: sendTimestamp, recipient: recipient, recipientPublicKey: _publicKey, + hasChatReference: 0, message: messageText, lastReference: reference, proofOfWorkNonce: 0, diff --git a/qortal-ui-plugins/plugins/core/components/ChatPage.js b/qortal-ui-plugins/plugins/core/components/ChatPage.js index a3bfba57..c6745df3 100644 --- a/qortal-ui-plugins/plugins/core/components/ChatPage.js +++ b/qortal-ui-plugins/plugins/core/components/ChatPage.js @@ -695,6 +695,7 @@ class ChatPage extends LitElement { timestamp: Date.now(), recipient: this._chatId, recipientPublicKey: this._publicKey.key, + hasChatReference: 0, message: messageText, lastReference: reference, proofOfWorkNonce: 0, @@ -712,6 +713,7 @@ class ChatPage extends LitElement { timestamp: Date.now(), groupID: Number(this._chatId), hasReceipient: 0, + hasChatReference: 0, message: messageText, lastReference: reference, proofOfWorkNonce: 0, diff --git a/qortal-ui-plugins/plugins/core/components/ChatWelcomePage.js b/qortal-ui-plugins/plugins/core/components/ChatWelcomePage.js index 11f046ff..91d5beec 100644 --- a/qortal-ui-plugins/plugins/core/components/ChatWelcomePage.js +++ b/qortal-ui-plugins/plugins/core/components/ChatWelcomePage.js @@ -410,6 +410,7 @@ class ChatWelcomePage extends LitElement { timestamp: sendTimestamp, recipient: recipient, recipientPublicKey: _publicKey, + hasChatReference: 0, message: messageText, lastReference: reference, proofOfWorkNonce: 0, diff --git a/qortal-ui-plugins/plugins/core/components/NameMenu.js b/qortal-ui-plugins/plugins/core/components/NameMenu.js index ca67af73..feb454c8 100644 --- a/qortal-ui-plugins/plugins/core/components/NameMenu.js +++ b/qortal-ui-plugins/plugins/core/components/NameMenu.js @@ -529,6 +529,7 @@ class NameMenu extends LitElement { timestamp: sendTimestamp, recipient: recipient, recipientPublicKey: _publicKey, + hasChatReference: 0, message: messageText, lastReference: reference, proofOfWorkNonce: 0, diff --git a/qortal-ui-plugins/plugins/core/messaging/q-chat/q-chat.src.js b/qortal-ui-plugins/plugins/core/messaging/q-chat/q-chat.src.js index dc59b97f..984314bd 100644 --- a/qortal-ui-plugins/plugins/core/messaging/q-chat/q-chat.src.js +++ b/qortal-ui-plugins/plugins/core/messaging/q-chat/q-chat.src.js @@ -789,6 +789,7 @@ class Chat extends LitElement { timestamp: sendTimestamp, recipient: recipient, recipientPublicKey: _publicKey, + hasChatReference: 0, message: messageText, lastReference: reference, proofOfWorkNonce: 0, From 6049d18f4949db8bb445418652300b0cff4df09f Mon Sep 17 00:00:00 2001 From: AlphaX-Projects <77661270+AlphaX-Projects@users.noreply.github.com> Date: Fri, 13 Jan 2023 11:22:50 +0100 Subject: [PATCH 3/5] Fixx transactions --- .../api/transactions/TransactionBase.js | 47 +++++ .../api/transactions/chat/ChatBase.js | 190 +++++++++++------- .../api/transactions/chat/ChatTransaction.js | 2 +- .../transactions/chat/GroupChatTransaction.js | 3 +- 4 files changed, 167 insertions(+), 75 deletions(-) diff --git a/qortal-ui-crypto/api/transactions/TransactionBase.js b/qortal-ui-crypto/api/transactions/TransactionBase.js index ae5f613e..f41b7749 100644 --- a/qortal-ui-crypto/api/transactions/TransactionBase.js +++ b/qortal-ui-crypto/api/transactions/TransactionBase.js @@ -19,6 +19,53 @@ export default class TransactionBase { this.fee = 0 this.groupID = 0 this.timestamp = Date.now() + 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)) { + if (this._lastReference == 0) { + return 'Invalid last reference. Please ensure that you have at least 0.001 QORT for the transaction fee.' + } + 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 + } + ] } render(html) { diff --git a/qortal-ui-crypto/api/transactions/chat/ChatBase.js b/qortal-ui-crypto/api/transactions/chat/ChatBase.js index 783176ed..240c9068 100644 --- a/qortal-ui-crypto/api/transactions/chat/ChatBase.js +++ b/qortal-ui-crypto/api/transactions/chat/ChatBase.js @@ -5,93 +5,137 @@ import Base58 from '../../deps/Base58.js' import utils from '../../deps/utils.js' export default class ChatBase { - static get utils() { - return utils - } - static get nacl() { - return nacl - } - static get Base58() { - return Base58 - } + static get utils() { + return utils + } + static get nacl() { + return nacl + } + static get Base58() { + return Base58 + } - constructor() { - this.fee = 0 - this.groupID = 0 - } + 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 keyPair(keyPair) { - this._keyPair = keyPair - } + set keyPair(keyPair) { + this._keyPair = keyPair + } - set type(type) { - this.typeText = TX_TYPES[type] - this._type = type - this._typeBytes = this.constructor.utils.int32ToBytes(this._type) - } + set type(type) { + this.typeText = TX_TYPES[type] + this._type = type + this._typeBytes = this.constructor.utils.int32ToBytes(this._type) + } - set groupID(groupID) { - this._groupID = groupID - this._groupIDBytes = this.constructor.utils.int32ToBytes(this._groupID) - } + set groupID(groupID) { + this._groupID = groupID + this._groupIDBytes = this.constructor.utils.int32ToBytes(this._groupID) + } - set timestamp(timestamp) { - this._timestamp = timestamp - this._timestampBytes = this.constructor.utils.int64ToBytes(this._timestamp) - } + set timestamp(timestamp) { + this._timestamp = timestamp + this._timestampBytes = this.constructor.utils.int64ToBytes(this._timestamp) + } - set fee(fee) { - this._fee = fee * QORT_DECIMALS - this._feeBytes = this.constructor.utils.int64ToBytes(this._fee) - } + set fee(fee) { + this._fee = fee * QORT_DECIMALS + this._feeBytes = this.constructor.utils.int64ToBytes(this._fee) + } - set lastReference(lastReference) { - this._lastReference = lastReference instanceof Uint8Array ? lastReference : this.constructor.Base58.decode(lastReference) - } + set lastReference(lastReference) { + this._lastReference = lastReference instanceof Uint8Array ? lastReference : this.constructor.Base58.decode(lastReference) + } - get params() { - return [ - this._typeBytes, - this._timestampBytes, - this._groupIDBytes, - this._lastReference, - this._keyPair.publicKey - ] - } + get params() { + return [ + this._typeBytes, + this._timestampBytes, + this._groupIDBytes, + this._lastReference, + this._keyPair.publicKey + ] + } - get chatBytes() { - const isValid = this.validParams() - if (!isValid.valid) { - throw new Error(isValid.message) - } + get chatBytes() { + const isValid = this.validParams() + if (!isValid.valid) { + throw new Error(isValid.message) + } - let result = new Uint8Array() + let result = new Uint8Array() - this.params.forEach(item => { - result = this.constructor.utils.appendBuffer(result, item) - }) + this.params.forEach(item => { + result = this.constructor.utils.appendBuffer(result, item) + }) - this._chatBytes = result + this._chatBytes = result - return this._chatBytes - } + return this._chatBytes + } - validParams() { - let finalResult = { - valid: true - } + validParams() { + let finalResult = { + valid: true + } - this.tests.some(test => { - const result = test() - if (result !== true) { - finalResult = { - valid: false, - message: result - } - return true - } - }) - return finalResult - } + this.tests.some(test => { + const result = test() + if (result !== true) { + finalResult = { + valid: false, + message: result + } + return true + } + }) + return finalResult + } } diff --git a/qortal-ui-crypto/api/transactions/chat/ChatTransaction.js b/qortal-ui-crypto/api/transactions/chat/ChatTransaction.js index 642ff744..d6313924 100644 --- a/qortal-ui-crypto/api/transactions/chat/ChatTransaction.js +++ b/qortal-ui-crypto/api/transactions/chat/ChatTransaction.js @@ -67,7 +67,7 @@ export default class ChatTransaction extends ChatBase { } get params() { - const params = super.params; + const params = super.params params.push( this._proofOfWorkNonce, this._hasReceipient, diff --git a/qortal-ui-crypto/api/transactions/chat/GroupChatTransaction.js b/qortal-ui-crypto/api/transactions/chat/GroupChatTransaction.js index e414d10b..dc3a856b 100644 --- a/qortal-ui-crypto/api/transactions/chat/GroupChatTransaction.js +++ b/qortal-ui-crypto/api/transactions/chat/GroupChatTransaction.js @@ -1,5 +1,6 @@ 'use strict' import ChatBase from "./ChatBase.js" +import { CHAT_REFERENCE_FEATURE_TRIGGER_TIMESTAMP } from '../../constants.js' export default class GroupChatTransaction extends ChatBase { constructor() { @@ -43,7 +44,7 @@ export default class GroupChatTransaction extends ChatBase { } get params() { - const params = super.params; + const params = super.params params.push( this._proofOfWorkNonce, this._hasReceipient, From 827095888289d1e406dcae2cc6f30da29e0083a7 Mon Sep 17 00:00:00 2001 From: Phillip Date: Fri, 13 Jan 2023 16:01:26 -0500 Subject: [PATCH 4/5] add chat refence timestamp --- qortal-ui-crypto/api/constants.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/qortal-ui-crypto/api/constants.js b/qortal-ui-crypto/api/constants.js index d5c58016..11c0cbbf 100644 --- a/qortal-ui-crypto/api/constants.js +++ b/qortal-ui-crypto/api/constants.js @@ -149,8 +149,6 @@ const ERROR_CODES = { 1000: "Not yet released." } -const CHAT_REFERENCE_FEATURE_TRIGGER_TIMESTAMP = 0 - // Qortal 8 decimals const QORT_DECIMALS = 1e8 @@ -161,7 +159,7 @@ const ADDRESS_VERSION = 58 const PROXY_URL = "/proxy/" // Chat reference timestamp -const CHAT_REFERENCE_FEATURE_TRIGGER_TIMESTAMP = 9999999999999 +const CHAT_REFERENCE_FEATURE_TRIGGER_TIMESTAMP = 1674316800000 // Used as a salt for all qora addresses. Salts used for storing your private keys in local storage will be randomly generated const STATIC_SALT = new Uint8Array([54, 190, 201, 206, 65, 29, 123, 129, 147, 231, 180, 166, 171, 45, 95, 165, 78, 200, 208, 194, 44, 207, 221, 146, 45, 238, 68, 68, 69, 102, 62, 6]) From 8bf0e9c68d40e0480d924cd762ebe7bd46c01dff Mon Sep 17 00:00:00 2001 From: Phillip Date: Fri, 13 Jan 2023 20:17:28 -0500 Subject: [PATCH 5/5] fix forwarding --- qortal-ui-core/language/us.json | 4 +- qortal-ui-crypto/api/constants.js | 2 +- .../plugins/core/components/ChatPage.js | 118 ++++++++++++++---- 3 files changed, 97 insertions(+), 27 deletions(-) diff --git a/qortal-ui-core/language/us.json b/qortal-ui-core/language/us.json index 6818dafc..d2e9d87b 100644 --- a/qortal-ui-core/language/us.json +++ b/qortal-ui-core/language/us.json @@ -548,7 +548,9 @@ "cchange39": "Cannot send an encrypted message to this user since they do not have their publickey on chain.", "cchange40": "IMAGE (click to view)", "cchange41":"Your Balance Is Under 4.20 QORT", - "cchange42":"Out of the need to combat spam, accounts with under 4.20 Qort balance will take a long time to SEND messages in Q-Chat. If you wish to immediately increase the send speed for Q-Chat messages, obtain over 4.20 QORT to your address. This can be done with trades in the Trade Portal, or by way of another Qortian giving you the QORT. Once you have over 4.20 QORT in your account, Q-Chat messages will be instant and this dialog will no more show. Thank you for your understanding of this necessary spam prevention method, and we hope you enjoy Qortal!" + "cchange42":"Out of the need to combat spam, accounts with under 4.20 Qort balance will take a long time to SEND messages in Q-Chat. If you wish to immediately increase the send speed for Q-Chat messages, obtain over 4.20 QORT to your address. This can be done with trades in the Trade Portal, or by way of another Qortian giving you the QORT. Once you have over 4.20 QORT in your account, Q-Chat messages will be instant and this dialog will no more show. Thank you for your understanding of this necessary spam prevention method, and we hope you enjoy Qortal!", + "cchange62": "Wrong Username and Address Inputted! Please try again!", + "cchange63": "Please enter a recipient" }, "welcomepage": { diff --git a/qortal-ui-crypto/api/constants.js b/qortal-ui-crypto/api/constants.js index 11c0cbbf..ae139416 100644 --- a/qortal-ui-crypto/api/constants.js +++ b/qortal-ui-crypto/api/constants.js @@ -159,7 +159,7 @@ const ADDRESS_VERSION = 58 const PROXY_URL = "/proxy/" // Chat reference timestamp -const CHAT_REFERENCE_FEATURE_TRIGGER_TIMESTAMP = 1674316800000 +const CHAT_REFERENCE_FEATURE_TRIGGER_TIMESTAMP = 0 // Used as a salt for all qora addresses. Salts used for storing your private keys in local storage will be randomly generated const STATIC_SALT = new Uint8Array([54, 190, 201, 206, 65, 29, 123, 129, 147, 231, 180, 166, 171, 45, 95, 165, 78, 200, 208, 194, 44, 207, 221, 146, 45, 238, 68, 68, 69, 102, 62, 6]) diff --git a/qortal-ui-plugins/plugins/core/components/ChatPage.js b/qortal-ui-plugins/plugins/core/components/ChatPage.js index 7f7d12e8..f20ca847 100644 --- a/qortal-ui-plugins/plugins/core/components/ChatPage.js +++ b/qortal-ui-plugins/plugins/core/components/ChatPage.js @@ -900,8 +900,10 @@ class ChatPage extends LitElement { id="sendTo" placeholder="${translate("chatpage.cchange7")}" @keydown=${() => { - this.forwardActiveChatHeadUrl = {}; - this.requestUpdate(); + if (this.forwardActiveChatHeadUrl.selected) { + this.forwardActiveChatHeadUrl = {}; + this.requestUpdate(); + } } } /> @@ -977,7 +979,6 @@ class ChatPage extends LitElement { ${translate("chatpage.cchange33")}