@ -85,7 +85,7 @@ namespace
//------------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------------
void set_confirmations ( tools : : wallet_rpc : : transfer_entry & entry , uint64_t blockchain_height , uint64_t block_reward )
void set_confirmations ( tools : : wallet_rpc : : transfer_entry & entry , uint64_t blockchain_height , uint64_t block_reward )
{
{
if ( entry . height > = blockchain_height )
if ( entry . height > = blockchain_height | | ( entry . height = = 0 & & ( ! strcmp ( entry . type . c_str ( ) , " pending " ) | | ! strcmp ( entry . type . c_str ( ) , " pool " ) ) ) )
{
{
entry . confirmations = 0 ;
entry . confirmations = 0 ;
entry . suggested_confirmations_threshold = 0 ;
entry . suggested_confirmations_threshold = 0 ;
@ -302,6 +302,7 @@ namespace tools
entry . note = m_wallet - > get_tx_note ( pd . m_tx_hash ) ;
entry . note = m_wallet - > get_tx_note ( pd . m_tx_hash ) ;
entry . type = pd . m_coinbase ? " block " : " in " ;
entry . type = pd . m_coinbase ? " block " : " in " ;
entry . subaddr_index = pd . m_subaddr_index ;
entry . subaddr_index = pd . m_subaddr_index ;
entry . subaddr_indices . push_back ( pd . m_subaddr_index ) ;
entry . address = m_wallet - > get_subaddress_as_str ( pd . m_subaddr_index ) ;
entry . address = m_wallet - > get_subaddress_as_str ( pd . m_subaddr_index ) ;
set_confirmations ( entry , m_wallet - > get_blockchain_current_height ( ) , m_wallet - > get_last_block_reward ( ) ) ;
set_confirmations ( entry , m_wallet - > get_blockchain_current_height ( ) , m_wallet - > get_last_block_reward ( ) ) ;
}
}
@ -373,6 +374,7 @@ namespace tools
entry . double_spend_seen = ppd . m_double_spend_seen ;
entry . double_spend_seen = ppd . m_double_spend_seen ;
entry . type = " pool " ;
entry . type = " pool " ;
entry . subaddr_index = pd . m_subaddr_index ;
entry . subaddr_index = pd . m_subaddr_index ;
entry . subaddr_indices . push_back ( pd . m_subaddr_index ) ;
entry . address = m_wallet - > get_subaddress_as_str ( pd . m_subaddr_index ) ;
entry . address = m_wallet - > get_subaddress_as_str ( pd . m_subaddr_index ) ;
set_confirmations ( entry , m_wallet - > get_blockchain_current_height ( ) , m_wallet - > get_last_block_reward ( ) ) ;
set_confirmations ( entry , m_wallet - > get_blockchain_current_height ( ) , m_wallet - > get_last_block_reward ( ) ) ;
}
}
@ -1830,7 +1832,7 @@ namespace tools
if ( m_wallet - > watch_only ( ) )
if ( m_wallet - > watch_only ( ) )
{
{
er . code = WALLET_RPC_ERROR_CODE_WATCH_ONLY ;
er . code = WALLET_RPC_ERROR_CODE_WATCH_ONLY ;
er . message = " The wallet is watch-only. Cannot display seed." ;
er . message = " The wallet is watch-only. Cannot retrieve seed." ;
return false ;
return false ;
}
}
if ( ! m_wallet - > is_deterministic ( ) )
if ( ! m_wallet - > is_deterministic ( ) )
@ -1855,6 +1857,12 @@ namespace tools
}
}
else if ( req . key_type . compare ( " spend_key " ) = = 0 )
else if ( req . key_type . compare ( " spend_key " ) = = 0 )
{
{
if ( m_wallet - > watch_only ( ) )
{
er . code = WALLET_RPC_ERROR_CODE_WATCH_ONLY ;
er . message = " The wallet is watch-only. Cannot retrieve spend key. " ;
return false ;
}
epee : : wipeable_string key = epee : : to_hex : : wipeable_string ( m_wallet - > get_account ( ) . get_keys ( ) . m_spend_secret_key ) ;
epee : : wipeable_string key = epee : : to_hex : : wipeable_string ( m_wallet - > get_account ( ) . get_keys ( ) . m_spend_secret_key ) ;
res . key = std : : string ( key . data ( ) , key . size ( ) ) ;
res . key = std : : string ( key . data ( ) , key . size ( ) ) ;
}
}
@ -4031,6 +4039,40 @@ namespace tools
return false ;
return false ;
}
}
//------------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------------
bool wallet_rpc_server : : on_set_daemon ( const wallet_rpc : : COMMAND_RPC_SET_DAEMON : : request & req , wallet_rpc : : COMMAND_RPC_SET_DAEMON : : response & res , epee : : json_rpc : : error & er , const connection_context * ctx )
{
if ( ! m_wallet ) return not_open ( er ) ;
if ( m_restricted )
{
er . code = WALLET_RPC_ERROR_CODE_DENIED ;
er . message = " Command unavailable in restricted mode. " ;
return false ;
}
epee : : net_utils : : ssl_support_t ssl_support ;
if ( ! epee : : net_utils : : ssl_support_from_string ( ssl_support , req . ssl_support ) )
{
er . code = WALLET_RPC_ERROR_CODE_NO_DAEMON_CONNECTION ;
er . message = std : : string ( " Invalid ssl support mode " ) ;
return false ;
}
std : : vector < std : : vector < uint8_t > > ssl_allowed_fingerprints ;
ssl_allowed_fingerprints . reserve ( req . ssl_allowed_fingerprints . size ( ) ) ;
for ( const std : : string & fp : req . ssl_allowed_fingerprints )
{
ssl_allowed_fingerprints . push_back ( { } ) ;
std : : vector < uint8_t > & v = ssl_allowed_fingerprints . back ( ) ;
for ( auto c : fp )
v . push_back ( c ) ;
}
if ( ! m_wallet - > set_daemon ( req . address , boost : : none , req . trusted , ssl_support , std : : make_pair ( req . ssl_private_key_path , req . ssl_certificate_path ) , req . ssl_allowed_certificates , ssl_allowed_fingerprints , req . ssl_allow_any_cert ) )
{
er . code = WALLET_RPC_ERROR_CODE_NO_DAEMON_CONNECTION ;
er . message = std : : string ( " Unable to set daemon " ) ;
return false ;
}
return true ;
}
//------------------------------------------------------------------------------------------------------------------------------
bool wallet_rpc_server : : on_get_version ( const wallet_rpc : : COMMAND_RPC_GET_VERSION : : request & req , wallet_rpc : : COMMAND_RPC_GET_VERSION : : response & res , epee : : json_rpc : : error & er , const connection_context * ctx )
bool wallet_rpc_server : : on_get_version ( const wallet_rpc : : COMMAND_RPC_GET_VERSION : : request & req , wallet_rpc : : COMMAND_RPC_GET_VERSION : : response & res , epee : : json_rpc : : error & er , const connection_context * ctx )
{
{
res . version = WALLET_RPC_VERSION ;
res . version = WALLET_RPC_VERSION ;