Author Topic: i want to add api to cli_wallet, but something failed, can you help me the code?  (Read 203 times)

0 Members and 1 Guest are viewing this topic.

Offline pqbb

  • Newbie
  • *
  • Posts: 6
    • View Profile
in fact, i'm not familiar with C++, but i want to try something.

i try to add a method (example: create_match) to the cli_wallet, so the cli can call it.
the code like below:

\libraries\wallet\include\graphene\wallet\wallet.hpp
      signed_transaction create_match(string issuer,
                                      string title,
                                      bool broadcast = false);

FC_API( graphene::wallet::wallet_api,
...
        (create_match)
...

\libraries\wallet\wallet.cpp
   signed_transaction create_match(string issuer,
                                   string title,
                                   bool broadcast = false)
   { try {
      account_object issuer_account = get_account( issuer );

      custom_operation create_op;
      create_op.issuer = issuer_account.id;
      create_op.title = title;

      signed_transaction tx;
      tx.operations.push_back( create_op );
      set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees);
      tx.validate();

      return sign_transaction( tx, broadcast );
   } FC_CAPTURE_AND_RETHROW( (issuer)(title)(broadcast) ) }


signed_transaction wallet_api::create_match(string issuer,
                                            string title,
                                            bool broadcast)

{
   return my->create_match(issuer, title, broadcast);
}

...

just like this(i refer to the create_asset method)


then build & run the cli_wallet
but when i run the command in the wallet: create_match user1 "test" true
it display the error:
itr != _by_name.end(): no method with name 'create_match'

how i can fix it?
thanks very much! ;D ;D