From 298a7714943dc3f1ebc582ed2426d3b71fb68466 Mon Sep 17 00:00:00 2001 From: s_nakamoto Date: Sun, 21 Nov 2010 22:46:19 +0000 Subject: [PATCH] added transaction fee setting in UI options menu, cut free transaction area from 50KB to 26KB git-svn-id: https://bitcoin.svn.sourceforge.net/svnroot/bitcoin/trunk@187 1a98c847-1fd6-4fd8-948a-caf3550aa51b --- db.cpp | 8 -- main.h | 21 +-- serialize.h | 2 +- uibase.cpp | 45 +++---- uibase.h | 15 ++- uiproject.fbp | 352 ++++++++++++++++++++++++++------------------------ 6 files changed, 224 insertions(+), 219 deletions(-) diff --git a/db.cpp b/db.cpp index 84b294c3..35da1705 100644 --- a/db.cpp +++ b/db.cpp @@ -702,14 +702,6 @@ bool CWalletDB::LoadWallet() printf("addrProxy = %s\n", addrProxy.ToString().c_str()); - // The transaction fee setting won't be needed for many years to come. - // Setting it to zero here in case they set it to something in an earlier version. - if (nTransactionFee != 0) - { - nTransactionFee = 0; - WriteSetting("nTransactionFee", nTransactionFee); - } - // Upgrade if (nFileVersion < VERSION) { diff --git a/main.h b/main.h index cc150e62..7d1145b5 100644 --- a/main.h +++ b/main.h @@ -537,14 +537,19 @@ public: if (fAllowFree) { - // Transactions under 25K are free as long as block size is under 40K - // (about 11,000bc if made of 50bc inputs) - if (nBytes < 25000 && nNewBlockSize < 40000) - nMinFee = 0; - - // Transactions under 3K are free as long as block size is under 50K - if (nBytes < 3000 && nNewBlockSize < 50000) - nMinFee = 0; + if (nBlockSize == 1) + { + // Transactions under 10K are free + // (about 4500bc if made of 50bc inputs) + if (nBytes < 10000) + nMinFee = 0; + } + else + { + // Free transaction area + if (nNewBlockSize < 27000) + nMinFee = 0; + } } // To limit dust spam, require a 0.01 fee if any output is less than 0.01 diff --git a/serialize.h b/serialize.h index e0b83aca..05d73030 100644 --- a/serialize.h +++ b/serialize.h @@ -22,7 +22,7 @@ class CDataStream; class CAutoFile; static const unsigned int MAX_SIZE = 0x02000000; -static const int VERSION = 31504; +static const int VERSION = 31505; static const char* pszSubVer = ""; diff --git a/uibase.cpp b/uibase.cpp index 9ce5093e..7c889818 100644 --- a/uibase.cpp +++ b/uibase.cpp @@ -352,28 +352,6 @@ COptionsDialogBase::COptionsDialogBase( wxWindow* parent, wxWindowID id, const w bSizer69->Add( 0, 16, 0, wxEXPAND, 5 ); - m_staticText32 = new wxStaticText( m_panelMain, wxID_ANY, _("Optional transaction fee you give to the nodes that process your transactions."), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticText32->Wrap( -1 ); - m_staticText32->Hide(); - - bSizer69->Add( m_staticText32, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); - - wxBoxSizer* bSizer56; - bSizer56 = new wxBoxSizer( wxHORIZONTAL ); - - m_staticText31 = new wxStaticText( m_panelMain, wxID_ANY, _("Transaction fee:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticText31->Wrap( -1 ); - m_staticText31->Hide(); - - bSizer56->Add( m_staticText31, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT, 5 ); - - m_textCtrlTransactionFee = new wxTextCtrl( m_panelMain, wxID_TRANSACTIONFEE, wxEmptyString, wxDefaultPosition, wxSize( 70,-1 ), 0 ); - m_textCtrlTransactionFee->Hide(); - - bSizer56->Add( m_textCtrlTransactionFee, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); - - bSizer69->Add( bSizer56, 0, wxEXPAND, 5 ); - wxBoxSizer* bSizer71; bSizer71 = new wxBoxSizer( wxHORIZONTAL ); @@ -435,6 +413,25 @@ COptionsDialogBase::COptionsDialogBase( wxWindow* parent, wxWindowID id, const w bSizer69->Add( bSizer103, 1, wxEXPAND, 5 ); + + bSizer69->Add( 0, 1, 0, 0, 5 ); + + m_staticText32 = new wxStaticText( m_panelMain, wxID_ANY, _("Optional transaction fee per KB that helps make sure your transactions are processed quickly. Most transactions are 1KB. Fee 0.01 recommended."), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText32->Wrap( 365 ); + bSizer69->Add( m_staticText32, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT, 5 ); + + wxBoxSizer* bSizer56; + bSizer56 = new wxBoxSizer( wxHORIZONTAL ); + + m_staticText31 = new wxStaticText( m_panelMain, wxID_ANY, _("Pay transaction fee:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText31->Wrap( -1 ); + bSizer56->Add( m_staticText31, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT, 5 ); + + m_textCtrlTransactionFee = new wxTextCtrl( m_panelMain, wxID_TRANSACTIONFEE, wxEmptyString, wxDefaultPosition, wxSize( 70,-1 ), 0 ); + bSizer56->Add( m_textCtrlTransactionFee, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); + + bSizer69->Add( bSizer56, 0, wxEXPAND, 5 ); + m_panelMain->SetSizer( bSizer69 ); m_panelMain->Layout(); bSizer69->Fit( m_panelMain ); @@ -486,12 +483,12 @@ COptionsDialogBase::COptionsDialogBase( wxWindow* parent, wxWindowID id, const w // Connect Events m_listBox->Connect( wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler( COptionsDialogBase::OnListBox ), NULL, this ); - m_textCtrlTransactionFee->Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler( COptionsDialogBase::OnKillFocusTransactionFee ), NULL, this ); m_checkBoxLimitProcessors->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( COptionsDialogBase::OnCheckBoxLimitProcessors ), NULL, this ); m_checkBoxMinimizeToTray->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( COptionsDialogBase::OnCheckBoxMinimizeToTray ), NULL, this ); m_checkBoxUseProxy->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( COptionsDialogBase::OnCheckBoxUseProxy ), NULL, this ); m_textCtrlProxyIP->Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler( COptionsDialogBase::OnKillFocusProxy ), NULL, this ); m_textCtrlProxyPort->Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler( COptionsDialogBase::OnKillFocusProxy ), NULL, this ); + m_textCtrlTransactionFee->Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler( COptionsDialogBase::OnKillFocusTransactionFee ), NULL, this ); m_buttonOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( COptionsDialogBase::OnButtonOK ), NULL, this ); m_buttonCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( COptionsDialogBase::OnButtonCancel ), NULL, this ); m_buttonApply->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( COptionsDialogBase::OnButtonApply ), NULL, this ); @@ -501,12 +498,12 @@ COptionsDialogBase::~COptionsDialogBase() { // Disconnect Events m_listBox->Disconnect( wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler( COptionsDialogBase::OnListBox ), NULL, this ); - m_textCtrlTransactionFee->Disconnect( wxEVT_KILL_FOCUS, wxFocusEventHandler( COptionsDialogBase::OnKillFocusTransactionFee ), NULL, this ); m_checkBoxLimitProcessors->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( COptionsDialogBase::OnCheckBoxLimitProcessors ), NULL, this ); m_checkBoxMinimizeToTray->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( COptionsDialogBase::OnCheckBoxMinimizeToTray ), NULL, this ); m_checkBoxUseProxy->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( COptionsDialogBase::OnCheckBoxUseProxy ), NULL, this ); m_textCtrlProxyIP->Disconnect( wxEVT_KILL_FOCUS, wxFocusEventHandler( COptionsDialogBase::OnKillFocusProxy ), NULL, this ); m_textCtrlProxyPort->Disconnect( wxEVT_KILL_FOCUS, wxFocusEventHandler( COptionsDialogBase::OnKillFocusProxy ), NULL, this ); + m_textCtrlTransactionFee->Disconnect( wxEVT_KILL_FOCUS, wxFocusEventHandler( COptionsDialogBase::OnKillFocusTransactionFee ), NULL, this ); m_buttonOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( COptionsDialogBase::OnButtonOK ), NULL, this ); m_buttonCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( COptionsDialogBase::OnButtonCancel ), NULL, this ); m_buttonApply->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( COptionsDialogBase::OnButtonApply ), NULL, this ); diff --git a/uibase.h b/uibase.h index 2c5e2fea..25af62a3 100644 --- a/uibase.h +++ b/uibase.h @@ -47,9 +47,9 @@ #define wxID_TEXTCTRLADDRESS 1004 #define wxID_BUTTONNEW 1005 #define wxID_BUTTONCOPY 1006 -#define wxID_TRANSACTIONFEE 1007 -#define wxID_PROXYIP 1008 -#define wxID_PROXYPORT 1009 +#define wxID_PROXYIP 1007 +#define wxID_PROXYPORT 1008 +#define wxID_TRANSACTIONFEE 1009 #define wxID_TEXTCTRLPAYTO 1010 #define wxID_BUTTONPASTE 1011 #define wxID_BUTTONADDRESSBOOK 1012 @@ -163,9 +163,6 @@ class COptionsDialogBase : public wxDialog wxScrolledWindow* m_scrolledWindow; wxPanel* m_panelMain; - wxStaticText* m_staticText32; - wxStaticText* m_staticText31; - wxTextCtrl* m_textCtrlTransactionFee; wxCheckBox* m_checkBoxLimitProcessors; wxSpinCtrl* m_spinCtrlLimitProcessors; wxStaticText* m_staticText35; @@ -178,6 +175,10 @@ class COptionsDialogBase : public wxDialog wxTextCtrl* m_textCtrlProxyIP; wxStaticText* m_staticTextProxyPort; wxTextCtrl* m_textCtrlProxyPort; + + wxStaticText* m_staticText32; + wxStaticText* m_staticText31; + wxTextCtrl* m_textCtrlTransactionFee; wxPanel* m_panelTest2; wxStaticText* m_staticText321; @@ -188,11 +189,11 @@ class COptionsDialogBase : public wxDialog // Virtual event handlers, overide them in your derived class virtual void OnListBox( wxCommandEvent& event ){ event.Skip(); } - virtual void OnKillFocusTransactionFee( wxFocusEvent& event ){ event.Skip(); } virtual void OnCheckBoxLimitProcessors( wxCommandEvent& event ){ event.Skip(); } virtual void OnCheckBoxMinimizeToTray( wxCommandEvent& event ){ event.Skip(); } virtual void OnCheckBoxUseProxy( wxCommandEvent& event ){ event.Skip(); } virtual void OnKillFocusProxy( wxFocusEvent& event ){ event.Skip(); } + virtual void OnKillFocusTransactionFee( wxFocusEvent& event ){ event.Skip(); } virtual void OnButtonOK( wxCommandEvent& event ){ event.Skip(); } virtual void OnButtonCancel( wxCommandEvent& event ){ event.Skip(); } virtual void OnButtonApply( wxCommandEvent& event ){ event.Skip(); } diff --git a/uiproject.fbp b/uiproject.fbp index ac7bbd66..976c5a72 100644 --- a/uiproject.fbp +++ b/uiproject.fbp @@ -1488,7 +1488,7 @@ - + @@ -1540,7 +1540,7 @@ - + bSizer55 wxVERTICAL @@ -1610,7 +1610,7 @@ 5 wxEXPAND|wxLEFT 1 - + 1 @@ -1720,174 +1720,6 @@ 0 - - 5 - wxALIGN_CENTER_VERTICAL|wxALL - 0 - - - - 1 - - - 1 - wxID_ANY - Optional transaction fee you give to the nodes that process your transactions. - - - m_staticText32 - protected - - - - - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND - 0 - - - bSizer56 - wxHORIZONTAL - none - - 5 - wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT - 0 - - - - 1 - - - 1 - wxID_ANY - Transaction fee: - - - m_staticText31 - protected - - - - - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL|wxALIGN_CENTER_VERTICAL - 0 - - - - 1 - - - 1 - wxID_TRANSACTIONFEE - - 0 - - m_textCtrlTransactionFee - protected - - 70,-1 - - - - - - - - - - - - - OnKillFocusTransactionFee - - - - - - - - - - - - - - - - - - - - - - - - - 5 @@ -2509,6 +2341,184 @@ + + 5 + + 0 + + 1 + protected + 0 + + + + 5 + wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT + 0 + + + + 1 + + + 0 + wxID_ANY + Optional transaction fee per KB that helps make sure your transactions are processed quickly. Most transactions are 1KB. Fee 0.01 recommended. + + + m_staticText32 + protected + + + + + + + + + 365 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 0 + + + bSizer56 + wxHORIZONTAL + none + + 5 + wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT + 0 + + + + 1 + + + 0 + wxID_ANY + Pay transaction fee: + + + m_staticText31 + protected + + + + + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL|wxALL + 0 + + + + 1 + + + 0 + wxID_TRANSACTIONFEE + + 0 + + m_textCtrlTransactionFee + protected + + 70,-1 + + + + + + + + + + + + + OnKillFocusTransactionFee + + + + + + + + + + + + + + + + + + + + + + + + +