示例#1
0
void ZrSatoshiBitcoin::loadWallets( std::vector< ZR::MyWallet *> & wallets )
{
    JsonRpc rpc( m_settings );
    try{
        JsonRpc::JsonData res = rpc.executeRpc ("listaddressgroupings");
        for( nmcrpc::JsonRpc::JsonData::iterator it1 = res.begin(); it1 != res.end(); it1++ ){
            JsonRpc::JsonData res0 = *it1;
            assert (res0.isArray());
            for( nmcrpc::JsonRpc::JsonData::iterator it2 = res0.begin(); it2 != res0.end(); it2++ ){
                JsonRpc::JsonData res1 = *it2;
                JsonRpc::JsonData res2 = res1[ 0u ];
                ZR::BitcoinAddress address = res2.asString();

                JsonRpc::JsonData res21 = res1[ 1u ];
                ZR::ZR_Number balance = res21.asDouble();
                ZR::MyWallet * wallet = new SatoshiWallet( address, balance );
                wallets.push_back( wallet );
            }
        }
    }
    catch( std::runtime_error e ){
        std::cerr << "Zero Reserve: " << __func__ << ": Exception caught: " << e.what() << std::endl;
        print_stacktrace();
    }
}