BlockchainCommons / Community

Discussions & shared documents for stakeholders in Blockchain Commons
Other
68 stars 10 forks source link

INTERNSHIP PROJECT: Writing Coding in Different Languages for LBTCftCL #10

Closed shannona closed 3 years ago

shannona commented 4 years ago

We are looking to fill out Chapter 18 of Learning Bitcoin from the Command Line by offering up six short sections which each describe how to command bitcoind via RPC with a popular programming language.

We have six options:

Each of these sections will include how to set up a developer environment for programming Bitcoin in the language of choice; how to issue RPC commands and get results; how to do basic wallet manipulation; and (ultimately) how to send a transaction. The object is not to create any sort of complete program for the users (as we sort of do in the C sections), but just to show these short fragments to get users the barest of foundation.

Each section needs to be standardized into the same format, shown below, so that anyone can jump from one section to another and see the exact same code in different libraries.

We don't have this precise format anywhere, but take a look at the Java section which is 75% of the way there. The first and second chapters of C may also be of use for the general categories of what we want to do, but do note that (1) it's more in-depth than we want here, and (2) it shows how to write a complete program, which we're not doing here.

The overall concept here is simplicity and brevity. We want to do the minimum necessary to show this functionality, in brief, but leave the readers with enough knowledge to move forward on their own. Obviously, the scope of each chapter is intended to be much smaller than the large-scale C work in Issue #11

Here's the standard section names:

Setup [Language]

Setup the complete IDE for the user to program Bitcoin on a Debian machine using the language of choice. Assume they have none of it at start.

  1. Install anything necessary to code with the library

Setup [any sublibraries]

  1. Install any libraries necessary for accessing RPC
  2. Install any chosen Bitcoin libraries

