BitShares Forum

Main => General Discussion => Topic started by: alt on May 26, 2015, 03:01:22 am

Title: can anybody help for build light wallet?
Post by: alt on May 26, 2015, 03:01:22 am
I want to change https://wallet.btsbots.com to light wallet server
can anybody help me what should I do?
how to use the BTS JS lib for browser?
what service should implement for the light wallet server?
many thanks!
Title: Re: can anybody help for build light wallet?
Post by: sudo on May 26, 2015, 07:05:03 am
 +5% +5%
Title: Re: can anybody help for build light wallet?
Post by: xeroc on May 26, 2015, 07:13:42 am
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
Title: Re: can anybody help for build light wallet?
Post by: alt on May 26, 2015, 09:00:57 am
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
Title: Re: can anybody help for build light wallet?
Post by: alt on May 27, 2015, 03:14:24 pm
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?
Title: Re: can anybody help for build light wallet?
Post by: alt on May 29, 2015, 01:04:52 am
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!
Title: Re: can anybody help for build light wallet?
Post by: alt on May 29, 2015, 05:59:46 am
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
Title: Re: can anybody help for build light wallet?
Post by: xeroc on May 29, 2015, 07:33:13 am
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
Title: Re: can anybody help for build light wallet?
Post by: monsterer on May 29, 2015, 09:26:17 am
I don't think memo's work yet for public accounts, do they?
Title: Re: can anybody help for build light wallet?
Post by: xeroc on May 29, 2015, 09:33:33 am
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
Title: Re: can anybody help for build light wallet?
Post by: alt on May 29, 2015, 09:36:46 am
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
Title: Re: can anybody help for build light wallet?
Post by: monsterer on May 29, 2015, 09:51:18 am
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
Title: Re: can anybody help for build light wallet?
Post by: xeroc on May 29, 2015, 09:51:34 am
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 ..
Title: Re: can anybody help for build light wallet?
Post by: xeroc on May 29, 2015, 09:52:36 am
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 ..
Title: Re: can anybody help for build light wallet?
Post by: boombastic on May 29, 2015, 03:26:27 pm

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
Title: Re: can anybody help for build light wallet?
Post by: alt on May 29, 2015, 05:08:27 pm
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
Title: Re: can anybody help for build light wallet?
Post by: xeroc on May 29, 2015, 06:15:54 pm
You can add a local contact with name and pubkey and register that without having the privkey for the account
Title: Re: can anybody help for build light wallet?
Post by: boombastic on May 29, 2015, 06:26:11 pm
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