Author Topic: pybitshares - getting the wallet transfer example to work completely  (Read 2482 times)

0 Members and 1 Guest are viewing this topic.

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 12922
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BitShares: xeroc
  • GitHub: xeroc
Hello, I would like to get the following example from the PyBitshares documentation [1] to work:

Code: [Select]
   
    from bitshares import BitShares
    bitshares = BitShares()
    bitshares.wallet.unlock("wallet-passphrase")
    bitshares.transfer("<to>", "<amount>", "<asset>", "[<memo>]",
                        account="<from>")

Although this is not the meat of my problem, you cannot supply keyword parameters after positional parameters. Therefore the call to
Code: [Select]
.transfer() cannot have
Code: [Select]
account=<from> parameter at the end.
Surprise to me. Keywork parameters have to come after positional arguments in python.

Quote
Anyway, moving on to the real issues, it seems that before you can get this example to work, you need to decide on a wallet operation model (Wallet Database, Provide Keys, Force Keys). For this discussion, I would like to focus on providing keys.

The Bitshares constructor [2] accepts a `keys` parameter whose value may be an array, dictionary or string. This leads to the following questions:

1 - what is a wif key? What does "wif" stand for?
Wallet Import Format - it's the "usual" way of providing a private key ... they look like this:
5JmQw8nM4kS8XHMagco6JhJV2jiBdvj1Q2oUmtCBhA8CFm8AKUL

Quote
2 - Where would I access the private key for an OpenLedger account? Please provide a precise navigation sequence.
Account Menu -> Permissions -> Active Key -> (click the bold key) -> show wif key

Quote
3 - Where would I access the private key for a Crypto-Bridge account? Please provide a precise navigation sequence.
same as above -  if you use the same account on both platforms, there is no need to do the process twice.

Quote
4 - Once I find the private key how does one supply it? The docs state the types of things that the `keys` parameter accepts, but it does not show how to supply it.

try this
Code: [Select]
from bitshares import BitShares
bitshares = BitShares()
bitshares.wallet.create("secret-passphrase")
bitshares.wallet.addPrivateKey("<wif-key>")

Quote
After looking at the wallet documentation [3] I have a few more questions:

1 - after adding a private key, does PyBitshares automatically know which Bitshares account it belongs to?
For instance, if I add the private keys for the the bitshares user bev123 [4] am I able to call getActiveKeyForAccount [5] and supply 'bev123' as the name of the account?
Yes - the library figures this out automatically.

Offline abit

  • Committee member
  • Hero Member
  • *
  • Posts: 4664
    • View Profile
    • Abit's Hive Blog
  • BitShares: abit
  • GitHub: abitmore
There are some basic questions, along with deeper technical questions.

We'll take reference wallet as an example. OpenLedger and Crypto-Bridge are mostly the same.

Open https://wallet.bitshares.org/, when you got an account,
click the right top hamburg icon, in the botton of the menu popped, click permissions, you'll see public key(s);
click on (one of) the key(s), you'll see the private key in WIF format (more info: https://en.bitcoin.it/wiki/Wallet_import_format).
BitShares committee member: abit
BitShares witness: in.abit

Offline akashic

  • Newbie
  • *
  • Posts: 9
    • View Profile
Hello, I would like to get the following example from the PyBitshares documentation [1] to work:

Code: [Select]
   
    from bitshares import BitShares
    bitshares = BitShares()
    bitshares.wallet.unlock("wallet-passphrase")
    bitshares.transfer("<to>", "<amount>", "<asset>", "[<memo>]",
                        account="<from>")

Although this is not the meat of my problem, you cannot supply keyword parameters after positional parameters. Therefore the call to
Code: [Select]
.transfer() cannot have
Code: [Select]
account=<from> parameter at the end.

Anyway, moving on to the real issues, it seems that before you can get this example to work, you need to decide on a wallet operation model (Wallet Database, Provide Keys, Force Keys). For this discussion, I would like to focus on providing keys.

The Bitshares constructor [2] accepts a `keys` parameter whose value may be an array, dictionary or string. This leads to the following questions:

1 - what is a wif key? What does "wif" stand for?
2 - Where would I access the private key for an OpenLedger account? Please provide a precise navigation sequence.
3 - Where would I access the private key for a Crypto-Bridge account? Please provide a precise navigation sequence.
4 - Once I find the private key how does one supply it? The docs state the types of things that the `keys` parameter accepts, but it does not show how to supply it.

After looking at the wallet documentation [3] I have a few more questions:

1 - after adding a private key, does PyBitshares automatically know which Bitshares account it belongs to? For instance, if I add the private keys for the the bitshares user bev123 [4] am I able to call getActiveKeyForAccount [5] and supply 'bev123' as the name of the account?

[1] http://docs.pybitshares.com/en/latest/index.html
[2] http://docs.pybitshares.com/en/latest/bitshares.bitshares.html
[3] http://docs.pybitshares.com/en/latest/bitshares.wallet.html
[4] https://cryptofresh.com/u/bev123
[5] http://docs.pybitshares.com/en/latest/bitshares.wallet.html#bitshares.wallet.Wallet.getActiveKey