Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: leonzh on December 21, 2018, 12:10:41 PM



Title: Implement a simple wallet
Post by: leonzh on December 21, 2018, 12:10:41 PM
I need to implement a simple wallet using bitcore-lib by node.js.
Like manage private/public keys and addresses .

Is there any simple tutorial or example source code to show how to do this?

Thanks.


Title: Re: Implement a simple wallet
Post by: darosior on December 21, 2018, 12:33:46 PM
Hi,

I don't have any "tutorial" nor code simple enough to give you. But I can help you to think about what do you need to implement.
First what is a wallet ? It's an interface to the Bitcoin network.
In order to use it what do you need ? A key pair;
I think you should begin by generating key pairs in different formats (compressed, uncompressed, b58check-encoded, b58check-decoded, WIF-encoded, WIF-decoded, encrypted, etc..)


Title: Re: Implement a simple wallet
Post by: leonzh on December 21, 2018, 02:59:26 PM
Hi,

I don't have any "tutorial" nor code simple enough to give you. But I can help you to think about what do you need to implement.
First what is a wallet ? It's an interface to the Bitcoin network.
In order to use it what do you need ? A key pair;
I think you should begin by generating key pairs in different formats (compressed, uncompressed, b58check-encoded, b58check-decoded, WIF-encoded, WIF-decoded, encrypted, etc..)

Hi thanks for reply.

If a "lightweight wallet" is what I need to implement,
1, generate key pair and address;
2, issue transaction
3, get balance
4, get exchange rate
are all what I suppose to do, and implement with bitcore-lib,
is there any good guide to show how to implement?



Thanks.



Title: Re: Implement a simple wallet
Post by: darosior on December 21, 2018, 03:08:33 PM
Why do you need a guide to do that ? I tried to guide you through the process, just try and then if you have problems you cannot solve I (/we?) can help you.

Quote
1, generate key pair and address;
https://github.com/bitpay/bitcore-lib/blob/master/docs/address.md

Quote
2, issue transaction
https://github.com/bitpay/bitcore-lib/blob/master/docs/transaction.md

