Skip to content
This repository has been archived by the owner on Sep 27, 2024. It is now read-only.

Commit

Permalink
Fix an issue where breaking masternodes would fail.
Browse files Browse the repository at this point in the history
  • Loading branch information
sproxet committed Jul 26, 2022
1 parent 2d4c3e6 commit 345c196
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
8 changes: 5 additions & 3 deletions src/renderer/components/SendPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ export default {
}),
transactionFee() {
if (!this.satoshiAmount) return undefined;
if (!this.satoshiAmount || !this.available || this.available < this.satoshiAmount) return undefined;
return this.calculateTransactionFee(this.isPrivate, this.satoshiAmount, this.txFeePerKb, this.subtractFeeFromAmount, this.customInputs.length ? this.customInputs : undefined);
},
Expand Down Expand Up @@ -270,7 +270,9 @@ export default {
},
available () {
return this.isPrivate ? this.availablePrivate : this.availablePublic;
if (this.coinControl) return this.coinControlSelectedAmount;
else if (this.isPrivate) return this.availablePrivate;
else return this.availablePublic;
},
// This is the amount the user entered in satoshis.
Expand All @@ -290,7 +292,7 @@ export default {
// We can begin the send if the fee has been shown and the form is valid.
canBeginSend () {
return this.isValidated && this.transactionFee > 0 && !this.totalAmountExceedsBalance;
return this.isValidated && this.transactionFee > 0 && (this.available >= this.totalAmount);
},
isValidated () {
Expand Down
6 changes: 3 additions & 3 deletions src/renderer/components/SendPage/SendFlow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export default {
computed: {
...mapGetters({
addressBook: 'AddressBook/addressBook',
lockedTransactions: 'Transactions/lockedTransactions',
lockedUTXOs: 'Transactions/lockedUTXOs',
allowBreakingMasternodes: 'App/allowBreakingMasternodes',
selectInputs: 'Transactions/selectInputs'
}),
Expand Down Expand Up @@ -116,9 +116,9 @@ export default {
} else {
if (this.coinControl && this.allowBreakingMasternodes) {
const lockedCoins = this.coinControl.filter(coin =>
this.lockedTransactions.find(tx => tx.txid === coin[0] && tx.txIndex === coin[1])
this.lockedUTXOs.find(tx => tx.txid === coin[0] && tx.index === coin[1])
);
await $daemon.updateCoinLocks(passphrase, [], lockedCoins);
if (lockedCoins.length) await $daemon.updateCoinLocks(passphrase, [], lockedCoins);
}
// Under the hood we'll always use coin control because the daemon uses a very complex stochastic
Expand Down
2 changes: 1 addition & 1 deletion src/store/modules/Balance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const getters = {
unconfirmedPublicChange, locked, immature] = [0, 0, 0, 0, 0, 0, 0, 0, 0];
let nextHeight: number = rootGetters['ApiStatus/currentBlockHeight'] + 1;

for (const txo of <TXO[]>rootGetters['Transactions/TXOs']) {
for (const txo of <TXO[]>rootGetters['Transactions/UTXOs']) {
if (!txo.isToMe || txo.isSpent) continue;
else if (txo.isLocked) locked += txo.amount;
else if (txo.inputPrivacy == 'mined' && txo.validAt > nextHeight) immature += txo.amount;
Expand Down
1 change: 1 addition & 0 deletions src/store/modules/Transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ const getters = {
txo.spendSize &&
txo.validAt <= rootGetters['ApiStatus/currentBlockHeight'] + 1
),
lockedUTXOs: (state, getters) => getters.UTXOs.filter((txo: TXO) => txo.isLocked),

userVisibleTransactions: (state, getters): TXO[] => getters.TXOs
.filter((txo: TXO) => !txo.isChange && txo.destination)
Expand Down

0 comments on commit 345c196

Please sign in to comment.