Remember that our object here is to teach RPC-focused Bitcoin programming. Bitcoin libraries are good to use if that's their paradigm. Maybe the user isn't making the RPC callout themselves, but the functions should still be each tightly connected to an RPC command. If a Bitcoin library is higher level and obscures the RPC functionality, we should not be using it (but it's OK to reference it, below).

Build Your Connection

Make an RPC Call

Using "getmininginfo" as an example

Output Your Response

  1. Get the results
  2. Output the results
  3. Close the connection

Make an RPC Call with Arguments

Is it notably different to send an RPC call with arguments? If so, explain/demonstrate it here with the abstract methodology for encoding and setting parameters. (We'll use it more completely in some of the next section.)

Manipulate Your Wallet

Look Up Addresses

Look Up Funds

Create an Address

Create a Transaction

For More Information

[if there are links to how to do more programming in Bitcoin with this language, this is where to put them; we can link multiple sites, reference books, whatever you think will help people learn more.]

Summary

Just a few sentences on how you set things up and how they worked. See the summaries elsewhere in the course.

jodobear commented 4 years ago

@shannona I can take the lead to complete the Python section.

gg2001 commented 4 years ago

I can lead the completion of the NodeJS section. I can also help out with the Golang section.

shannona commented 4 years ago

Great. Tag me when you have a section complete & submit a PR. It'll sometimes take me a few days to get back. I'll offer some comments in the short-term, and will then do a full polish way down the road when I complete the big upgrade of the rest of the book.

Looking forward to seeing the material!

gg2001 commented 4 years ago

Sure, I'll be submitting a PR soon for the Node.js and Go sections.

The usage code in the README for bcrpc didn't work so I fixed it and submitted a PR. This is my bcrpc fork with the fix: https://github.com/gg2001/bcrpc.

javiervargas commented 4 years ago

I can lead the completion of the Java section.

javiervargas commented 4 years ago

@shannona Take a look. I'm deepening in Create a transaction section. https://github.com/javiervargas/Accesing_Bitcoind_with_Java/blob/master/18_2_Accessing_Bitcoind_with_Java.md

cprkrn commented 4 years ago

@shannona I can take the lead to complete the Python section.

Can help here.

shannona commented 4 years ago

@javiervargas So you inherited a previously written section that could use your work. Definitely feel free to revise what's there as much as you see fit.

Here's some ways you could clean up the previous sections that you inherited:

  1. I'm a bit confused at Maven vs gradle, and this might just be my personal inexperience with Java. But we show the package installation for Maven, and then it looks like gradle comes out of nowhere. Is that because it's a default (if so we should mention it) or is that because it's an alternative (if so, we should show how to get it)?

  2. This isn't quite laid out in the organization I suggest (see the major and minor sections in the outline, with the major sections being what's missing), but that's easy enough to change.

  3. I can't tell what's actually being done in "Look Up an Address". It seems to offer a function then set an address. Maybe we could show its usage and output?

  4. Similarly, "Create a Transaction" shows a function but now how to use it, and not how that connects with the "Send a Transaction" in the next section. (I don't even know what the second argument in sendToAddress is, though my guess is BTCs.

[Generally, we can always add brief explanation about what's being done.]

The summary you created is fine. If you're able to help polish things up (or change them, as you see fit), above, we can have a fine chapter here.

shannona commented 4 years ago

So far I've heard:

Go @gg2001 Java @javiervargas NodeJS @gg2001 Python @jodobear [help from @cprkrn ? ; you two should discuss] Rust (unwritten) Swift (unwritten)

Thanks folks!

jodobear commented 4 years ago

@shannona I can take the lead to complete the Python section.

Can help here.

Cool! I've already starrted writing it, will share and let's take it from there

javiervargas commented 4 years ago

@javiervargas So you inherited a previously written section that could use your work. Definitely feel free to revise what's there as much as you see fit.

Here's some ways you could clean up the previous sections that you inherited:

  1. I'm a bit confused at Maven vs gradle, and this might just be my personal inexperience with Java. But we show the package installation for Maven, and then it looks like gradle comes out of nowhere. Is that because it's a default (if so we should mention it) or is that because it's an alternative (if so, we should show how to get it)?
  2. This isn't quite laid out in the organization I suggest (see the major and minor sections in the outline, with the major sections being what's missing), but that's easy enough to change.
  3. I can't tell what's actually being done in "Look Up an Address". It seems to offer a function then set an address. Maybe we could show its usage and output?
  4. Similarly, "Create a Transaction" shows a function but now how to use it, and not how that connects with the "Send a Transaction" in the next section. (I don't even know what the second argument in sendToAddress is, though my guess is BTCs.

[Generally, we can always add brief explanation about what's being done.]

The summary you created is fine. If you're able to help polish things up (or change them, as you see fit), above, we can have a fine chapter here.

  1. In that case I should create a maven project and show results and outputs. You're right, I understand gradle it's an alternative.
  2. OK,
  3. Same as case 1, I'll create methods for lookup an address and create a raw.
  4. I'll try to connect create and send tx and show output. Hope have it this weekend.
javiervargas commented 4 years ago

@shannona I've add more code and outputs to sections and completed others. Take a look and tell me if it's ready to merge.

https://github.com/javiervargas/Accesing_Bitcoind_with_Java/blob/master/18_2_Accessing_Bitcoind_with_Java.md

shannona commented 4 years ago

@shannona I've add more code and outputs to sections and completed others. Take a look and tell me if it's ready to merge.

https://github.com/javiervargas/Accesing_Bitcoind_with_Java/blob/master/18_2_Accessing_Bitcoind_with_Java.md

Looks great. I have one request:

You "List generatedBlocksHashes = rpcClient.generateToAddress(110, addr1);" but don't really explain what that's doing. If you can add some explanation of that, I think this is ready to PR.

Thanks!

javiervargas commented 4 years ago

Great!!

Ok, I’ll check it and add it.

shannona commented 4 years ago

Thanks, @javiervargas I've merged the Java content. Is "Javier Vargas" the correct credit for you?

shannona commented 4 years ago

And thanks to @jodobear I've merged in the Python section.

javiervargas commented 4 years ago

Thanks, @javiervargas I've merged the Java content. Is "Javier Vargas" the correct credit for you?

It's Ok!, thanks!.

shannona commented 4 years ago

A Note for is someone picks up the SWIFT section: we should consider basing it on (or referencing) the code in FullyNoded2.

gg2001 commented 4 years ago

@shannona I've completed the JavaScript section and I'm almost done with the Go section. I've submitted a pull request.

shannona commented 4 years ago

@gg2001, terrific, this was a very pleasant surprise!

I've looked it over and offered a general style suggestion that I think could help polish this up and make it an improved teaching piece.

gorazdko commented 4 years ago

Rust (unwritten)

~I'll write this.~ Written.

javiervargas commented 4 years ago

@shannona I've completed last C section and I've submitted a PR.

shannona commented 4 years ago

Hey Folks,

Thanks for all the great work on this. Here's the current status:

Go: Drafted by @gg2001, revisions requested Java: Updated by @javiervargas (DONE) NodeJS: Drafted by @gg2001, revisions requested Python: Written by @jodobear (DONE) Rust: Written by @gorazdko (DONE) Swift: Unwritten, but @Fonta1n3 has provided a basis at Issue #137

gg2001 commented 4 years ago

@shannona I just made some revisions to the Go and NodeJS sections.

shannona commented 3 years ago

We've got this fully completed as Chapter 17 (https://github.com/BlockchainCommons/Learning-Bitcoin-from-the-Command-Line/blob/master/17_0_Talking_to_Bitcoind_Other.md), which has been released under v2.0 of Learning Bitcoin.

Thanks for all intern updates to Learning Bitcoin: gg2001 (Go, Node.js sections), gorazdko (Rust section), Javier Vargas (C, Java, Lightning, Tor sections), jodobear (Appendix: Compiling Bitcoin, Python section). I wrote Swift, thanks to that code snipped supplied by Fonta1n3.