The bitcore-lib docs (https://github.com/bitpay/bitcore-lib/blob/master/docs/examples.md) are here to help you and are I think the guide you are looking for.

Quote
4, get exchange rate
Maybe the lib doesn't provide this and so you have to use exchanges APIs.



Title: Re: Implement a simple wallet
Post by: leonzh on December 21, 2018, 03:39:55 PM
Why do you need a guide to do that ? I tried to guide you through the process, just try and then if you have problems you cannot solve I (/we?) can help you.

Quote
1, generate key pair and address;
https://github.com/bitpay/bitcore-lib/blob/master/docs/address.md

Quote
2, issue transaction
https://github.com/bitpay/bitcore-lib/blob/master/docs/transaction.md

The bitcore-lib docs (https://github.com/bitpay/bitcore-lib/blob/master/docs/examples.md) are here to help you and are I think the guide you are looking for.

Quote
4, get exchange rate
Maybe the lib doesn't provide this and so you have to use exchanges APIs.



Thanks very much for your help.


Title: Re: Implement a simple wallet
Post by: Initscri on December 22, 2018, 01:06:29 AM
Hi,

I don't have any "tutorial" nor code simple enough to give you. But I can help you to think about what do you need to implement.
First what is a wallet ? It's an interface to the Bitcoin network.
In order to use it what do you need ? A key pair;
I think you should begin by generating key pairs in different formats (compressed, uncompressed, b58check-encoded, b58check-decoded, WIF-encoded, WIF-decoded, encrypted, etc..)

Hi thanks for reply.

If a "lightweight wallet" is what I need to implement,
1, generate key pair and address;
2, issue transaction
3, get balance
4, get exchange rate
are all what I suppose to do, and implement with bitcore-lib,
is there any good guide to show how to implement?



Thanks.



What currency pair are you looking for exchange wise? I can maybe give some info/support regarding exchange APIs


Title: Re: Implement a simple wallet
Post by: leonzh on December 22, 2018, 09:59:45 AM
Hi,

I don't have any "tutorial" nor code simple enough to give you. But I can help you to think about what do you need to implement.
First what is a wallet ? It's an interface to the Bitcoin network.
In order to use it what do you need ? A key pair;
I think you should begin by generating key pairs in different formats (compressed, uncompressed, b58check-encoded, b58check-decoded, WIF-encoded, WIF-decoded, encrypted, etc..)

Hi thanks for reply.

If a "lightweight wallet" is what I need to implement,
1, generate key pair and address;
2, issue transaction
3, get balance
4, get exchange rate
are all what I suppose to do, and implement with bitcore-lib,
is there any good guide to show how to implement?



Thanks.



What currency pair are you looking for exchange wise? I can maybe give some info/support regarding exchange APIs

Hi, I know a library named ccxt, almost composited all currencies:
https://github.com/ccxt/ccxt

any comments?


Title: Re: Implement a simple wallet
Post by: leonzh on December 22, 2018, 10:12:34 AM
One thing I do confuse is that through bitcore-lib, I can implement a wallet, why bitcore and many other apis like blockchaininfo still provide wallet programs which will require at least a rpc call to be functional? Running wallet as an external process and make rpc call could increase the complexity of a project, which I'd rather implement with a internal library(as bitcore-lib).


Title: Re: Implement a simple wallet
Post by: darosior on December 22, 2018, 12:13:51 PM
Quote
Hi, I know a library named ccxt, almost composited all currencies:
https://github.com/ccxt/ccxt

any comments?
I've heard of it but never used it. It seems good.

Quote
One thing I do confuse is that through bitcore-lib, I can implement a wallet, why bitcore and many other apis like blockchaininfo still provide wallet programs which will require at least a rpc call to be function? Running wallet as an extra rpc process could increase the complexity of a project, which I'd rather implement with a internal library(as bitcore-lib).
I don't understand this part :
Quote
which will require at least a rpc call to be function?
If you wonder why use RPC if we have a library which could do a similar thing, then the answer is that to interact with the network you sometimes have to have some informations only a node (at least a SPV) has.


Title: Re: Implement a simple wallet
Post by: leonzh on December 22, 2018, 01:23:05 PM
Quote
Hi, I know a library named ccxt, almost composited all currencies:
https://github.com/ccxt/ccxt

any comments?
I've heard of it but never used it. It seems good.

Quote
One thing I do confuse is that through bitcore-lib, I can implement a wallet, why bitcore and many other apis like blockchaininfo still provide wallet programs which will require at least a rpc call to be function? Running wallet as an extra rpc process could increase the complexity of a project, which I'd rather implement with a internal library(as bitcore-lib).
I don't understand this part :
Quote
which will require at least a rpc call to be function?
If you wonder why use RPC if we have a library which could do a similar thing, then the answer is that to interact with the network you sometimes have to have some informations only a node (at least a SPV) has.

So why I cannot setup a node with library code inside my project? Does a node must be an external program?


Title: Re: Implement a simple wallet
Post by: darosior on December 22, 2018, 02:59:39 PM
Quote
So why I cannot setup a node with library code inside my project? Does a node must be an external program?
Actually every wallet should be a node (or used to be). For convenience lightweight wallets have been implemented (SPV nodes) and you can do that if bitcore-lib permits it, or you can codez it yourself ^^
I still don't understand what you want to do with it.


Title: Re: Implement a simple wallet
Post by: Coding Enthusiast on December 22, 2018, 04:24:18 PM
I need to implement a simple wallet using bitcore-lib by node.js.
Like manage private/public keys and addresses .

Have you checked the already existing open source projects on GitHub?
https://github.com/search?l=JavaScript&q=bitcoin+wallet&type=Repositories

So why I cannot setup a node with library code inside my project? Does a node must be an external program?

A library is a set of functions that are put together by the programmer to serve a purpose. In order for a bitcoin library to have node functionalities it has to have implemented the P2P protocol and also have some wrappers allowing the caller to open up sockets for communication. I haven't had the chance to finish up this myself but it is not that complicated, I've already implemented the protocol part.


Title: Re: Implement a simple wallet
Post by: Initscri on December 22, 2018, 05:54:08 PM
Hi,

I don't have any "tutorial" nor code simple enough to give you. But I can help you to think about what do you need to implement.
First what is a wallet ? It's an interface to the Bitcoin network.
In order to use it what do you need ? A key pair;
I think you should begin by generating key pairs in different formats (compressed, uncompressed, b58check-encoded, b58check-decoded, WIF-encoded, WIF-decoded, encrypted, etc..)

Hi thanks for reply.

If a "lightweight wallet" is what I need to implement,
1, generate key pair and address;
2, issue transaction
3, get balance
4, get exchange rate
are all what I suppose to do, and implement with bitcore-lib,
is there any good guide to show how to implement?



Thanks.



What currency pair are you looking for exchange wise? I can maybe give some info/support regarding exchange APIs

Hi, I know a library named ccxt, almost composited all currencies:
https://github.com/ccxt/ccxt

any comments?

Looks fine to me, rather well supported/updated & a huge following. I'd go with that for the price portion if you want it to be more advanced.
Although, it may be a tad overkill.

A simple request to https://blockchain.info/ticker will provide prices as well.


Title: Re: Implement a simple wallet
Post by: leonzh on December 23, 2018, 11:14:13 AM
Hi,

I don't have any "tutorial" nor code simple enough to give you. But I can help you to think about what do you need to implement.
First what is a wallet ? It's an interface to the Bitcoin network.
In order to use it what do you need ? A key pair;
I think you should begin by generating key pairs in different formats (compressed, uncompressed, b58check-encoded, b58check-decoded, WIF-encoded, WIF-decoded, encrypted, etc..)

Hi thanks for reply.

If a "lightweight wallet" is what I need to implement,
1, generate key pair and address;
2, issue transaction
3, get balance
4, get exchange rate
are all what I suppose to do, and implement with bitcore-lib,
is there any good guide to show how to implement?



Thanks.



What currency pair are you looking for exchange wise? I can maybe give some info/support regarding exchange APIs

Hi, I know a library named ccxt, almost composited all currencies:
https://github.com/ccxt/ccxt

any comments?

Looks fine to me, rather well supported/updated & a huge following. I'd go with that for the price portion if you want it to be more advanced.
Although, it may be a tad overkill.

A simple request to https://blockchain.info/ticker will provide prices as well.

For bcoin, its bcoin program will run a node and sync chain data on local machine; but for blockchain.info apis, its wallet program does not require run a node to call api, why?


Title: Re: Implement a simple wallet
Post by: RedR00t on December 23, 2018, 02:41:44 PM
I need to implement a simple wallet using bitcore-lib by node.js.
Like manage private/public keys and addresses .

Is there any simple tutorial or example source code to show how to do this?

Thanks.

Bro you can use RPC for do this

https://github.com/Hanminji/BitcoinRPC

just you must keep Bitcoin Node working OR Electrum Wallet in Daemon mood


Title: Re: Implement a simple wallet
Post by: darosior on December 24, 2018, 11:34:41 AM
Quote
Bro you can use RPC for do this

https://github.com/Hanminji/BitcoinRPC

just you must keep Bitcoin Node working OR Electrum Wallet in Daemon mood
You cannot do everything just with RPC : you would have to use `importprivkey` at some point (or generate one) and that's neither secure (you have to trust the node, which generates the private keys, or knows about them) nor convenient (rescanning the funds when importing a private key, or if many people use it having all the pk of all the users on one node).
Moreover we can discuss the utility of doing so : it would just be a graphical interface to the daemon, which is exactly bitcoin-qt.