Commit Graph

18685 Commits

Author SHA1 Message Date
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
dustinface
7db9909a17 qt: Introduce runtime theme changes (#3559)
* qt: Set the default theme properly

* qt: Keep track of disabled rects for macOS

This allows enabling them again on theme changes

* qt: Introduce runtime theme changes

Runtime theme changes means no more client restart required if the
theme gets changed in the options dialog.

In the RPCConsole's StyleChange event make sure following things are still correct after a runtime theme change:
- Hide prompt icon for dash themes in rpc console if dash theme gets
activated.
- Clear rpc console on theme changes to make sure fonts/sizes/colors are correct.
2020-09-01 18:46:28 +02:00
dustinface
b3738648d6 qt: General CSS related redesigns (#3563)
* qt: User border-image in place of image

For some reason image produced weird outputs on some resolution screens.

* qt: Fix layout issues in TransactionView

* qt: Fix layout issues in OverviewPage

* qt: Replace transparent with #00000000 in stylesheets

* qt: Use #a84832 as red where possible.

This includes css files and any color usage in code.

* qt: Finetune QPushButton style

* qt: Customized QSlider (used in the Debug window -> NetworkTraffic)

* qt: Finetune QToolbar style

* qt: Customized QProgressBar

* qt: Customized QCalendarWidget

* qt: Finetune QStatusBar style

- Give the progress label a name as css reference
- Set min height and margins

* qt: Finetune QMenu style

- Set a light rounded border
- Color for disabled items
- Color/Style for seperator
- Give the items padding

* qt: Customized QGroupBox

* qt: Customized QToolTip

* qt: Give inputs widgets a proper hover/focus/selected/disabled style

* qt: Finetune SendCoinsDialog

- Add light line below the coincontrol frame
- Add light line above fee frame
- Increase header font size
- Remove button layout changes of CoinControl button
- Fix Layout/Alignment of balance labels

* qt: Customized RPC console's autocompletition popup

* qt: Add stylesheets to Intro

This is the datadir selection dialog.

* qt: OptionsDialog - Give the reset button the "light button" style

* qt: Finetune shared styles in general.css

* qt: Finetune coloring in dark.css

* qt: Finetune coloring in light.css

* More fixes for traditional.css

No text colors, s/transparent/#00000000/

* qt: Run update-css-files.py

Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
2020-09-01 18:46:28 +02:00
dustinface
1dea248d0d qt: Make use of GUIUtil themed colors/styles (#3561)
* qt: Update theme colors in GUIUtil

- Adds ThemedColor::GREEN
- Changes ThemedColor::NEGATIVE to ThemedColor::RED
- Color adjustments to align with css colors

* qt: Give links a more eye friendly blue

* qt: Use themed colors in net traffic graph

* qt: Use themed styles/color in overview page

* qt: Use themed stylesheets in Intro

* qt: Modified QR code image painting to match the theme colors
2020-09-01 18:46:28 +02:00
dustinface
06d69d74c2 qt: Replace usage of QTabBar with custom replacement (#3560)
* qt: OptionsDialog - Replaced QTabBar with QStackedWidget

This allows to stretch the buttons in the dialog window.

* qt: RPCConsole - Replaced QTabBar with QStackedWidget

This allows to stretch the buttons in the dialog window.

* qt: SignVerifyMessageDialog - Replaced QTabBar with QStackedWidget

This allows to stretch the buttons in the dialog window.

* qt: Add styles for tabbar replacement buttons
2020-09-01 18:46:28 +02:00
dustinface
edfc3a4646 qt: Call GUIUtil::loadFonts earlier (#3593)
* qt: Call GUIUtil::loadFonts earlier.

Before there is any usage of the font helpers.

* Apply review suggestion

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

Co-authored-by: PastaPastaPasta <6443210+PastaPastaPasta@users.noreply.github.com>
2020-09-01 18:46:28 +02:00
dustinface
f371e4771c qt: Add -debug-ui command line parameter (#3558)
* qt: Set parents properly to inherit css and remove redundant loading

The stylesheet is inherited from the parent so its enough to set it for the main window and use this as parent for all other windows.

Except for the ShutdownDialog. This needs to have its own stylesheet set because we can't have the main window as parent of the ShutdownDialog.

* qt: Adding Qt::Window flag to the constructor of RPCConsole

This is required now as RPCConsole does not longer show as extra window with a parent set (For stylesheet inheritance).

* qt: Add UI debug mode (-debug-ui)

If this mode is enabled the content of the css files will become pushed to the UI if there were any changes made to the stylesheet files in the custom css directory. It also forces some UI elements to show up which are actually only shown under special conditions (e.g. watch balance labels). Its required to set a custom css directory with -custom-css-dir to enable this.

* qt: Adjust the description of -debug-ui
2020-09-01 18:46:28 +02:00
dustinface
dde4ab5f84 qt: Add -custom-css-dir commmand line parameter (#3557)
* qt: Change themes path from ":themes" to ":css"

Required for the introduction of a custom css directory which will
happen with the follow-up commits.

* qt: Renamed trad.css to traditional.css

* qt: Add -custom-css-dir startup parameter

This allows to load a custom directory as css directory.

The custom directory currently needs to have the files:

- general.css
- dark.css
- light.css
- traditional.css
- scrollbars.css
2020-09-01 18:46:28 +02:00
dustinface
067622764c qt: Disable macOS system focus rectangles for dash themes (#3556)
* qt: Disable macOS system focus rectangles for dash themes

The focus rects drawn by macOS are in the color the user selected in the
OS settings as selection color. This just doesn't always fit into the coloring of the dash specific themes.

* Apply review suggestion

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

Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
2020-09-01 18:46:28 +02:00
UdjinM6
d296cbdca1 Merge pull request #3555 from xdustinface/pr-ui-2-fonts
qt: Implement application wide font management
2020-09-01 18:46:28 +02:00
dustinface
b409254587 qt: Redesign of the main toolbar (#3554)
* qt: Replaced QAction with QToolButton for BitcoinGUI toolbar buttons.

This allows setting a size policy for the toolbar buttons so that
they are stretched over the toolbar and resize on window size changes.

* qt: Give the BitcoinGUI's toolbar more style

* qt: Give the toolbar logo a higher resolution

This also removes the blue logo because its not longer used.

* qt: Restore the traditional themes toolbar previous styles and logo
2020-09-01 18:46:28 +02:00
dustinface
c5fcc811d6 qt: Generalized css files, simple design changes, added scripts to keep track of color usage (#3508)
* qt: Send tab - Generalized related CSS and some redesign

- Removed grey boxes around labels of SendCoinEntry
- Changed button styles for add/clear button
- Removed padding for send button

* qt: Overview tab - Generalized related CSS and some redesign

- Removed grey boxes around balance labels

* qt: Receive tab & QPushButton - Generalized related CSS and some redesign

- Removed grey boxes around "Label", "Amount", "Message" and "Requested
payment history" labels and increased their textsize
- Changed the color of the "Requested payment history" label
- Adjusted the style of the "Clear", "Remove" and "Show" buttons

* qt: Transaction tab - Generalized related CSS and some redesign

- Increased size of selected sum labels

* qt: Masternode tab - Generalized related CSS and some redesign

- Increased the size of the "Filter list" and "Node count" labels

* qt: CoinControl dialog - Generalized related CSS and some redesign

- Removed alternated coloring

* qt: Sync overlay - Generalized related CSS and some redesign

- Adjusted colors
- Added rounded border

* qt: About dialog - Generalized related CSS

* qt: Edit address dialog - Generalized related CSS

* qt: Help message dialog - Generalized related CSS

* qt: RPC console  - Generalized related CSS and some redesign

- Changed colors for network activity legend (signal colors TBD in a
code change commit)

* qt: Options dialog - Generalized related CSS

* qt: Ask passphrase dialog - Generalized related CSS

* qt: Addressbook page - Generalized related CSS

* qt: Sign/Verify dialog - Generalized related CSS

* qt: Open URI dialog - Generalized related CSS

* qt: Generalized remaining individual Qt classes

* qt: Fixed indentation in css files

* qt: Use newlines for multiple selector entries

* qt: Formal cleanups in all css files

* qt: Add copyright and file description to all css files

* qt: Add update_colors.py, prepare css files for scripted color updates

- update_colors.py is a python script which parses the css files and prints some
details about their color usage into appropriate files in the css/colors directory. It also
updates the <colors></colors> section for each css file.
- Added <colors></colors> section to css files for automated color updates by update_colors.py

* qt/contrib: Moved update_colors.py to update-css-files.py 

This also moves the file from src/qt/res/css to contrib/devtools

* build: Remove files in src/qt/res/css/colors when running "make clean"

* git: Add src/qt/res/css/colors/* to gitignore and remove the files from the repo

* path -> css_folder_path

* Resolve path and fail early

* Create 'colors/' if it doesn't exist and fail if smth went wrong

* Run git after all filesystem preparations are done

* qt: Fix background-color of bgWidget in trad.css

Its #AARRGGBB not #RRGGBBAA!

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

* qt: Run update_colors.py

* contrib: Use case insensitive regex for color matching

* qt: Update colors in css files

* contrib: Remove obsolete import in update-css-files.py

Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
2020-09-01 18:46:28 +02:00
UdjinM6
d42877998e
Merge pull request #3670 from PastaPastaPasta/more-v16-backports
[v0.16.x] Backport pending PRs
2020-09-01 18:28:25 +03:00
dustinface
a206af443d
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-01 18:27:33 +03:00
UdjinM6
62551a220a
ci: Add workflow:rules to fix Gitlab warnings (#3679) 2020-08-30 17:24:26 +03:00
sc-9310
c8ef16a6d6
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-08-30 17:24:05 +03:00
PastaPastaPasta
e8e34b836a
docs: Adjust developer-notes.md to use signed ints normally (#3663)
* Adjust developer-notes.md to use signed ints normally

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

* Adjust wording in dev-notes

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

* remove trailing whitespace

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

* Remove trailing whitespace

* maybe fix linter

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

Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
2020-08-30 17:22:51 +03:00
PastaPastaPasta
8baf69d448
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-08-30 17:22:21 +03:00
PastaPastaPasta
533b2fe9f1
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-08-30 17:21:45 +03:00
PastaPastaPasta
404014d31a
change argument name to reflect the fact that it's a return value (#3673)
Signed-off-by: pasta <pasta@dashboost.org>
2020-08-27 12:51:31 +03:00
PastaPastaPasta
e75c18a60b
trivial/docs: minor adjustments to PrivateSend help text (#3669)
Signed-off-by: pasta <pasta@dashboost.org>
2020-08-24 18:17:13 +03:00
dustinface
997e79439b
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-08-24 18:16:42 +03:00
PastaPastaPasta
91724d29e6
trivial: clang-tidy changes in privatesend (#3665)
Signed-off-by: pasta <pasta@dashboost.org>
2020-08-24 18:15:57 +03:00
PastaPastaPasta
28b7395ec5
trivial: don't mix unsigned int with int (#3664)
Signed-off-by: pasta <pasta@dashboost.org>
2020-08-24 18:15:29 +03:00
PastaPastaPasta
7c4e5122cf
trivial: return bool instead of int in CPrivateSendClientOptions (#3660)
Signed-off-by: pasta <pasta@dashboost.org>
2020-08-24 18:15:05 +03:00
PastaPastaPasta
0dc2017248
trivial: don't compare pointer to zero (#3659)
Signed-off-by: pasta <pasta@dashboost.org>
2020-08-24 18:14:41 +03:00
UdjinM6
8aeeb97995
Print exception origin in crash messages (#3653)
* Print exception origin in crash messages

We use `PrintExceptionContinue` in many places and we pass crash origin to it as a param but we never use it. Also, change the param name to better match its meaning.

* Update src/util.cpp

Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com>

Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com>
2020-08-23 11:54:37 -05:00
UdjinM6
bd5c047e28
Implement a safer version of GetCrashInfoFromException (#3652)
* Implement a safer version of GetCrashInfoFromException

`abi::__cxa_current_exception_type()` can return `null`, handle this properly

* Update src/stacktraces.cpp

Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com>

* Update src/stacktraces.cpp

Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com>

Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com>
2020-08-23 11:54:10 -05:00
dustinface
4414b5c3c7
llmq: Fix spork check in CSigSharesManager::ForceReAnnouncement (#3650)
It seems like the idea here was to avoid announcing already available sigshares for a signhash to everyone if concentrated recovery is enabled. But by returning there if `IsAllMembersConnectedEnabled` equals to `false` we disable the re-announcements prior to the spork activation, where we want to still have them and re-enable if the spork is enabled where we don't want to have them.
2020-08-23 11:53:45 -05:00
Akshay CM
c232f2a12d
[RPC] Show address of fundDest when no funds (#3649) 2020-08-23 11:53:30 -05:00
UdjinM6
abe3d578b2
Include protocol version into MNAUTH (#3631)
* Include protocol version into MNAUTH

* Introduce MNAUTH_NODE_VER_VERSION = 70218
2020-08-23 11:52:22 -05:00
CryptoTeller
4db8968d4a
rpc: update help text for BLS operator key arguments (#3628)
* Update rpcevo.cpp

I would like to mirror docs.dash.org/en/stable/masternodes/maintenance.html#proupservtx by adding the specific term "BLS" to the rpc help menu to differentiate this is not a dash address key like the other ownerkey votingkey. We had this changed on the docs site to help clarify for people who were missing the point this was the operator BLS key.

* Update rpcevo.cpp
2020-08-23 11:50:58 -05:00
dustinface
bbb0064b60
init: Fix crash due to -litemode and improve its deprecation warning (#3626)
* init: Fix `-litemode` crash due to not connected CClientUIInterface signal

Prior to this commit the signal
`CClientUIInterface::ThreadSafeMessageBox` is not connected to a slot in
Qt at the time its emitted when `-litemode` is used. The signal gets
emitted from `InitWarning`, in `InitParameterInteraction`. This happens
currently before `BitcoinGUI` gets created by
`app.createWindow(networkStyle.data())` in `dash.cpp` where the
signal becomes connected to the slot. After this commit the litemode
`InitWarning` will be called in `AppInitParameterInteraction` which runs
after `BitcoinGUI` has been created, means the signal will be connected
then at that point and the crash is fixed.

* init: Improve -litemode deprecation warning

- Always show a basic warning if `-litemode` gets used no matter if its
activated or not.
- Let the user know when -disablegovernance gets forced by -litemode.
2020-08-23 11:50:30 -05:00
UdjinM6
8d99e7836c
Fix -resetguisettings (#3624) 2020-08-23 11:49:09 -05:00
PastaPastaPasta
508fc2db4b
privatesend: Increase max participants to 20 (#3610)
* Add spork to change max mixing participants to 20

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

* Also change min participants on devnet/testnet

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

* adjust formatting

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

* add nPoolNewMinParticipants under regtest

Signed-off-by: pasta <pasta@dashboost.org>
2020-08-23 11:48:17 -05:00
dustinface
f425316eed
util: Change TraceThread's "name" type: "const char*" -> "const std::string" (#3609)
Having "const char*" leads to undefined behaviour if the "const char*"
is deallocated before the thread used it.

Co-Authored-By: UdjinM6 <UdjinM6@users.noreply.github.com>

Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
2020-08-23 11:47:47 -05:00
Alexander Block
a170c649b8
Fail GetTransaction when the block from txindex is not in mapBlockIndex (#3606)
This indicates a previous crash where the TX made it into the txindex but
the block was not flushed to disk. When dashd is restarted then, there is
a short time where GetTransaction would return a non-existant block, while
callers very often assume that the returned block hash is known.
2020-08-23 11:47:27 -05:00
dustinface
62c3fb5748
llmq: Fix thread handling in CDKGSessionManager and CDKGSessionHandler (#3601)
* llqm: Fix thread handling in CDKGSessionManager and CDKGSessionHandler

* llmq: Removed unused thread_pool from CDKGSessionManager

* Tweak `CDKGSessionHandler::StartThread()`

* llmq: Simplify CDKGSessionHandler's thread naming

* llmq: Make sure CDKGSessionHandler uses a valid LLMQ type

Co-Authored-By: UdjinM6 <UdjinM6@users.noreply.github.com>

Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
2020-08-23 11:46:58 -05:00
dustinface
aa3bec6106
evo: Avoid some unnecessary copying in BuildNewListFromBlock (#3594) 2020-08-23 11:46:27 -05:00
PastaPastaPasta
6a249f59b6
Merge #13564: [wallet] loadwallet shouldn't create new wallets. (#3592)
ea65182f03 [wallet] loadwallet shouldn't create new wallets. (John Newbery)

Pull request description:

  A bug in the initial implementation of loadwallet meant that if the
  arguement was a directory that didn't contain a wallet.dat file, a new
  wallet would be created in that directory. Fix that so that if a
  directory is passed in, it must contain a wallet.dat file.

  Bug reported by promag (João Barbosa).

Tree-SHA512: 0a59fa8a33fde51a88544ad288b00e4995284fe16424f643076aaba42b8244fff362145217650ee53d518dfab7efbed4237632c34cdd3dcbbecaa9ecaab5fd7b

Co-authored-by: MarcoFalke <falke.marco@gmail.com>
2020-08-23 11:46:10 -05:00