Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/commands/generate-lattice-keys.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,14 @@ class Lattice extends Command {
}

// set the fee to default or flag
let fee = 0 // default fee 100 Shor
let fee = 0 // default fee 0 Shor
if (flags.fee) {
const passedFee = parseInt(flags.fee, 10)
if (passedFee) {
fee = passedFee
} else {
if (Number.isNaN(passedFee) || passedFee < 0) {
this.log(`${red('⨉')} Fee is invalid`)
this.exit(1)
}
fee = passedFee
}

// create the keys
Expand Down Expand Up @@ -497,7 +496,7 @@ Lattice.flags = {
fee: flags.string({
char: 'f',
required: false,
description: '(default: 100) QRL (f)ee for transaction in Shor'
description: '(default: 0) QRL (f)ee for transaction in Shor'
}),

otsindex: flags.string({
Expand Down
5 changes: 2 additions & 3 deletions src/commands/notarize.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,11 @@ class Notarise extends Command {
let fee = 0 // default fee 0 Shor
if (flags.fee) {
const passedFee = parseInt(flags.fee, 10)
if (passedFee) {
fee = passedFee
} else {
if (Number.isNaN(passedFee) || passedFee < 0) {
spinner.fail(`${black().bgRed(`Fee is invalid...`)}` )
this.exit(1)
}
fee = passedFee
}

// sign and send transaction
Expand Down
9 changes: 4 additions & 5 deletions src/commands/send-message.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,15 +177,14 @@ class SendMessage extends Command {
}
}
// set the fee to default or flag
let fee = 0 // default fee 100 Shor
let fee = 0 // default fee 0 Shor
if (flags.fee) {
const passedFee = parseInt(flags.fee, 10)
if (passedFee) {
fee = passedFee
} else {
if (Number.isNaN(passedFee) || passedFee < 0) {
this.log(`${red('⨉')} Fee is invalid`)
this.exit(1)
}
fee = passedFee
}

const spinner = ora({ text: 'Sending Message to network...' }).start()
Expand Down Expand Up @@ -387,7 +386,7 @@ SendMessage.flags = {
fee: flags.string({
char: 'f',
required: false,
description: 'QRL (f)ee for transaction in Shor (defaults to 100 Shor)'
description: 'QRL (f)ee for transaction in Shor (defaults to 0 Shor)'
}),

otsindex: flags.string({
Expand Down
9 changes: 4 additions & 5 deletions src/commands/send.js
Original file line number Diff line number Diff line change
Expand Up @@ -390,15 +390,14 @@ class Send extends Command {
this.exit(1)
}
}
let fee = 0 // default fee 100 Shor
let fee = 0 // default fee 0 Shor
if (flags.fee) {
const passedFee = parseInt(flags.fee, 10)
if (passedFee) {
fee = passedFee
} else {
if (Number.isNaN(passedFee) || passedFee < 0) {
this.log(`${red('⨉')} Fee is invalid`)
this.exit(1)
}
fee = passedFee
}
const thisAddressesTo = []
const thisAmounts = []
Expand Down Expand Up @@ -756,7 +755,7 @@ Send.flags = {
fee: flags.string({
char: 'f',
required: false,
description: 'Fee for transaction in Shor (defaults to 100 Shor)'
description: 'Fee for transaction in Shor (defaults to 0 Shor)'
}),

file: flags.string({
Expand Down
5 changes: 2 additions & 3 deletions src/commands/sign-tx-offline.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,12 +323,11 @@ class SignTxOffline extends Command {
let fee = 100 // default fee 100 Shor
if (flags.fee) {
const passedFee = parseInt(flags.fee, 10)
if (passedFee) {
fee = passedFee
} else {
if (Number.isNaN(passedFee) || passedFee < 0) {
this.log(`${red('⨉')} Fee is invalid`)
this.exit(1)
}
fee = passedFee
}
const thisAddressesTo = []
const thisAmounts = []
Expand Down
36 changes: 35 additions & 1 deletion test/commands/send.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -682,9 +682,43 @@ describe('send #3a', () => {
})
})

// an explicit fee of 0 (the default) must be accepted, not rejected as invalid
describe('send #3c', () => {
const fs = require('fs') // eslint-disable-line global-require
const outFile = `${testSetup.sendTXOfflineFile}.zerofee`
let exitCode
before(done => {
const args = [
'send',
'1',
'-r', 'Q000200ecffb27f3d7b11ccd048eb559277d64bb52bfda998341e66a9f11b2d07f6b2ee4f62c408',
'-h', 'aback filled atop regal town opaque gloss send cheek ten fisher cow once home remain module aye salt chord before bunch stiff heel won attend reduce heroic oak shrug midday king fit islam appear',
'-i', '10',
'-f', '0',
'-t',
'-T', outFile,
]
const process = spawn('./bin/run', args, processFlags)
process.on('exit', code => {
exitCode = code
done()
})
})
after(() => {
try { fs.unlinkSync(outFile) } catch (e) { /* ignore */ }
})
it('exit code should be 0 when --fee 0 is passed explicitly', () => {
assert.strictEqual(exitCode, 0)
})
it('writes a transaction carrying a zero fee', () => {
const tx = JSON.parse(fs.readFileSync(outFile))
assert.strictEqual(tx.tx.fee, '0')
})
})



// load from a file
// load from a file
describe('send #3b', () => {
let exitCode
before(done => {
Expand Down