Skip to content

Commit d049ba7

Browse files
committed
ZIP 313 implementation (default fee)
1 parent 0185077 commit d049ba7

File tree

3 files changed

+20
-8
lines changed

3 files changed

+20
-8
lines changed

app/components/Send.js

+11-4
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,8 @@ function getSendManyJSON(sendPageState: SendPageState): [] {
184184
}
185185
})
186186
);
187+
json.push(1); // minconf = 1
188+
json.push(Utils.getDefaultFee()); // Control the default fee as well.
187189

188190
console.log('Sending:');
189191
console.log(json);
@@ -229,7 +231,9 @@ const ConfirmModalInternal = ({
229231
openErrorModal,
230232
history
231233
}) => {
232-
const sendingTotal = sendPageState.toaddrs.reduce((s, t) => parseFloat(s) + parseFloat(t.amount), 0.0) + 0.0001;
234+
const sendingTotal =
235+
sendPageState.toaddrs.reduce((s, t) => parseFloat(s) + parseFloat(t.amount), 0.0) +
236+
Utils.getDefaultFee(info.latestBlock);
233237
const { bigPart, smallPart } = Utils.splitZecAmountIntoBigSmall(sendingTotal);
234238

235239
const sendButton = () => {
@@ -301,7 +305,10 @@ const ConfirmModalInternal = ({
301305
))}
302306
</div>
303307

304-
<ConfirmModalToAddr toaddr={{ to: 'Fee', amount: 0.0001, memo: null }} info={info} />
308+
<ConfirmModalToAddr
309+
toaddr={{ to: 'Fee', amount: Utils.getDefaultFee(info.latestBlock), memo: null }}
310+
info={info}
311+
/>
305312

306313
{info && info.disconnected && (
307314
<div className={[cstyles.red, cstyles.margintoplarge].join(' ')}>
@@ -443,7 +450,7 @@ export default class Send extends PureComponent<Props, SendState> {
443450
};
444451

445452
setMaxAmount = (id: number, total: number) => {
446-
const { sendPageState, setSendPageState } = this.props;
453+
const { sendPageState, setSendPageState, info } = this.props;
447454

448455
const newToAddrs = sendPageState.toaddrs.slice(0);
449456

@@ -452,7 +459,7 @@ export default class Send extends PureComponent<Props, SendState> {
452459
.reduce((s, a) => parseFloat(s) + parseFloat(a.amount), 0);
453460

454461
// Add Fee
455-
totalOtherAmount += Utils.getDefaultFee();
462+
totalOtherAmount += Utils.getDefaultFee(info.latestBlock);
456463

457464
// Find the correct toAddr
458465
const toAddr = newToAddrs.find(a => a.id === id);

app/components/Transactions.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import Utils from '../utils/utils';
1515
import AddressBook from './Addressbook';
1616
import routes from '../constants/routes.json';
1717

18-
const TxModalInternal = ({ modalIsOpen, tx, closeModal, currencyName, zecPrice, setSendTo, history }) => {
18+
const TxModalInternal = ({ modalIsOpen, tx, info, closeModal, currencyName, zecPrice, setSendTo, history }) => {
1919
let txid = '';
2020
let type = '';
2121
let typeIcon = '';
@@ -54,7 +54,7 @@ const TxModalInternal = ({ modalIsOpen, tx, closeModal, currencyName, zecPrice,
5454
};
5555

5656
const doReply = (address: string) => {
57-
setSendTo(new ZcashURITarget(address, 0.0001, null));
57+
setSendTo(new ZcashURITarget(address, Utils.getDefaultFee(info.latestBlock), null));
5858
closeModal();
5959

6060
history.push(routes.SEND);
@@ -336,6 +336,7 @@ export default class Transactions extends Component<Props, State> {
336336
<TxModal
337337
modalIsOpen={modalIsOpen}
338338
tx={clickedTx}
339+
info={info}
339340
closeModal={this.closeModal}
340341
currencyName={info.currencyName}
341342
zecPrice={info.zecPrice}

app/utils/utils.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,12 @@ export default class Utils {
110110
return Utils.nextToAddrID++;
111111
}
112112

113-
static getDefaultFee(): number {
114-
return 0.0001;
113+
static getDefaultFee(height: number): number {
114+
if (height > 1046400) {
115+
return 0.00001;
116+
} else {
117+
return 0.0001;
118+
}
115119
}
116120

117121
static getDonationAddress(testnet: boolean): string {

0 commit comments

Comments
 (0)