bitshares / bitshares-core

BitShares Blockchain node and command-line wallet
https://bitshares.github.io/
Other
1.17k stars 648 forks source link

Improve CLI create_witness command #434

Open wy-z opened 6 years ago

wy-z commented 6 years ago

When I tried to create_witness, I always got such error:

create_witness wy12 "https://onesbts.com" true
0 exception: unspecified
Expecting a simple authority with one active key
    {}
    th_a  wallet.cpp:676 graphene::wallet::detail::wallet_api_impl::get_private_key_for_account

    {"owner_account":"wy12","broadcast":true}
    th_a  wallet.cpp:1468 graphene::wallet::detail::wallet_api_impl::create_witness

cmd

import_key wy12 HwCS***
create_witness wy12 "https://onesbts.com" true

witness_node

witness_node --rpc-endpoint 127.0.0.1:8090 --max-ops-per-account 500 --partial-operations true

Looking forward to your reply~

secp256 commented 6 years ago

import your active private key with cli_wallet.

wy-z commented 6 years ago

@gxchain123 Nice to see your reply~ I have imported my key by import_key before calling create_witness~

wy-z commented 6 years ago

@gxchain123 I have just updated my operation flow and 'witness_node' config~ Is there an improper operation?

wy-z commented 6 years ago

@gxchain123 I have imported all my keys, and here is my account info: unlocked >>> list_my_accounts

list_my_accounts
[{
    "id": "1.2.374609",
    "membership_expiration_date": "1969-12-31T23:59:59",
    "registrar": "1.2.374609",
    "referrer": "1.2.374609",
    "lifetime_referrer": "1.2.374609",
    "network_fee_percentage": 2000,
    "lifetime_referrer_fee_percentage": 8000,
    "referrer_rewards_percentage": 0,
    "name": "wy12",
    "owner": {
      "weight_threshold": 1,
      "account_auths": [],
      "key_auths": [[
          "BTS5***",
          1
        ]
      ],
      "address_auths": []
    },
    "active": {
      "weight_threshold": 1,
      "account_auths": [],
      "key_auths": [[
          "BTS6***",
          1
        ],[
          "BTS8***",
          1
        ]
      ],
      "address_auths": []
    },
    "options": {
      "memo_key": "BTS8***",
      "voting_account": "1.2.282",
      "num_witness": 0,
      "num_committee": 0,
      "votes": [],
      "extensions": []
    },
    "statistics": "2.6.374609",
    "whitelisting_accounts": [],
    "blacklisting_accounts": [],
    "whitelisted_accounts": [],
    "blacklisted_accounts": [],
    "cashback_vb": "1.13.1849",
    "owner_special_authority": [
      0,{}
    ],
    "active_special_authority": [
      0,{}
    ],
    "top_n_control_flags": 0
  }
]

unlocked >>> list_account_balances wy12

list_account_balances wy12
251752.67860 BTS
0 CNY
0.0001 USD
0 OPEN.ETH
0 OPEN.BTC
0 OPEN.EOS
wy-z commented 6 years ago

@gxchain123 Is "membership_expiration_date": "1969-12-31T23:59:59" correct?

wy-z commented 6 years ago

@gxchain123 Yes~

unlocked >>> transfer ones wy12 10 BTS "some bts" true
transfer ones wy12 10 BTS "some bts" true
{
  "ref_block_num": 27007,
  "ref_block_prefix": 516032709,
  "expiration": "2017-10-20T07:17:39",
  "operations": [[
      0,{
        "fee": {
          "amount": 22941,
          "asset_id": "1.3.0"
        },
        "from": "1.2.430293",
        "to": "1.2.374609",
        "amount": {
          "amount": 1000000,
          "asset_id": "1.3.0"
        },
        "memo": {
          "from": "BTS8***",
          "to": "BTS8***",
          "nonce": "10954262777596169095",
          "message": "30189b7c90012bd0536eadea2b8aa823"
        },
        "extensions": []
      }
    ]
  ],
  "extensions": [],
  "signatures": [
    "1f19a01d1b7598b20226d95475a8938a5ff5275e7e9fa1296785ad44f83ce63c412d6cf498377aafd117d62d3d1486a5061ec4be840c7d175e6656881075ee71a0"
  ]
}
abitmore commented 6 years ago

The error message is Expecting a simple authority with one active key, which means you need to have only one active key in your account, so the client can generate another key from that key. By the way, this is a designed feature of that CLI command, but not a limitation of the chain. You can always generate a pair of keys elsewhere then sign a raw transaction to create a witness, perhaps a bit off topic here.

Your account has 2 keys for active authority:

    "active": {
      "weight_threshold": 1,
      "account_auths": [],
      "key_auths": [[
          "BTS6***",
          1
        ],[
          "BTS8***",
          1
        ]
      ],
      "address_auths": []
    },
wy-z commented 6 years ago

@abitmore Got, thanks~

pmconrad commented 6 years ago

Which version? Maybe fixed in develop branch with PR #321 / issue #284 ?

wy-z commented 6 years ago

@pmconrad BitShares Core Release 2.0.170710

pmconrad commented 6 years ago

Please try the cli_wallet from the develop branch.

wy-z commented 6 years ago

@pmconrad I will~ Thanks~

oxarbitrage commented 6 years ago

@pmconrad this is not fixed in the mentioned pulls as the create_witness will call get_private_key_for_account where the throw occurs: https://github.com/bitshares/bitshares-core/blob/master/libraries/wallet/wallet.cpp#L676

this still happening in current versions.

if we remove the thrown the call with use the first key found but unsure if we want to do that.

abitmore commented 6 years ago

@oxarbitrage check my comment above. It's a designed feature, although I'm not sure if we really want it or want to change it. Low priority to me.