@ -92,36 +92,45 @@ Value getinfo(const Array& params, bool fHelp)
# ifdef ENABLE_WALLET
# ifdef ENABLE_WALLET
class DescribeAddressVisitor : public boost : : static_visitor < Object >
class DescribeAddressVisitor : public boost : : static_visitor < Object >
{
{
private :
isminetype mine ;
public :
public :
DescribeAddressVisitor ( isminetype mineIn ) : mine ( mineIn ) { }
Object operator ( ) ( const CNoDestination & dest ) const { return Object ( ) ; }
Object operator ( ) ( const CNoDestination & dest ) const { return Object ( ) ; }
Object operator ( ) ( const CKeyID & keyID ) const {
Object operator ( ) ( const CKeyID & keyID ) const {
Object obj ;
Object obj ;
CPubKey vchPubKey ;
CPubKey vchPubKey ;
pwalletMain - > GetPubKey ( keyID , vchPubKey ) ;
obj . push_back ( Pair ( " isscript " , false ) ) ;
obj . push_back ( Pair ( " isscript " , false ) ) ;
obj . push_back ( Pair ( " pubkey " , HexStr ( vchPubKey ) ) ) ;
if ( mine = = MINE_SPENDABLE ) {
obj . push_back ( Pair ( " iscompressed " , vchPubKey . IsCompressed ( ) ) ) ;
pwalletMain - > GetPubKey ( keyID , vchPubKey ) ;
obj . push_back ( Pair ( " pubkey " , HexStr ( vchPubKey ) ) ) ;
obj . push_back ( Pair ( " iscompressed " , vchPubKey . IsCompressed ( ) ) ) ;
}
return obj ;
return obj ;
}
}
Object operator ( ) ( const CScriptID & scriptID ) const {
Object operator ( ) ( const CScriptID & scriptID ) const {
Object obj ;
Object obj ;
obj . push_back ( Pair ( " isscript " , true ) ) ;
obj . push_back ( Pair ( " isscript " , true ) ) ;
CScript subscript ;
if ( mine = = MINE_SPENDABLE ) {
pwalletMain - > GetCScript ( scriptID , subscript ) ;
CScript subscript ;
std : : vector < CTxDestination > addresses ;
pwalletMain - > GetCScript ( scriptID , subscript ) ;
txnouttype whichType ;
std : : vector < CTxDestination > addresses ;
int nRequired ;
txnouttype whichType ;
ExtractDestinations ( subscript , whichType , addresses , nRequired ) ;
int nRequired ;
obj . push_back ( Pair ( " script " , GetTxnOutputType ( whichType ) ) ) ;
ExtractDestinations ( subscript , whichType , addresses , nRequired ) ;
obj . push_back ( Pair ( " hex " , HexStr ( subscript . begin ( ) , subscript . end ( ) ) ) ) ;
obj . push_back ( Pair ( " script " , GetTxnOutputType ( whichType ) ) ) ;
Array a ;
obj . push_back ( Pair ( " hex " , HexStr ( subscript . begin ( ) , subscript . end ( ) ) ) ) ;
BOOST_FOREACH ( const CTxDestination & addr , addresses )
Array a ;
a . push_back ( CBitcoinAddress ( addr ) . ToString ( ) ) ;
BOOST_FOREACH ( const CTxDestination & addr , addresses )
obj . push_back ( Pair ( " addresses " , a ) ) ;
a . push_back ( CBitcoinAddress ( addr ) . ToString ( ) ) ;
if ( whichType = = TX_MULTISIG )
obj . push_back ( Pair ( " addresses " , a ) ) ;
obj . push_back ( Pair ( " sigsrequired " , nRequired ) ) ;
if ( whichType = = TX_MULTISIG )
obj . push_back ( Pair ( " sigsrequired " , nRequired ) ) ;
}
return obj ;
return obj ;
}
}
} ;
} ;
@ -161,10 +170,11 @@ Value validateaddress(const Array& params, bool fHelp)
string currentAddress = address . ToString ( ) ;
string currentAddress = address . ToString ( ) ;
ret . push_back ( Pair ( " address " , currentAddress ) ) ;
ret . push_back ( Pair ( " address " , currentAddress ) ) ;
# ifdef ENABLE_WALLET
# ifdef ENABLE_WALLET
bool fMine = pwalletMain ? IsMine ( * pwalletMain , dest ) : false ;
isminetype mine = pwalletMain ? IsMine ( * pwalletMain , dest ) : MINE_NO ;
ret . push_back ( Pair ( " ismine " , fMine ) ) ;
ret . push_back ( Pair ( " ismine " , mine ! = MINE_NO ) ) ;
if ( fMine ) {
if ( mine ! = MINE_NO ) {
Object detail = boost : : apply_visitor ( DescribeAddressVisitor ( ) , dest ) ;
ret . push_back ( Pair ( " watchonly " , mine = = MINE_WATCH_ONLY ) ) ;
Object detail = boost : : apply_visitor ( DescribeAddressVisitor ( mine ) , dest ) ;
ret . insert ( ret . end ( ) , detail . begin ( ) , detail . end ( ) ) ;
ret . insert ( ret . end ( ) , detail . begin ( ) , detail . end ( ) ) ;
}
}
if ( pwalletMain & & pwalletMain - > mapAddressBook . count ( dest ) )
if ( pwalletMain & & pwalletMain - > mapAddressBook . count ( dest ) )