Skip to content

Commit d0c6bcc

Browse files
authored
Merge pull request #23 from navcoindev/v1.1.1
V1.1.1
2 parents 1acdc59 + dd6ab67 commit d0c6bcc

12 files changed

+95
-19
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,11 @@ Here are the detailed explaination of what the settings control and their defaul
9898
| `GLOBAL` | `object` | true | `none` | contains the global settings which control how your server operates |
9999
| `GLOBAL.serverType` | `string` | true | `INCOMING` | determines if your server is of incoming or outgoing type |
100100
| `GLOBAL.encryptedWallet` | `boolean` | true | `false` | flag for if the NavCoin and Subchain wallets are encrypted |
101+
| `GLOBAL.preventSend` | `boolean` | false | `false` | flag to prevent sending of NAV & SUB for testing purposes |
101102
| `GLOBAL.maintenance` | `boolean` | false | `false` | flag to turn your wallet to maintenance mode and restrict IP access |
102103
| `GLOBAL.allowedIps` | `array` | false | `none` | array of allowed ip addresses when server is in maintenance mode |
103-
| `GLOBAL.allowedIps[n]` | `string` | false | `none` | ip address to allow for maintenance testing |
104+
| `GLOBAL.allowedIps[n]` | `object` | true | `none` | contains the address information of a single user allowed while in maintenance |
105+
| `GLOBAL.allowedIps[n].ipAddress` | `string` | true | `none` | ip address to allow for maintenance testing |
104106
| `INCOMING` | `object` | true | `none` | contains all the settings which are unique to incoming servers |
105107
| `INCOMING.local` | `object` | true | `none` | contains the address information of the local (incoming) server |
106108
| `INCOMING.local.ipAddress` | `string` | true | `none` | IP address of the local server |

