Author Topic: can anybody help for build light wallet?  (Read 3427 times)

0 Members and 1 Guest are viewing this topic.

Offline boombastic

  • Sr. Member
  • ****
  • Posts: 251
    • View Profile
    • AngelShares Explorer
check here

https://github.com/BitShares/web_services/blob/master/faucet/app/services/account_registrator.rb#L40-L55

Code: [Select]
def register_bts(account_name, account_key, owner_key)
    BitShares::API::Wallet.add_contact(account_key)
    #account = BitShares::API::Wallet.get_account(account_name)
    account = {}
    account['id'] = 0
    account['public_data'] = nil
    account['name'] = account_name
    account['active_key_history'] = [["2015-04-28T22:01:23", account_key]]
    account["registration_date"] = "1970-01-01T00:00:00"
    account["last_child_key_index"] = 0
    account["block_production_enabled"] = false
    account["custom_data"] = {}
    account['owner_key'] = owner_key if owner_key
    account['meta_data'] = {'type' => 'public_account', 'data' => ''}
    BitShares::API.rpc.request('request_register_account', [account])
end
http://bitshares.dacplay.org/r/boombastic
Support My Witness: mr.agsexplorer
BTC: 1Bb6V1UStz45QMAamjaX8rDjsnQnBpHvE8

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 12922
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BitShares: xeroc
  • GitHub: xeroc
You can add a local contact with name and pubkey and register that without having the privkey for the account

Offline alt

  • Hero Member
  • *****
  • Posts: 2821
    • View Profile
  • BitShares: baozi
do you know what's the api to register for other?
I saw faucet use request_register_account, but I didn't found the next step.


a new question, how to use faucet.bitshares.org?

I saw wallet.bitshares.org request a url like this:
https://faucet.bitshares.org/?account_name=Guest&active_key=BTS8DvM...KHCHaj3y6tU5&owner_key=BTS8DvM...KHCHaj3y6tU5&app_id=0

why active_key is not complete, and account_name always Guest, and what means app_id?
too many questions, Thanks!

Incomplete active key is probably a mistake.  Faucet uses those parameters for its workflow.  Basically ask you to identify yourself using social account to prevent spam and help you register your account with the name you want (long free account names).

Anyway, since you are building a light weight wallet for end users, you will probably integrate account registration function into your wallet, especially when BitShares referral program is activated.  You won't want to redirect users to external faucet services.


Sent from my iPhone using Tapatalk

Offline boombastic

  • Sr. Member
  • ****
  • Posts: 251
    • View Profile
    • AngelShares Explorer

a new question, how to use faucet.bitshares.org?

I saw wallet.bitshares.org request a url like this:
https://faucet.bitshares.org/?account_name=Guest&active_key=BTS8DvM...KHCHaj3y6tU5&owner_key=BTS8DvM...KHCHaj3y6tU5&app_id=0

why active_key is not complete, and account_name always Guest, and what means app_id?
too many questions, Thanks!

Incomplete active key is probably a mistake.  Faucet uses those parameters for its workflow.  Basically ask you to identify yourself using social account to prevent spam and help you register your account with the name you want (long free account names).

Anyway, since you are building a light weight wallet for end users, you will probably integrate account registration function into your wallet, especially when BitShares referral program is activated.  You won't want to redirect users to external faucet services.


Sent from my iPhone using Tapatalk
http://bitshares.dacplay.org/r/boombastic
Support My Witness: mr.agsexplorer
BTC: 1Bb6V1UStz45QMAamjaX8rDjsnQnBpHvE8

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 12922
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BitShares: xeroc
  • GitHub: xeroc
why shouldn't they?

Quote
help wallet_account_register
Usage:
wallet_account_register <account_name> <pay_from_account> [public_data] [delegate_pay_rate] [account
_type]   Updates the data published about a given account
Updates the data published about a given account

Parameters:
  account_name (account_name, required): the account that will be updated pay_from_account (account_name, required): the account from which fees will be paid
  public_data (json_variant, optional, defaults to null): public data about the account
  delegate_pay_rate (uint8_t, optional, defaults to -1): -1 for non-delegates; otherwise the percent of delegate pay to accept per produced block
  account_type (string, optional, defaults to "titan_account"): titan_account | public_account - public accounts do not receive memos and all payments are made to the active key

Returns:
  transaction_record

aliases: register

The wallet.bitshares.org is the best counter example .. it can only use nonTITAN accounts and yet you can receive a memo .. give it a try ..

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 12922
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BitShares: xeroc
  • GitHub: xeroc
