Commit Graph

18674 Commits

Author SHA1 Message Date
dustinface
54ed089f97 test: Implement unit tests for CTransactionBuilder (#3677)
* makefile.test.include: Let privatesend_tests.cpp depend on ENABLE_WALLET

* test: Implement unit tests for CTransactionBuilder

* Check that we can decrease the amount and GetAmountLeft() is updated accordingly

* Check if resulting tx has a change output when expected

* Avoid pushing nullptr into vecOutputs

* Add few notes about size calculations

* nit: better readability (imo)

Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
2020-09-12 22:54:56 +02:00
dustinface
ab0f789be6 wallet: Fix and improve CWallet::CreateTransaction (#3668)
* wallet: Remove unused vecTxDSInTmp in CWallet::CreateTransaction

* wallet: Calculate fees earlier and respect them in change determination

* wallet: Cleanup obsolete code in CreateTransaction

This parts were needed before when the fee was calculated after the
change was assigned. But now with the previous commit the fee is
calculated upfront and respected properly from the begining. So there is
no longer a need of increasing or decreasing the change depending on the
fee as it has the correct value directly after its added.

* wallet: Try to pick other inputs if the selected ones are too small

If nChange is negative in this cases it means that the selected inputs
can't cover the amount to send and the required transaction fee. So we
just add the missing amount to nFeeRet. This leads to the algo
trying to pick larger inputs in the next loop (with nFeeRet more duffs
than in the previous loop). This process gets repeated until the selected
amount is enough to cover all the costs or until the requested amount
can't be selected anymore (not enough utxos to cover it).

* wallet: Break the loop if the transaction is ready

* wallet: Respect additional amount from previous cycles

* wallet: Respect available in coin selection, try all coins in last round

* wallet: Avoid potential infinite loop, just in case..

* wallet: Fix signing in CreateTransaction

Prior it was messed because of 60d96a1a28b55f071c6144f248e136679c44337e. 
Set coins isn't sorted the same way as txNew.vin is so it sometimes may 
pick wrong coins for signing the input.

* wallet: Fix change calculation if "subtract fee from amount" is enabled

* wallet: Return after fee calc if no or not enough amount available

Return the proper fail reason. Prior to this commit it run into
"Exceeded max tried".

Note: Only return if not enough amount is available if we can't subtract
fee from amount.

* wallet: Fix break logic if available amount is not enough

* Revert "wallet: Fix signing in CreateTransaction"

This reverts commit 5fcdc0f00e7b961ebb62c94d17d585537e911309.

* Use a vector of coins instead of a set in CreateTransaction and sort it in a BIP69 compliant way when needed

* wallet: Adjust comment

* Cleaner usage of nChangePosRequest/InOut

* Simplify some fail/try-again conditions (fixed)

* Loop through outputs to update change output position only when outputs are sorted for BIP69

No need to do this for non-bip69 cases (i.e. when a specific change output position was requested and assigned)

* Avoid implicit conversions of int-s into bool-s

* Move `nAmountLeft == nFeeRet` check higher, tweak comments

* wallet: Fix some formatting

* wallet: Improve CTxIn creation in CreateTransaction

Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
2020-09-12 22:54:56 +02:00
dustinface
dd55609d6b test: Implement unit tests for CWallet::CreateTransaction (#3667)
* test: Implement unit tests for CWallet::CreateTransaction

* test: Reset minRelayTxFee in CreateTransactionTest

At this point its modified from an other test when running all unit 
tests which lets this test fail unexpectedly.

* test: Lock cs_main/cs_wallet when required in CreateTransactionTest

* test: Add new test in CreateTransactionTest

Test if the wallet creation fails properly with the correct error
messages.

* test: Fixed expected test results for some CreateTransactionTest cases

* test: Fail if CreateTransaction runs into "Exceed max tries" case

* test: Adjust last return in CreateTransaction

* test: Drop dust tests
2020-09-12 22:54:56 +02:00
dustinface
9c988d5b5a privatesend|wallet|qt: Improve calculations in CreateDenominated/MakeCollateralAmounts (#3657)
* wallet: Add m_dust_feerate to CCoinControl / Use it in CreateTransaction

* privatesend: Introduce CTransactionBuilder/CTransactionBuilderOutput

Builder classes for transactions from type

Inputs: Defined by CompactTallyItem
Outputs: Simple outputs with lose reserve keys

This takes fully takes care of fee calculations and makes sure calculations are the same like those happening when actually create the transaction with CreateTransaction.

* privatesend: Improve amount/fee calculation in CreateDenominated

* privatesend: Improve amount/fee calculation in MakeCollateralAmounts

* qt: Fix decomposeTransaction's MakeCollateralAmounts detection

Align it with the three cases in CPrivateSendClientSession::MakeCollateralAmounts

* Refactor GetFee

The fee rate is always coinControl.m_feerate, also it's not used outside so should be a private method

* Simplify nBytesOutput calculations

* Drop unused GetBytesOutput()

* Make Clear(), GetBytesTotal() and GetAmountUsed() private

* Drop unused GetCoinControl()

* Make ToString() const

* Refactor `CTransactionBuilder::Commit()`

* Reorder cases in decomposeTransaction

* Fix "finished" conditions in CreateDenominated

* Fix typo

* wallet|privatesend: Refactor CCoinControl's m_dust_feerate -> m_discard_feerate

* privatesend: Drop unused member CTransactionBuilder::dustFeeRate

* privatesend: Improve CTransactionBuilder's readability

* privatesend: Make the static CTransactionBuilder::GetAmountLeft private

* wallet: Recover previous code style

* Update src/privatesend/privatesend-util.cpp

Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>

* Tweak CTransactionBuilder to respect potential compact size diffs

* Tweak GetFee param type

* Trivial log/comments tweaks

* privatesend: Fix countPossibleOutputs

- Fix off by one issue
- Respect max outputs threshold

* privatesend: Use GetSizeOfCompactSizeDiff in CTransactionBuilder

* Apply suggestions from code review

Co-authored-by: PastaPastaPasta <6443210+PastaPastaPasta@users.noreply.github.com>

* privatesend: Rename TryAdd to CouldAdd in CTransactionBuilder

* wallet: Reset m_discard_feerate in CCoinControl::SetNull

* Respect `-paytxfee` and `settxfee`

* privatesend: Check for denominated amount only where really required

* qt: Remove obsolete IsCollateralAmount() checks

* privatesend: Don't accept negative amounts in CTransactionBuilder

* privatesend: Remove unused CConnman parameter

* use emplace_back instead of push_back

Signed-off-by: pasta <pasta@dashboost.org>

* fix typos

Signed-off-by: pasta <pasta@dashboost.org>

* make GetAmount const

Signed-off-by: pasta <pasta@dashboost.org>

* privatesend: Explicit capture __func__ in needMoreOutputs lambda

* privatesend: Update CTransactionBuilder::UpdateAmount

* remove const on parameter in declaration

Signed-off-by: pasta <pasta@dashboost.org>

* handle unsigned int -> int conversions a bit better

Signed-off-by: pasta <pasta@dashboost.org>

* explicitly cast to int from unsigned int.

estimateSmartFee handles it if negative

Signed-off-by: pasta <pasta@dashboost.org>

* Make CTransactionBuilderOutput::GetScript const

Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>

* privatesend: Update comments to follow doxygen

* privatesend: Add class descriptions

Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
Co-authored-by: PastaPastaPasta <6443210+PastaPastaPasta@users.noreply.github.com>
Co-authored-by: pasta <pasta@dashboost.org>
2020-09-12 22:54:45 +02:00
dustinface
ba2dcb0399 qt: Update assets and colorize them theme related (#3574)
* qt: Replaced checkbox images with new ones

* qt: Replaced radiobutton images with new ones

* qt: Redefine arrow usage

- Removed "hover" arrows
- Rename normal -> light
- Rename pressed -> dark
- Use light as hover in dark theme and vice versa

* qt: Update icon set

* qt: Update sync spinner

* qt: Add new ThemedColor's

- ThemedColor::ORANGE
- ThemedColor::ICON_ALTERNATIVE_COLOR

* qt: Add GUIUtil::getIcon and GUIUtil::setIcon

* qt: Use themed icons where required

* qt: Make sure icons in SendCoinsEntry are updated on style changes

* qt: Make sure status bar icons are updated on style changes

* qt: Make sure icons in RPCConsole are updated on style changes

* qt: Remove icon/iconsSize in modaloverlaydialog.ui

* qt: Remove obsolete qproperty-iconSize entries from general.css

* qt: Use QToolButton's in SendVerifyMessageDialog and RPCConsole

Instead of QPushButton. This is to have the same alignment of the
iconized buttons by default like in SendCoinsEntry

* qt: Revert arrow icons

* qt: Revert HD icons
2020-09-12 20:56:40 +02:00
PastaPastaPasta
37af70a188
Merge #13622: Remove mapRequest tracking that just effects Qt display. (#3694)
* Merge #13622: Remove mapRequest tracking that just effects Qt display.

beef7ec4be725beea870a2da510d2817487601ec Remove useless mapRequest tracking that just effects Qt display. (Matt Corallo)

Pull request description:

  I thought we had removed this a long time ago, TBH, its really
  confusing feedback to users that we display whether a tx was
  broadcast to immediate neighbor nodes, given that has little
  indication of whether the tx propagated very far.

Tree-SHA512: c9d0808fb60146919bb78d0860ec2193601966c944887eaae7837408422f7e85dfdb306407a613200cdd4726aec66da18df618ebc6a8cfe8650bf08d4a8dc155
Signed-off-by: pasta <pasta@dashboost.org>

* drop TX_STATUS_OFFLINE

Signed-off-by: pasta <pasta@dashboost.org>

Co-authored-by: Wladimir J. van der Laan <laanwj@gmail.com>
2020-09-12 13:29:36 -04:00
dustinface
e13c746a7d
chainparams: Remove llmq_50_60 from regtest (#3696)
Its just not used anywhere so there is no point in starting the thread 
for it imo since it just spams the test logs with tries/failures.
2020-09-12 13:29:36 -04:00
UdjinM6
f2c1a9213c
Fix two potential issues in the way pending islocks are processed (#3678)
* Always check for previous quorum set in llmq IS

* Refactor SelectQuorumForSigning and related code

Should have no changes in behaviour

* Do not use SIGN_HEIGHT_OFFSET when checking pending IS locks, use actual chain tip

This commit actually changes the behaviour
2020-09-12 13:29:36 -04:00
pasta
82ad002541
fix reallocation backport
Signed-off-by: pasta <pasta@dashboost.org>
2020-09-12 13:27:04 -04:00
UdjinM6
eb163c53a5
Implement dynamic activation thresholds (#3692)
* Implement dynamic activation thresholds

* fix

* Revert unrelated changes

* Clarify switching to/staying in LOCKED_IN state

* Fix signal function to work correctly with num_blocks=0

* Add simplified threshold calculation and use it in tests

* Check that thresholds are decreasing, reach the min level and stay there

* Drop `;`
2020-09-12 13:27:04 -04:00
UdjinM6
7d6aba47cf
Implement Block Reward Reallocation (#3691)
* Implement Block Reward Reallocation

* Add integr. test

* drop unused variable

* Sep -> Oct

* Update test/functional/feature_block_reward_reallocation.py

Co-authored-by: PastaPastaPasta <6443210+PastaPastaPasta@users.noreply.github.com>

* Revert to Sep for testnet and devnet

* validation: Refactor reallocation calculations

Makes it much more readable imo and avoids calculating the percentage
each time.

* test: Align reallocation calculation with c++ (GetMasternodePayment)

* test: Make feature_block_reward_allocation.py executable

* Make linter happy

Co-authored-by: PastaPastaPasta <6443210+PastaPastaPasta@users.noreply.github.com>
Co-authored-by: xdustinface <xdustinfacex@gmail.com>
2020-09-12 13:27:04 -04:00
PastaPastaPasta
a70056c5a8
privatesend: Implement Random Round Mixing (#3661)
* Use GetRealOut... instead of Capped

Signed-off-by: pasta <pasta@dashboost.org>

* Add "ps_salt" value to walletdb

This value is used to deterministically pick a random number of rounds to mix, between N and N + GetRandomRounds. A salt is needed in addition to the inputs hash to ensure that an attacker learns nothing from looking at the blockchain.

Signed-off-by: pasta <pasta@dashboost.org>

* Implement Random Round Mixing

This implements "Random Round Mixing." Previously, attempted attacks on PrivateSend assumed that all inputs had been mixed for the same number of rounds. Noramlly assuming 2,4,8 or 16.

While none of these attacks have been successful, they still teach what we can do to make our system more robust, and one of those ways is to implement "Random Round Mixing".

Under the previous system, inputs were mixed up until N rounds (configured by user). At this point, the input was considered mixed, and could be private-sent. Under this new system, an input will be mixed to N rounds like prior. However, at this point, Sha256d(input, salt) will be calculated (note: this likely could be a more efficient hash function than double sha256, but that can be done in another PR / version if needed). If (hash % 2 == 0), then the input will be mixed again.
This results in an exponential decay where if you mix a set of inputs, half of those inputs will be mixed for N rounds, 1/4 will be mixed N+1, 1/8 will be mixed N+2, etc. This current implementation caps it at N+2. This results in mixing an average of N+0.875 rounds. If you removed the cap, you would mix on average N+1 rounds.

Signed-off-by: pasta <pasta@dashboost.org>

* Make PS salt a private member of CWallet, tweak the way it's initialized

* Introduce `CWallet::IsFullyMixed` and use it everywhere instead of comparing rounds directly to ensure consistency between coin selection logic, balance calculations and gui

* Tweak `GetRealOutpointPrivateSendRounds` to respect random rounds

* Tweak IsFullyMixed to make decision on a per-outpoint basis instead of a per-tx one

* make a comment doxygen

Signed-off-by: pasta <pasta@dashboost.org>

* Rename GetPrivateSendSalt InitPrivateSendSalt, since it is not a getter

Signed-off-by: pasta <pasta@dashboost.org>

* move the comment below GetRounds call

Signed-off-by: pasta <pasta@dashboost.org>

* don't use GetCappedOutpointPrivateSendRounds when printing to RPC

Signed-off-by: pasta <pasta@dashboost.org>

* Simplify hashing in IsFullyMixed

Uses just 1 sha256 instead of 3 (1 in SerializeHash + 2 in Hash)

* undo comment change

Signed-off-by: pasta <pasta@dashboost.org>

Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
2020-09-12 13:04:49 -04:00
PastaPastaPasta
df536f269a
Merge #13622: Remove mapRequest tracking that just effects Qt display. (#3694)
* Merge #13622: Remove mapRequest tracking that just effects Qt display.

beef7ec4be725beea870a2da510d2817487601ec Remove useless mapRequest tracking that just effects Qt display. (Matt Corallo)

Pull request description:

  I thought we had removed this a long time ago, TBH, its really
  confusing feedback to users that we display whether a tx was
  broadcast to immediate neighbor nodes, given that has little
  indication of whether the tx propagated very far.

Tree-SHA512: c9d0808fb60146919bb78d0860ec2193601966c944887eaae7837408422f7e85dfdb306407a613200cdd4726aec66da18df618ebc6a8cfe8650bf08d4a8dc155
Signed-off-by: pasta <pasta@dashboost.org>

# Conflicts:
#	src/interfaces/wallet.cpp
#	src/interfaces/wallet.h
#	src/net_processing.cpp
#	src/qt/guiconstants.h
#	src/qt/transactiondesc.cpp
#	src/qt/transactionrecord.cpp
#	src/qt/transactionrecord.h
#	src/qt/transactiontablemodel.cpp
#	src/validationinterface.cpp
#	src/validationinterface.h
#	src/wallet/wallet.cpp

* drop TX_STATUS_OFFLINE

Signed-off-by: pasta <pasta@dashboost.org>

Co-authored-by: Wladimir J. van der Laan <laanwj@gmail.com>
2020-09-12 17:33:54 +03:00
UdjinM6
ab8347e06b
Implement dynamic activation thresholds (#3692)
* Implement dynamic activation thresholds

* fix

* Revert unrelated changes

* Clarify switching to/staying in LOCKED_IN state

* Fix signal function to work correctly with num_blocks=0

* Add simplified threshold calculation and use it in tests

* Check that thresholds are decreasing, reach the min level and stay there

* Drop `;`
2020-09-12 17:33:12 +03:00
UdjinM6
db01af1695
Merge pull request #3693 from PastaPastaPasta/backport-v0.16-develop
[v0.16.x] Backport more PRs to 0.16
2020-09-12 17:32:38 +03:00
dustinface
5176a26007
masternode|net|rpc: Improve masternode sync process (#3690)
* masternode: Replace sync states INITIAL and WAITING with BLOCKCHAIN

* masternode: Peer dependent "assume tip" timeout

I would say its enough to only wait 1 tick if we have more than 3
peers before we move over to governance sync.

* masternode: Notify the UI instantly if switched to governance sync

Without this it takes one iteration more for the UI to receive the
update.

* masternode: Notify the UI about CMasternodeSync::Reset calls

* masternode: Don't instantly reset the sync process

Give it MASTERNODE_SYNC_RESET_SECONDS (600) seconds time after the last
UpdateBlockTip call.

* rpc: Don't switch to next asset in "mnsync reset"

* rpc: Force the reset in "mnsync reset"

* net: Make sure the sync gets a reset if required after network changes

This will reset the sync process if its outdated in the following cases:

- If the connections dropped to zero
- If the connections went from zero to one
- If the network has been enabled or disabled

* Apply suggestions from code review

Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>

* net: Only open masternode connections if the blockchain is synced

In general it doesn't make sense to connect to masternodes before due to 
MNAUTH requires blockchain sync. This could lead to failing quorum 
connections/failing masternode 
probing.. if a just restarted node/a out of sync node 
would hit a dkg block.. Then they would not try to open those 
llmq/probing connections for the next 60s (nLLMQConnectionRetryTimeout). 
Thats basically what happens in tests right now and they fail without 
this commit.

* test: Make sure nodes are synced when they get restored after isolation

Their sync might be out of date otherwise due to bigger mocktime bumps

Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
2020-09-11 15:07:34 +03:00
dustinface
ee32ee0ddf
qt: Improved status bar (#3688)
* qt: Adjust green color

* qt: Don't disable the HD icon

Disabling it leads to incorrect colors due to opacity.

* qt: Move the HD icon to the left

Reason: Its the only one not turning green by default if all is set
properly. So this lets is look better imo.

* qt: Increase statusbar icon size

* qt: Show lock icon in status bar also if wallet is not encrypted

Just as signal to the user!

* qt: Refine connection icon usage

* qt: Use state related colors in statusbar

* qt: Hide the HD icon for non-HD wallets

* qt: Update HD icon
2020-09-11 15:07:12 +03:00
dustinface
1e835a629e
chainparams: Remove llmq_50_60 from regtest (#3696)
Its just not used anywhere so there is no point in starting the thread 
for it imo since it just spams the test logs with tries/failures.
2020-09-10 19:28:56 +03:00
dustinface
c7a9f47e42
qt: Update assets and colorize them theme related (#3574)
* qt: Replaced checkbox images with new ones

* qt: Replaced radiobutton images with new ones

* qt: Redefine arrow usage

- Removed "hover" arrows
- Rename normal -> light
- Rename pressed -> dark
- Use light as hover in dark theme and vice versa

* qt: Update icon set

* qt: Update sync spinner

* qt: Add new ThemedColor's

- ThemedColor::ORANGE
- ThemedColor::ICON_ALTERNATIVE_COLOR

* qt: Add GUIUtil::getIcon and GUIUtil::setIcon

* qt: Use themed icons where required

* qt: Make sure icons in SendCoinsEntry are updated on style changes

* qt: Make sure status bar icons are updated on style changes

* qt: Make sure icons in RPCConsole are updated on style changes

* qt: Remove icon/iconsSize in modaloverlaydialog.ui

* qt: Remove obsolete qproperty-iconSize entries from general.css

* qt: Use QToolButton's in SendVerifyMessageDialog and RPCConsole

Instead of QPushButton. This is to have the same alignment of the
iconized buttons by default like in SendCoinsEntry

* qt: Revert arrow icons

* qt: Revert HD icons
2020-09-10 19:28:05 +03:00
UdjinM6
d838ec0370
Implement Block Reward Reallocation (#3691)
* Implement Block Reward Reallocation

* Add integr. test

* drop unused variable

* Sep -> Oct

* Update test/functional/feature_block_reward_reallocation.py

Co-authored-by: PastaPastaPasta <6443210+PastaPastaPasta@users.noreply.github.com>

* Revert to Sep for testnet and devnet

* validation: Refactor reallocation calculations

Makes it much more readable imo and avoids calculating the percentage
each time.

* test: Align reallocation calculation with c++ (GetMasternodePayment)

* test: Make feature_block_reward_allocation.py executable

* Make linter happy

Co-authored-by: PastaPastaPasta <6443210+PastaPastaPasta@users.noreply.github.com>
Co-authored-by: xdustinface <xdustinfacex@gmail.com>
2020-09-10 19:23:11 +03:00
PastaPastaPasta
c2f56e08a8
remove /* continued */ where is is not needed
Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
2020-09-10 09:56:21 -04:00
Pasta
14fd2214af
fix lint failure
Signed-off-by: Pasta <pasta@dashboost.org>
2020-09-10 09:56:08 -04:00
UdjinM6
d711c2765b
Fix two potential issues in the way pending islocks are processed (#3678)
* Always check for previous quorum set in llmq IS

* Refactor SelectQuorumForSigning and related code

Should have no changes in behaviour

* Do not use SIGN_HEIGHT_OFFSET when checking pending IS locks, use actual chain tip

This commit actually changes the behaviour
2020-09-09 13:29:59 +03:00
UdjinM6
e8d5c8e19d More of 13153 (fix LogPrintf-s) -- TODO: backport to 0.16 2020-09-08 13:12:10 -05:00
dustinface
50d7a2fecf qt: Ignore GUIUtil::updateFont calls until GUIUtil::loadFonts was called (#3687) 2020-09-08 13:09:26 -05:00
dustinface
608f481a9c qt: Fix block update signals/slots in BitcoinGUI and SendCoinsDialog (#3685) 2020-09-08 13:09:00 -05:00
sc-9310
25e4fed75b QT: add last block hash to debug ui (#3672)
* [QT] Add last block hash to debug ui

Trivial addition to display last block hash next to last block time

* [QT] Make last block hash selectable

... and linter happy

Switch QMetaObject to get last hash from pIndex instead of clientmodel

* [Trivial] Fix trailing whitespaces
2020-09-08 13:08:26 -05:00
PastaPastaPasta
195dcad1ee trivial/docs: minor adjustments to PrivateSend help text (#3669)
Signed-off-by: pasta <pasta@dashboost.org>
2020-09-08 13:07:09 -05:00
dustinface
b1a35b2d32 Merge #13007: test: Fix dangling wallet pointer in vpwallets (#3666)
* test: Fix importwallet_rescan test

The wallet should be removed after the dumpwallet() call otherwise it 
may lead to unepexted behaviour in other wallet tests since the wallet 
stays in vpwallets then.

* tests: Change where RemoveWallet call is to be more in line with upstream

Signed-off-by: pasta <pasta@dashboost.org>

Co-authored-by: pasta <pasta@dashboost.org>
2020-09-08 13:03:08 -05:00
PastaPastaPasta
f9bf42cb90 Harden spork6 logic then remove spork6 (#3662)
* Harden Spork6

Spork6 was previously activated on testnet, but we then developed an alternative fix for the issue and never activated spork6 on mainnet. At this point, Spork6 will not be activated on mainnet.
As such, it makes sense to harden Spork6 and ensure that spork6 will never be activated on mainnet. So, we just change from checking Spork6 to checking if we are on testnet. If we are on testnet, use spork6 logic, else don't.

Signed-off-by: pasta <pasta@dashboost.org>

* remove now unused SPORK_6_NEW_SIGS

Signed-off-by: pasta <pasta@dashboost.org>

* force fSporkSixActive to be correct, otherwise return

Signed-off-by: pasta <pasta@dashboost.org>

* Harden spork6 even more

* Add TODO in chainparams as a reminder to drop all spork6 related code on next testnet reset

Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
2020-09-08 13:02:16 -05:00
UdjinM6
604d6a4225 Fix some translation issues (#3656)
* Avoid translating "PrivateSend"

* Make some strings translatable
2020-09-08 12:57:05 -05:00
UdjinM6
60d298376b Fix crash on splash screen when wallet fails to load (#3629) 2020-09-08 12:55:15 -05:00
dustinface
ca76dd0868 qt: Give PrivateSend separate instances of SendCoinsDialog + CCoinControl (#3625)
Prior to this commit there are (imo) flaws in the behaviour of the PrivateSend tab.

- If you enter an address, label, add a recipient, do whatever in the normal Send tab its also reflected in
the PrivateSend tab
- If you select fully mixed coins in the Send tab's CoinControl they are also selected
in the PrivateSend tab if you switch over.
- If you select non-fully mixed coins in the Send tab's CoinControl you
get a warning when switching over to PrivateSend tab due to non-fully
mixed coins selected in CoinControl.

With giving the private send tab separate instances of `SendCoinsDialog` and `CCoinControl` they are independent
from each other which just makes more sense imo and by doing this the points above are solved.

I would say this just better reflects the actual behaviour of a tab.
2020-09-08 12:52:09 -05:00
dustinface
13de970063
masternode|rpc: Remove unused code (#3689) 2020-09-08 13:02:50 +03:00
dustinface
3f8d27dc41
qt: Ignore GUIUtil::updateFont calls until GUIUtil::loadFonts was called (#3687) 2020-09-08 12:55:38 +03:00
dustinface
a719c49bfa
qt: Fix block update signals/slots in BitcoinGUI and SendCoinsDialog (#3685) 2020-09-08 12:54:49 +03:00
dustinface
c207e0c953
test: Implement unit tests for CTransactionBuilder (#3677)
* makefile.test.include: Let privatesend_tests.cpp depend on ENABLE_WALLET

* test: Implement unit tests for CTransactionBuilder

* Check that we can decrease the amount and GetAmountLeft() is updated accordingly

* Check if resulting tx has a change output when expected

* Avoid pushing nullptr into vecOutputs

* Add few notes about size calculations

* nit: better readability (imo)

Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
2020-09-05 00:25:16 +03:00
dustinface
45103780f7
test: Implement unit tests for CWallet::CreateTransaction (#3667)
* test: Implement unit tests for CWallet::CreateTransaction

* test: Reset minRelayTxFee in CreateTransactionTest

At this point its modified from an other test when running all unit 
tests which lets this test fail unexpectedly.

* test: Lock cs_main/cs_wallet when required in CreateTransactionTest

* test: Add new test in CreateTransactionTest

Test if the wallet creation fails properly with the correct error
messages.

* test: Fixed expected test results for some CreateTransactionTest cases

* test: Fail if CreateTransaction runs into "Exceed max tries" case

* test: Adjust last return in CreateTransaction

* test: Drop dust tests
2020-09-05 00:24:41 +03:00
UdjinM6
09cd844785
Merge pull request #3684 from xdustinface/backport-ui-redesign
qt: Backport UI redesign to v0.16.x
2020-09-05 00:24:14 +03:00
dustinface
5c3f3e635a
wallet: Fix and improve CWallet::CreateTransaction (#3668)
* wallet: Remove unused vecTxDSInTmp in CWallet::CreateTransaction

* wallet: Calculate fees earlier and respect them in change determination

* wallet: Cleanup obsolete code in CreateTransaction

This parts were needed before when the fee was calculated after the
change was assigned. But now with the previous commit the fee is
calculated upfront and respected properly from the begining. So there is
no longer a need of increasing or decreasing the change depending on the
fee as it has the correct value directly after its added.

* wallet: Try to pick other inputs if the selected ones are too small

If nChange is negative in this cases it means that the selected inputs
can't cover the amount to send and the required transaction fee. So we
just add the missing amount to nFeeRet. This leads to the algo
trying to pick larger inputs in the next loop (with nFeeRet more duffs
than in the previous loop). This process gets repeated until the selected
amount is enough to cover all the costs or until the requested amount
can't be selected anymore (not enough utxos to cover it).

* wallet: Break the loop if the transaction is ready

* wallet: Respect additional amount from previous cycles

* wallet: Respect available in coin selection, try all coins in last round

* wallet: Avoid potential infinite loop, just in case..

* wallet: Fix signing in CreateTransaction

Prior it was messed because of 60d96a1a28b55f071c6144f248e136679c44337e. 
Set coins isn't sorted the same way as txNew.vin is so it sometimes may 
pick wrong coins for signing the input.

* wallet: Fix change calculation if "subtract fee from amount" is enabled

* wallet: Return after fee calc if no or not enough amount available

Return the proper fail reason. Prior to this commit it run into
"Exceeded max tried".

Note: Only return if not enough amount is available if we can't subtract
fee from amount.

* wallet: Fix break logic if available amount is not enough

* Revert "wallet: Fix signing in CreateTransaction"

This reverts commit 5fcdc0f00e7b961ebb62c94d17d585537e911309.

* Use a vector of coins instead of a set in CreateTransaction and sort it in a BIP69 compliant way when needed

* wallet: Adjust comment

* Cleaner usage of nChangePosRequest/InOut

* Simplify some fail/try-again conditions (fixed)

* Loop through outputs to update change output position only when outputs are sorted for BIP69

No need to do this for non-bip69 cases (i.e. when a specific change output position was requested and assigned)

* Avoid implicit conversions of int-s into bool-s

* Move `nAmountLeft == nFeeRet` check higher, tweak comments

* wallet: Fix some formatting

* wallet: Improve CTxIn creation in CreateTransaction

Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
2020-09-04 15:00:55 +03:00
dustinface
0969c2d268 qt: Splashscreen redesign (#3613)
* qt: Splashscreen redesign

- Make it theme related dark or light
- Fixes bluriness issues
- Fixes issues with overlapping init messages at the bottom of the
splashscreen
- Give it a cleaner look -> Removed copyrights and prefix `Version v` of the version string

* Do not rotate colors of the splash image

* Adjust logo color based on the current theme for all networks

* Draw network-specific text as a "badge" with a network-specific color

* Introduce `NetworkStyle::rotateColor()` helper

* Introduce badge color in NetworkStyle and use it in SplashScreen's ctor

Replaces the getTrayAndWindowIcon hack

* refactor loops

Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
2020-09-04 01:33:14 +02:00
dustinface
966be38c79 qt: Make sure stylesheet updates of -debug-ui are activated (#3623)
This reverses force logic of `GUIUtil::loadTheme` to not force by default and instead forces it explicit in appearance widgets call.

Due to `fForce` beeing default the ui debug timer wasn't started properly because there was no call of `GUIUtil::loadStylesheet` without `fForce=true` which is a requirement to start the debug timer.
2020-09-04 01:33:14 +02:00
dustinface
0ed7f1672c qt: Add missing placeholders (#3575)
* qt: Add more placeholder in ReceiveCoinsDialog

* qt: Add placeholder for filter line edit in MasternodeList

* qt: Add more placerholder in SignVerifyMessageDialog

* qt: Removes a dot

* qt: Adjust placeholder phrasing in ReceiveCoinsDialog

* Apply suggestions from code review

* qt: Align wording of placeholders with the corresponding tooltip
2020-09-04 01:33:02 +02:00
dustinface
103fda2cb7 qt: Fix appearancewidget.h to make lint-include-guards.sh happy (#3627) 2020-09-01 18:46:29 +02:00
dustinface
2cc36dffde qt: Drop PlatformStyle (#3573)
* qt: Add PlatformStyle::Icon + only show icons on menu if enabled

Now icons are disabled everywhere if imagesOnButtons is disabled. There were still buttons on each menu item.

* qt: Disable all PlatformStyle related changes

* qt: Drop PlatformStyle
2020-09-01 18:46:29 +02:00
dustinface
b073ae9853 qt: Redesign scrollbar styles (#3571)
* qt: Add platform specific css style for scrollbars

This disabled scrollbars.css loading and adds a "windows,other" section in general.css, dark.css and light.css where it adds customizations for scrollbars in each theme.

* qt: Remove scrollbar.css and all its remaining mentions

* qt: Run update-css-files.py
2020-09-01 18:46:29 +02:00
dustinface
1a2867f886 qt: Introduce appearance tab and setup dialog (#3568)
* qt: Add "Appearance Tab" to OptionsDialog and move "Theme" into it

* qt: Add "Font scale" settings to Appearance Tab of OptionsDialog

Allows to scale the font in the same way like with -font-scale.

* qt: Add font weight settings to Appearance tab of OptionsDialog

Allows to set the weight for normal and bold text

* qt: Add font family setting to Appearance tab of OptionsDialog

Allows to choose between system default font or montserrat

* qt: GUIUtil - Maintain a map with supported weights for all fonts.

* qt: Introduce AppearanceWidget

A widget which just wraps all appearance related settings.

Also replaces Appearance settings in OptionsDialog with the introduced widget.

* qt: Introduce initial appearance setup dialog

This will pop up the first time the user starts the DashCore version with the new UI changes.

* qt: Load font related settings in GUIUtil::loadFonts

* qt: Make osDefaultFont global in GUIUtil to fix getFont()

Before getFont(FontFamily, ...) wasn't always able to return the correct font without the requested font family beeing set as application font upfront.

* qt: Improve supported weight helpers

Add conversion helpers. and let all of them depend on the currently selected font.

* qt: Default weights based on supported if not all weights are supported

For SystemDefault only because Montserrat has all supported weights.

* qt/test: Fix GUI tests

* Store normal/bold font GUI settings as "pure" (not "supported") values

* Rename supportedWeighti(To/From)Arg to supportedWeight(To/From)Index to better match the logic and avoid confusion with weight(To/From)Arg functions

Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
2020-09-01 18:46:29 +02:00
dustinface
d44611bc2b qt: General qt/c++ related fixes and updates (#3562)
* qt: Draw a border around net traffic graph

* qt: ReceiveRequestDialog - Improve QR code image

- Fix issue with bluriness
- Refine sizing/layout of QR code and address
- Adjust coloring to match the themes

* qt: Give the TransactionView's instantsendWidget a name

Required to access it in css

* qt: Rename conflicting label in SendCoinsDialog

- Was named the same as the the label in EditAddressDialog so it couldn't be accessed properly in css

* qt: Give the TransactionView's search field the first focus on startup

* qt: Some updates to the PrivateSend widget on the OverviewPage

- Hide denom labels if inactive
- Enable wordwrap for denom label
- Add some spacer
- Make sure it gets its basic initialization on startup

* qt: Fix some layout issues in SendCoinsDialog's UI file.

- Added some margins for fee selection radio buttons to align them centered to their options
- Removed a weird placed spacer

* qt: Fix vertical alignment of the two balance labels in SendCoinsDialog

* qt: Add newline in textedit of receiverequest

* qt: OptionsDialog - Hide override hint if there is nothing overridden

* qt: Allow stylesheet modifications for auto completition popup

- Inheritance doesn't work here obviously because of QCompleter is parent of the popup
- QStyledItemDelegate delegate is required. Without its not possible to access `::item` selectors from css.

* qt: Make the progress label in the status bar accessible in css

* qt: Update weekend colors of QCalendarWidget on style changes

Its obviously not possible to do this in stylesheets thats why i added
this as workaround.

* qt: Load stylesheets for Intro

This is the datadir selection dialog.

* Drop labelPrivateSendLastMessage

* Add a space

Co-authored-by: PastaPastaPasta <6443210+PastaPastaPasta@users.noreply.github.com>

Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
Co-authored-by: PastaPastaPasta <6443210+PastaPastaPasta@users.noreply.github.com>
2020-09-01 18:46:28 +02:00
dustinface
d22ab43910 qt: Introduce platform specific css sections (#3570)
* qt: Add platform specific css loading to GUIUtil::loadStyleSheet

This commit leads to GUIUtil::loadStyleSheet treating css code between
<os="<os_list>"> and </os> different. It will only become added for
operating systems provided in the list of the sections start tag.

There may be multiple entries per section. Possible entries:

- macosx
- windows
- other

<os_list> must be a combination of the three options above separated by
comma like in "windows,macosx".

Its ok to have multiple <os="...">...</os> sections in a file with
arbitrary OS combinations. They will all become added to the end of the
file though. Means even putting an <os> section in the top of the file
would become appended to the end of the file during loading which should
be kept in mind when adding sections to avoid unexpected overwriting.

Example
------------------------------------------------------------------------

<os="macosx, windows, other">

/* Example section to add styles for all operating systems
   Remove any to exclude it.
*/

</os>

* Respect `-uiplatform` when matching for os-specific styles

* Format osStyleExp to make it a bit easier to see groups

Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
2020-09-01 18:46:28 +02:00
dustinface
a16cfa77de qt: Redesign BitcoinAmountField (#3569)
* qt: Remove min-width of BitcoinAmountField in ReceiveCoinsDialog

* qt: Add BitcoinUnits::data(const int &row, int role)

Make its data also accessible int, not only by QModelIndex.

* qt: Adjust BitcoinAmountField

- AmountSpinBox (QAbstractBox) is now called AmountLineEdit (QLineEdit)
- Replaced the AmountSpinBox and the QValueComboBox with just an AmountLineEdit
- Adjusted min-size hint calculation
- Increased maximum width
- Right-Align text
- Removed obsolete code

* qt: Removed leftover from legacy BitcoinAmountField

* qt: Move amount field into a Hlayout with a spacer (ReveiveCoinsDialog)

Make sure it does not get stretched above the in AmountLineEdit::minimumSizeHint() calculated size.

* qt: Removed obsolete workaround related to BitcoinAmountField

Its fixed now with the change to a normal line edit.
2020-09-01 18:46:28 +02:00