Skip to content

Commit

Permalink
Merge branch '0.0.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
silkroadnomad committed Apr 16, 2018
2 parents e962787 + 089b143 commit 044495f
Show file tree
Hide file tree
Showing 22 changed files with 245 additions and 243 deletions.
26 changes: 13 additions & 13 deletions .meteor/packages
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,33 @@
# 'meteor add' and 'meteor remove' will edit this file for you,
# but you can also edit it by hand.

meteor-base@1.2.0 # Packages every Meteor app needs to have
meteor-base@1.3.0 # Packages every Meteor app needs to have
[email protected] # Packages for a great mobile UX
mongo@1.3.1 # The database Meteor supports right now
mongo@1.4.2 # The database Meteor supports right now
[email protected] # Compile .html files into Meteor Blaze views
[email protected] # Reactive variable for tracker
[email protected] # Meteor's client-side reactive programming library

standard-minifier-css@1.3.5 # CSS minifier run for production mode
standard-minifier-js@2.2.0 # JS minifier run for production mode
es5-shim@4.6.15 # ECMAScript 5 compatibility for older browsers
ecmascript@0.9.0 # Enable ECMAScript2015+ syntax in app code
[email protected].0 # Server-side component of the `meteor shell` command
standard-minifier-css@1.4.0 # CSS minifier run for production mode
standard-minifier-js@2.3.1 # JS minifier run for production mode
es5-shim@4.7.0 # ECMAScript 5 compatibility for older browsers
ecmascript@0.10.6 # Enable ECMAScript2015+ syntax in app code
[email protected].1 # Server-side component of the `meteor shell` command