yes, I am learning from your python script  :)
but for js coffee, It's really hard for me, I can't understand it totally  :(
Same here :|

Quote
and can you add memo for your python code?
maybe I will learn js, and write a js version from your python script.
I used the JS code as reference too ...
however, I fear I currently don't have the time to do the Memo in python .. just now ..
Will come eventually ..

Offline monsterer

why shouldn't they?

Quote
help wallet_account_register
Usage:
wallet_account_register <account_name> <pay_from_account> [public_data] [delegate_pay_rate] [account
_type]   Updates the data published about a given account
Updates the data published about a given account

Parameters:
  account_name (account_name, required): the account that will be updated pay_from_account (account_name, required): the account from which fees will be paid
  public_data (json_variant, optional, defaults to null): public data about the account
  delegate_pay_rate (uint8_t, optional, defaults to -1): -1 for non-delegates; otherwise the percent of delegate pay to accept per produced block
  account_type (string, optional, defaults to "titan_account"): titan_account | public_account - public accounts do not receive memos and all payments are made to the active key

Returns:
  transaction_record

aliases: register
My opinions do not represent those of metaexchange unless explicitly stated.
https://metaexchange.info | Bitcoin<->Altcoin exchange | Instant | Safe | Low spreads

Offline alt

  • Hero Member
  • *****
  • Posts: 2821
    • View Profile
  • BitShares: baozi
yes, I am learning from your python script  :)
but for js coffee, It's really hard for me, I can't understand it totally  :(

and can you add memo for your python code?
maybe I will learn js, and write a js version from your python script.

I need a js library for these functions, who can help me, thanks

1. build transfer transaction
input: sender's private key, sender's balance info, receiver's public key, and transfer amount, asset info, memo, fee info
output: json data with sender's signed , which can broadcast with API: blockchain_broadcast_transaction

2. build market transaction, bid/ask
input: sender's private key, sender's balance info, bid/ask, price, amount, fee info
output: json data with sender's signed , which can broadcast with API: blockchain_broadcast_transaction

3. decrypt a transfer transaction
input: transaction json data from api blockchain_list_address_balances
output: decrypt memo, and sender's info


1. and 2. should be possible already with the bitshares-js library because that's what wallet.bitshares.org does
take a look here:
https://github.com/BitShares/BitShares-JS/blob/master/src/wallet/transaction_builder.coffee#L475-L514
The lower level code (ie. signing and constructing) is done with the classes here:
https://github.com/BitShares/BitShares-JS/tree/master/src/blockchain

for reference you can take a look at my python code for deposits (market order not available yet):
https://github.com/xeroc/python-bitsharestools/blob/master/bitsharestools/transactions.py#L365-L381

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 12922
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BitShares: xeroc
  • GitHub: xeroc
I don't think memo's work yet for public accounts, do they?
why shouldn't they?
The key used to encrypt the public memo is just the public key of the account instead of a TITAN derived public key ..
Not sure if the client does it correctly already though

Offline monsterer

I don't think memo's work yet for public accounts, do they?
My opinions do not represent those of metaexchange unless explicitly stated.
https://metaexchange.info | Bitcoin<->Altcoin exchange | Instant | Safe | Low spreads

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 12922
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BitShares: xeroc
  • GitHub: xeroc
I need a js library for these functions, who can help me, thanks

1. build transfer transaction
input: sender's private key, sender's balance info, receiver's public key, and transfer amount, asset info, memo, fee info
output: json data with sender's signed , which can broadcast with API: blockchain_broadcast_transaction

2. build market transaction, bid/ask
input: sender's private key, sender's balance info, bid/ask, price, amount, fee info
output: json data with sender's signed , which can broadcast with API: blockchain_broadcast_transaction

3. decrypt a transfer transaction
input: transaction json data from api blockchain_list_address_balances
output: decrypt memo, and sender's info


1. and 2. should be possible already with the bitshares-js library because that's what wallet.bitshares.org does
take a look here:
https://github.com/BitShares/BitShares-JS/blob/master/src/wallet/transaction_builder.coffee#L475-L514
The lower level code (ie. signing and constructing) is done with the classes here:
https://github.com/BitShares/BitShares-JS/tree/master/src/blockchain

for reference you can take a look at my python code for deposits (market order not available yet):
https://github.com/xeroc/python-bitsharestools/blob/master/bitsharestools/transactions.py#L365-L381

Offline alt

  • Hero Member
  • *****
  • Posts: 2821
    • View Profile
  • BitShares: baozi
I need a js library for these functions, who can help me, thanks

1. build transfer transaction
input: sender's private key, sender's balance info, receiver's public key, and transfer amount, asset info, memo, fee info
output: json data with sender's signed , which can broadcast with API: blockchain_broadcast_transaction

2. build market transaction, bid/ask
input: sender's private key, sender's balance info, bid/ask, price, amount, fee info
output: json data with sender's signed , which can broadcast with API: blockchain_broadcast_transaction

3. decrypt a transfer transaction
input: transaction json data from api blockchain_list_address_balances
output: decrypt memo, and sender's info

Offline alt

  • Hero Member
  • *****
  • Posts: 2821
    • View Profile
  • BitShares: baozi
a new question, how to use faucet.bitshares.org?

I saw wallet.bitshares.org request a url like this:
https://faucet.bitshares.org/?account_name=Guest&active_key=BTS8DvM...KHCHaj3y6tU5&owner_key=BTS8DvM...KHCHaj3y6tU5&app_id=0

why active_key is not complete, and account_name always Guest, and what means app_id?
too many questions, Thanks!

Offline alt

  • Hero Member
  • *****
  • Posts: 2821
    • View Profile
  • BitShares: baozi
I have change to light wallet.
now I can import private key, get account, get balance, get transaction
try here: https://wallet.btsbots.com

work to do:
1. get memo, and send account. I still don't know how to do this with the JS lib. how to get the sender's info which is not public account?
and how to decrypt the meo
2. transfer. still don't know how to do, if bob want to transfer to Alice, what's the step?
1) he need to get public key of Alice  from server?
2)  build the transaction, and signify?
3) broadcast by server?

Offline alt

  • Hero Member
  • *****
  • Posts: 2821
    • View Profile
  • BitShares: baozi
I don't know anything about the lightwallet server .. but I did try around with the bts-js library .. you can see the wallet/ecc stuff in action here:
https://delegate.xeroc.org/paperwallet.html
This is what I want, thank you so much  :D