config/example-incoming.default.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
"GLOBAL": {
33
"serverType": "INCOMING",
44
"encryptedWallet": false,
5-
"maintenance": true,
6-
"allowedIps": [
7-
"192.168.1.1"
8-
]
5+
"maintenance": false,
6+
"preventSend": false,
7+
"allowedIps": [{
8+
"ipAddress": "192.168.1.1"
9+
}]
910
},
1011
"INCOMING": {
1112
"local": {

config/example-outgoing.default.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"GLOBAL": {
33
"serverType": "OUTGOING",
4-
"encryptedWallet": false
4+
"encryptedWallet": false,
5+
"preventSend": true
56
},
67
"OUTGOING": {
78
"local": {

dist/navtech.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/lib/ProcessIncoming.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ const lodash = require('lodash')
22
const ursa = require('ursa')
33

44
let Logger = require('./Logger.js') // eslint-disable-line
5-
let EncryptedData = require('./EncryptedData.js')
5+
let EncryptedData = require('./EncryptedData.js') // eslint-disable-line
66
const privateSettings = require('../settings/private.settings.json')
7-
let SendToAddress = require('./SendToAddress.js')
7+
let SendToAddress = require('./SendToAddress.js') // eslint-disable-line
88

99
const ProcessIncoming = {}
1010

src/lib/RandomizeTransactions.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ RandomizeTransactions.randomizeIncoming = () => {
4040
const randAmount = Math.round(randSatoshis / satoshiFactor)
4141

4242
if (randAmount > sumProcessed - runningTotal || i === RandomizeTransactions.runtime.addresses.length - 1) {
43-
const remainingAmount = sumProcessed - runningTotal
43+
const remainingAmount = Math.round(sumProcessed - runningTotal)
4444
RandomizeTransactions.runtime.transactions[RandomizeTransactions.runtime.addresses[i]] = remainingAmount / satoshiFactor
4545
runningTotal += remainingAmount
4646
} else {
@@ -91,7 +91,7 @@ RandomizeTransactions.randomizeOutgoing = () => {
9191
const randAmount = Math.round(randSatoshis / satoshiFactor)
9292

9393
if (randAmount > sumPendingSatoshi - runningTotal || i === numTransactions - 1) {
94-
const remainingAmount = Math.floor(sumPendingSatoshi - runningTotal)
94+
const remainingAmount = Math.round(sumPendingSatoshi - runningTotal)
9595
RandomizeTransactions.runtime.transactions.push(remainingAmount / satoshiFactor)
9696
runningTotal += remainingAmount
9797
} else {

src/lib/ReturnToSender.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,11 @@ ReturnToSender.decodeOriginInputRaw = (options, callback) => {
9494

9595
ReturnToSender.buildTransaction = (options, callback) => {
9696
const outgoingTransactions = {}
97-
outgoingTransactions[options.origin] = options.transaction.amount - privateSettings.txFee
97+
const satoshiFactor = 100000000
98+
const newAmountFloat = options.transaction.amount - privateSettings.txFee
99+
const amountSatoshi = Math.round(newAmountFloat * satoshiFactor)
100+
101+
outgoingTransactions[options.origin] = amountSatoshi / satoshiFactor
98102

99103
const spentTransactions = [{
100104
txid: options.transaction.txid,

src/lib/SendRawTransaction.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ SendRawTransaction.createRaw = (options, callback) => {
2121
callback(false, { message: 'invalid options provided to SelectOutgoing.run' })
2222
return
2323
}
24+
2425
SendRawTransaction.runtime = {} // wipe the runtime variables
2526
if (options.encrypted) {
2627
options.client.createRawTransaction(options.spentTransactions, options.outgoingTransactions, options.encrypted).then((rawTrans) => {
@@ -94,6 +95,11 @@ SendRawTransaction.walletUnlocked = (success, data) => {
9495
}
9596

9697
SendRawTransaction.sendRaw = (options, callback) => {
98+
if (globalSettings.preventSend) {
99+
Logger.writeLog('RAW_TEST_001', 'preventSend triggered', { options })
100+
callback(true, { rawOutcome: 'dummy-tx-id' })
101+
return
102+
}
97103
options.client.sendRawTransaction(options.signedRaw.hex).then((rawOutcome) => {
98104
callback(true, { rawOutcome })
99105
}).catch((err) => {

src/lib/SendToAddress.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ SendToAddress.send = (options, callback) => {
2222
return
2323
}
2424

25+
if (globalSettings.preventSend) {
26+
Logger.writeLog('STA_TEST_001', 'preventSend triggered', { options })
27+
callback(true, { sendOutcome: 'dummy-tx-id', transaction: options.transaction })
28+
return
29+
}
30+
2531
SendToAddress.runtime = {}
2632

2733
if (options.counter && options.counter > 7) {
@@ -30,7 +36,11 @@ SendToAddress.send = (options, callback) => {
3036
return
3137
}
3238

33-
options.client.sendToAddress(options.address, parseFloat(options.amount), null, null, options.encrypted).then((sendOutcome) => {
39+
const satoshiFactor = 100000000
40+
const amountSatoshi = Math.round(options.amount * satoshiFactor)
41+
const safeAmount = amountSatoshi / satoshiFactor
42+
43+
options.client.sendToAddress(options.address, safeAmount, null, null, options.encrypted).then((sendOutcome) => {
3444
if (sendOutcome) {
3545
callback(true, { sendOutcome, transaction: options.transaction })
3646
return

src/lib/SpendToHolding.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,14 @@ SpendToHolding.createHoldingTransactions = (success, data) => {
3434
return
3535
}
3636

37-
let sumPending = 0
37+
const satoshiFactor = 100000000
38+
let sumPendingSatoshi = 0
3839
for (const successful of SpendToHolding.runtime.successfulSubTransactions) {
39-
sumPending += successful.amount - privateSettings.txFee
40+
sumPendingSatoshi += Math.round(successful.amount * satoshiFactor) - Math.round(privateSettings.txFee * satoshiFactor)
4041
}
4142

43+
const sumPending = sumPendingSatoshi / satoshiFactor
44+
4245
const spentTransactions = []
4346

4447
for (let i = 0; i < SpendToHolding.runtime.successfulSubTransactions.length; i++) {

0 commit comments

Comments
 (0)