planettraining:material-design-icons-font
nimble:restivus
accounts-password
accounts-password@1.5.0
alanning:roles
ddp-rate-limiter
ddp-rate-limiter@1.0.7
universe:i18n
react-meteor-data
aldeed:collection2-core
aldeed:schema-deny
session
less
session@1.1.7
less@2.7.11
mdg:validated-method
vsivsi:job-collection
email
email@1.2.3
aldeed:[email protected]
aldeed:schema-index
http
http@1.4.0
2 changes: 1 addition & 1 deletion .meteor/release
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[email protected].0.1
[email protected].1.1
63 changes: 33 additions & 30 deletions .meteor/versions
Original file line number Diff line number Diff line change
Expand Up @@ -6,41 +6,41 @@ aldeed:[email protected]
aldeed:[email protected]
aldeed:[email protected]
[email protected]
autoupdate@1.3.12
babel-compiler@6.24.7
babel-runtime@1.1.1
autoupdate@1.4.0
babel-compiler@7.0.7
babel-runtime@1.2.0
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
boilerplate-generator@1.3.1
boilerplate-generator@1.4.0
[email protected]
[email protected]
callback-hook@1.0.10
check@1.2.5
callback-hook@1.1.0
check@1.3.0
[email protected]
[email protected]
ddp-client@2.2.0
ddp-common@1.3.0
ddp-client@2.3.1
ddp-common@1.4.0
[email protected]
[email protected].1
[email protected].2
[email protected]
diff-sequence@1.0.7
dynamic-import@0.2.1
ecmascript@0.9.0
diff-sequence@1.1.0
dynamic-import@0.3.0
ecmascript@0.10.6
[email protected]
ecmascript-runtime-client@0.5.0
ecmascript-runtime-client@0.6.0
[email protected]
[email protected]
[email protected]
es5-shim@4.6.15
es5-shim@4.7.0
[email protected]
[email protected]
[email protected]
[email protected]
http@1.3.0
id-map@1.0.9
http@1.4.0
id-map@1.1.0
[email protected]
[email protected]
[email protected]
Expand All @@ -49,44 +49,47 @@ [email protected]
[email protected]
mdg:[email protected]
[email protected]
meteor-base@1.2.0
minifier-css@1.2.16
minifier-js@2.2.2
meteor-base@1.3.0
minifier-css@1.3.0
minifier-js@2.3.1
[email protected]
[email protected]
[email protected]
[email protected].2
[email protected].3
[email protected]
mongo@1.3.1
mongo@1.4.2
[email protected]
[email protected]
mrt:[email protected]
nimble:[email protected]
[email protected]
[email protected]
[email protected]
ordered-dict@1.0.9
ordered-dict@1.1.0
planettraining:[email protected]
[email protected].0
[email protected].1
raix:[email protected]
random@1.0.10
random@1.1.0
[email protected]
[email protected]
[email protected]
[email protected]
reload@1.1.11
retry@1.0.9
reload@1.2.0
retry@1.1.0
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
simple:[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
standard-minifier-css@1.3.5
standard-minifier-js@2.2.3
standard-minifier-css@1.4.0
standard-minifier-js@2.3.1
[email protected]
[email protected]
[email protected]
Expand All @@ -96,7 +99,7 @@ [email protected]
[email protected]
[email protected]
universe:[email protected]
url@1.1.0
url@1.2.0
vsivsi:[email protected]
webapp@1.4.0
webapp@1.5.0
[email protected]
4 changes: 2 additions & 2 deletions i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"components": {
"userMenu": {
"logout": "Logout",
"login": "Sign In",
"join": "Join",
"login": "Login",
"join": "Sign-up",
"entries": {
"home": {
"name": "Home"
Expand Down
12 changes: 1 addition & 11 deletions imports/api/namecoin/entries.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,6 @@ NamecoinEntries.schema = new SimpleSchema({
txId: {
type: String,
denyUpdate: false
},
expiresIn: {
type: Number,
denyUpdate: false
},
expired: {
type: Boolean,
denyUpdate: false
}
});

Expand All @@ -67,7 +59,5 @@ NamecoinEntries.publicFields = {
name: 1,
value: 1,
address: 1,
txId: 1,
expiresIn: 1,
expired: 1
txId: 1
};
39 changes: 27 additions & 12 deletions imports/modules/server/namecoin/add_entry_and_fetch_data.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,38 +20,53 @@ const AddNamecoinEntrySchema = new SimpleSchema({
},
txId: {
type: String
},
expiresIn: {
type: Number
},
expired: {
type: Boolean
}
});

/**
* Inserts
*
* @param entry
* @returns {*}
*/
const addNamecoinEntry = (entry) => {
try {

if(isDebug()) { console.log("add NamecoinEntry..."+JSON.stringify(entry)); }
const ourEntry = entry;
AddNamecoinEntrySchema.validate(ourEntry);
const ety = NamecoinEntries.findOne({name: ourEntry.name})
if(ety !== undefined) return ety._id;

if(ety !== undefined){
if(isDebug()) { console.log("NamecoinEntry already saved under _id "+ety._id); }
return ety._id;
}

if(isDebug()) { console.log("found entry: "+JSON.stringify(ety)); }
const value = JSON.parse(ourEntry.value);
if(isDebug()) { console.log("from: "+JSON.stringify(value)); }

if(value.from === undefined) throw "Wrong blockchain entry";
const wif = getWif(CONFIRM_CLIENT, CONFIRM_ADDRESS);
const wif = getWif(CONFIRM_CLIENT, CONFIRM_ADDRESS); //TODO is it possible to decrypt a message without private key?
const privateKey = getPrivateKeyFromWif({wif: wif});

if(isDebug()) { console.log("got private key"); }
const domain = decryptMessage({privateKey: privateKey, message: value.from});
if(isDebug()) { console.log("decrypted message from domain: "+domain); }

const id = NamecoinEntries.insert({
name: ourEntry.name,
value: ourEntry.value,
address: ourEntry.address,
txId: ourEntry.txId,
expiresIn: ourEntry.expiresIn,
expired: ourEntry.expired
})
});

if(isDebug()) { console.log("NamecoinEntries added: "+id); }
addFetchDoiMailDataJob({
name: ourEntry.name,
domain: domain
})
});

if(isDebug()) {
console.log("New entry added: \n"+
"NameId="+ourEntry.name+"\n"+
Expand Down
69 changes: 39 additions & 30 deletions imports/modules/server/namecoin/check_new_transactions.js
Original file line number Diff line number Diff line change
@@ -1,46 +1,55 @@
import { Meteor } from 'meteor/meteor';
import { listSinceBlock, nameShow } from '../../../../server/api/namecoin.js';
import { getRawTransaction, nameShow } from '../../../../server/api/namecoin.js';
import { CONFIRM_CLIENT, CONFIRM_ADDRESS } from '../../../startup/server/namecoin-configuration.js';
import { Meta } from '../../../api/meta/meta.js';
import addOrUpdateMeta from '../meta/addOrUpdate.js';
import addNamecoinEntry from './add_entry_and_fetch_data.js'
import {isDebug} from "../../../startup/server/dapp-configuration";

const TX_NAME_START = "update: e/";
const LAST_CHECKED_BLOCK_KEY = "lastCheckedBlock";
const TX_NAME_START = "e/";

const checkNewTransactions = () => {

const checkNewTransaction = (txid) => {
try {
var lastCheckedBlock = Meta.findOne({key: LAST_CHECKED_BLOCK_KEY});
if(lastCheckedBlock !== undefined) lastCheckedBlock = lastCheckedBlock.value;
const ret = listSinceBlock(CONFIRM_CLIENT, lastCheckedBlock);
if(ret === undefined || ret.transactions === undefined) return;
const txs = ret.transactions;
lastCheckedBlock = ret.lastblock;
const addressTxs = txs.filter(tx =>
tx.address === CONFIRM_ADDRESS &&
tx.category === 'receive' &&
tx.confirmations >= 1 &&
tx.name !== undefined &&
tx.name.startsWith(TX_NAME_START));
addressTxs.forEach(tx => addTx(tx));
addOrUpdateMeta({key: LAST_CHECKED_BLOCK_KEY, value: lastCheckedBlock});
console.log("Transactions updated");

if(isDebug()) { console.log("txid: "+txid+' was triggered by walletnotify getting its data from blockchain'); }

const ret = getRawTransaction(CONFIRM_CLIENT, txid);
if(isDebug()) { console.log('gettransaction was called via rpc'); }

const txs = ret.vout;
if(!ret || !txs || !txs.length===0){
console.log("txid"+txid+'does not contain transaction details or transaction not found.');
return;
}
if(isDebug()) { console.log("get transaction details:"+JSON.stringify(txs)); }

const addressTxs = txs.filter(tx =>
tx.scriptPubKey.nameOp !== undefined
&& tx.scriptPubKey.nameOp.op === "name_doi"
&& tx.scriptPubKey.addresses[0] === CONFIRM_ADDRESS
&& tx.scriptPubKey.nameOp.name !== undefined
&& tx.scriptPubKey.nameOp.name.startsWith(TX_NAME_START)
);

addressTxs.forEach(tx => addTx(tx,txid));

} catch(exception) {
throw new Meteor.Error('namecoin.checkNewTransactions.exception', exception);
}
};

function addTx(tx) {
var txName = tx.name.substring(TX_NAME_START.length);
const ety = nameShow(CONFIRM_CLIENT, txName);
function addTx(tx,txid) {

if(isDebug()) { console.log("addTx:"+JSON.stringify(tx)); }
const txName = tx.scriptPubKey.nameOp.name.substring(TX_NAME_START.length);
const txValue = tx.scriptPubKey.nameOp.value;
const txAddress = tx.scriptPubKey.addresses[0]; //a soi entry can only be send to one address so far.

addNamecoinEntry({
name: txName,
value: ety.value,
address: ety.address,
txId: ety.txid,
expiresIn: ety.expires_in,
expired: ety.expired
value: txValue,
address: txAddress,
txId: txid
});
}

export default checkNewTransactions;
export default checkNewTransaction;
9 changes: 1 addition & 8 deletions imports/modules/server/namecoin/claim_and_transfer.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,8 @@ const claim = (data) => {
ClaimSchema.validate(ourData);
const provider = getOptInProvider({domain: ourData.domain});
const publicKey = getOptInKey({domain: provider});
const address = getAddress({publicKey: publicKey});
const address = getAddress({publicKey: publicKey});
const from = encryptMessage({publicKey: publicKey, message: getUrl()});
/* const value = JSON.stringify({
dataHash: ourData.dataHash,
signature: ourData.signature,
soiTimestamp: ourData.soiDate.toISOString(),
from: from
});*/

const value = JSON.stringify({
signature: ourData.signature,
dataHash: ourData.dataHash,
Expand Down
2 changes: 1 addition & 1 deletion imports/modules/server/namecoin/first_update.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const firstUpdate = (data) => {
FirstUpdateSchema.validate(ourData);
nameFirstUpdate(SEND_CLIENT, ourData.nameId, ourData.rand, ourData.tx, ourData.value, ourData.address);
} catch(exception) {
if(exception.toString().indexOf("this name is already active")==-1) //for some reason a name was already in the database and now an exception from nameocoin is thrown
if(exception.toString().indexOf("this name is already active")==-1) //for some reason a name was already in the database and an exception from nameocoin was thrown - skip here
throw new Meteor.Error('namecoin.firstUpdate.exception', exception);
}
};
Expand Down
Loading

0 comments on commit 044495f

Please sign in to comment.