@ -546,44 +546,45 @@ void SendCoinsDialog::coinControlChangeChecked(int state)
@@ -546,44 +546,45 @@ void SendCoinsDialog::coinControlChangeChecked(int state)
// Coin Control: custom change address changed
void SendCoinsDialog : : coinControlChangeEdited ( const QString & text )
{
if ( model )
if ( model & & model - > getAddressTableModel ( ) )
{
CoinControlDialog : : coinControl - > destChange = CBitcoinAddress ( text . toStdString ( ) ) . Get ( ) ;
// Default to no change address until verified
CoinControlDialog : : coinControl - > destChange = CNoDestination ( ) ;
ui - > labelCoinControlChangeLabel - > setStyleSheet ( " QLabel{color:red;} " ) ;
CBitcoinAddress addr = CBitcoinAddress ( text . toStdString ( ) ) ;
// label for the change address
ui - > labelCoinControlChangeLabel - > setStyleSheet ( " QLabel{color:black;} " ) ;
if ( text . isEmpty ( ) )
if ( text . isEmpty ( ) ) // Nothing entered
{
ui - > labelCoinControlChangeLabel - > setText ( " " ) ;
else if ( ! CBitcoinAddress ( text . toStdString ( ) ) . IsValid ( ) )
}
else if ( ! addr . IsValid ( ) ) // Invalid address
{
// invalid change address
CoinControlDialog : : coinControl - > destChange = CNoDestination ( ) ;
ui - > lineEditCoinControlChange - > setValid ( false ) ;
ui - > labelCoinControlChangeLabel - > setStyleSheet ( " QLabel{color:red;} " ) ;
ui - > labelCoinControlChangeLabel - > setText ( tr ( " Warning: Invalid Bitcoin address " ) ) ;
}
else
else // Valid address
{
QString associatedLabel = model - > getAddressTableModel ( ) - > labelForAddress ( text ) ;
if ( ! associatedLabel . isEmpty ( ) )
ui - > labelCoinControlChangeLabel - > setText ( associatedLabel ) ;
els e
CPubKey pubkey ;
CKeyID keyid ;
addr . GetKeyID ( keyid ) ;
if ( ! mod el- > g etPubKey ( keyid , pubkey ) ) // Unknown change address
{
CPubKey pubkey ;
CKeyID keyid ;
CBitcoinAddress ( text . toStdString ( ) ) . GetKeyID ( keyid ) ;
if ( model - > getPubKey ( keyid , pubkey ) )
ui - > labelCoinControlChangeLabel - > setText ( tr ( " (no label) " ) ) ;
ui - > lineEditCoinControlChange - > setValid ( false ) ;
ui - > labelCoinControlChangeLabel - > setText ( tr ( " Warning: Unknown change address " ) ) ;
}
else // Known change address
{
ui - > labelCoinControlChangeLabel - > setStyleSheet ( " QLabel{color:black;} " ) ;
// Query label
QString associatedLabel = model - > getAddressTableModel ( ) - > labelForAddress ( text ) ;
if ( ! associatedLabel . isEmpty ( ) )
ui - > labelCoinControlChangeLabel - > setText ( associatedLabel ) ;
else
{
// unknown change address
CoinControlDialog : : coinControl - > destChange = CNoDestination ( ) ;
ui - > lineEditCoinControlChange - > setValid ( false ) ;
ui - > labelCoinControlChangeLabel - > setStyleSheet ( " QLabel{color:red;} " ) ;
ui - > labelCoinControlChangeLabel - > setText ( tr ( " Warning: Unknown change address " ) ) ;
}
ui - > labelCoinControlChangeLabel - > setText ( tr ( " (no label) " ) ) ;
CoinControlDialog : : coinControl - > destChange = addr . Get ( ) ;
}
}
}