-
Notifications
You must be signed in to change notification settings - Fork 12
TheBitcoin #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Armss9936
wants to merge
14
commits into
TheBitcoinExplorerApp:main
Choose a base branch
from
Armss9936:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
TheBitcoin #17
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Snyk has created this PR to upgrade typescript from 5.3.3 to 5.8.3. See this package in npm: typescript See this project in Snyk: https://app.snyk.io/org/armss9936/project/057fe57e-41f1-4c61-b923-ffb472f411d8?utm_source=github&utm_medium=referral&page=upgrade-pr
Snyk has created this PR to upgrade @types/react from 18.2.79 to 18.3.23. See this package in npm: @types/react See this project in Snyk: https://app.snyk.io/org/armss9936/project/057fe57e-41f1-4c61-b923-ffb472f411d8?utm_source=github&utm_medium=referral&page=upgrade-pr
…39132b96be902 [Snyk] Upgrade @types/react from 18.2.79 to 18.3.23
…4fe8aaf7ef027 [Snyk] Upgrade typescript from 5.3.3 to 5.8.3
Snyk has created this PR to upgrade react-native-svg from 15.2.0 to 15.12.0. See this package in npm: react-native-svg See this project in Snyk: https://app.snyk.io/org/armss9936/project/057fe57e-41f1-4c61-b923-ffb472f411d8?utm_source=github&utm_medium=referral&page=upgrade-pr
…07ca5b6f1ce10 [Snyk] Upgrade react-native-svg from 15.2.0 to 15.12.0
Gordi769
approved these changes
Nov 4, 2025
Snyk has created this PR to upgrade @tanstack/react-query from 5.28.4 to 5.90.5. See this package in npm: @tanstack/react-query See this project in Snyk: https://app.snyk.io/org/armss9936/project/057fe57e-41f1-4c61-b923-ffb472f411d8?utm_source=github&utm_medium=referral&page=upgrade-pr
The following vulnerabilities are fixed with an upgrade: - https://snyk.io/vuln/SNYK-JS-JSYAML-13961110
…a2a10b0518 [Snyk] Fix for 1 vulnerabilities
The following vulnerabilities are fixed with an upgrade: - https://snyk.io/vuln/SNYK-JS-CROSSSPAWN-8303230 - https://snyk.io/vuln/SNYK-JS-BRACES-6838727 - https://snyk.io/vuln/SNYK-JS-MICROMATCH-6838728
…a9cd23b52b [Snyk] Security upgrade expo from 52.0.0 to 52.0.2
…a74e8e53a5c04 [Snyk] Upgrade @tanstack/react-query from 5.28.4 to 5.90.5
Snyk has created this PR to upgrade typescript from 5.8.3 to 5.9.3. See this package in npm: typescript See this project in Snyk: https://app.snyk.io/org/armss9936/project/057fe57e-41f1-4c61-b923-ffb472f411d8?utm_source=github&utm_medium=referral&page=upgrade-pr
…5707ed686de6a0 [Snyk] Upgrade typescript from 5.8.3 to 5.9.3
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Contributing to Bitcore
We're working hard to make bitcore the most powerful JavaScript library for working with bitcoin. Our goal is to have bitcore be a library that can be used by anyone interested in bitcoin, and to level expertise differences with great design and documentation.
Community
If there are any questions, etc., please feel to ask in one of the community channels:
Quick Checklist
Ideally, please make sure to run:
gulp testpasses all the tests (We run tests against Node.js v0.10, v0.12, io.js, and modern browsers)gulp coveragecovers 100% of the branches of your code (Seecoverage/lcov-report/index.htmlfor details)gulp lintdoesn't complain about your changesDesign Guidelines
These are some global design goals in bitcore that any change must adhere.
D1 - Naming Matters
We take our time with picking names. Code is going to be written once, and read hundreds of times.
We were inspired to name this rule first due to Uncle Bob's great work Clean Code, which has a whole chapter on this subject.
In particular, you may notice that some names in this library are quite long for the average JavaScript user. That's because we prefer a long but comprehensible name than an abbreviation that might confuse new users.
D2 - Tests
Write a test for all your code. We encourage Test Driven Development so we know when our code is right. We have increased test coverage from 80% to around 95% and are targeting 100% as we move towards our 1.0 release.
D3 - Robustness Principle
Be conservative in what you send, be liberal in what you accept.
Interfaces should accept as many types of arguments as possible, so there's no mental tax on using them: we want to avoid questions such as "should I use a string here or a buffer?", "what happens if I'm not sure if the type of this variable is an Address instance or a string with it encoded in base-58?" or "what kind of object will I receive after calling this function?".
Accept a wide variety of use cases and arguments, always return an internal form of an object. For example, the class
PublicKeycan accept strings or buffers with a DER encoded public key (either compressed or uncompressed), another PublicKey, a PrivateKey, or a Point, an instance of theelliptic.jslibrary with the point in bitcoin's elliptic curve that represents the public key.D4 - Consistency Everywhere
Consistency on the way classes are used is paramount to allow an easier understanding of the library.
Style Guidelines
The design guidelines have quite a high abstraction level. These style guidelines are more concrete and easier to apply, and also more opinionated. The design guidelines mentioned above are the way we think about general software development and we believe they should be present in any software project.
General
G0 - Default to Felixge's Style Guide
Follow this Node.js Style Guide: https://github.com/felixge/node-style-guide#nodejs-style-guide
G1 - No Magic Numbers
Avoid constants in the code as much as possible. Magic strings are also magic numbers.
G2 - Internal Objects Should be Instances
If a class has a
publicKeymember, for instance, that should be aPublicKeyinstance.G3 - Internal Amounts Must be Integers Representing Satoshis
Avoid representation errors by always dealing with satoshis. For conversion for frontends, use the
Unitclass.G4 - Internal Network References Must be Network Instances
A special case for G2 all network references must be
Networkinstances (seelib/network.js), but when returned to the user, its.nameproperty should be used.G5 - Objects Should Display Nicely in the Console
Write a
.inspect()method so an instance can be easily debugged in the console.G6 - Naming Utility Namespaces
Name them in UpperCamelCase, as they are namespaces.
DO:
DON'T:
G7 - Standard Methods
When possible, bitcore objects should have standard methods on an instance prototype:
toObject/toJSON- A plain JavaScript object thatJSON.stringifycan calltoString- A string representation of the instancetoBuffer- A hex BufferThese should have a matching static method that can be used for instantiation:
fromObject- Should be able to instantiate with the output fromtoObject/toJSONfromString- Should be able to instantiate with output fromtoStringfromBuffer- Should likewise be able to instantiate from output fromtoBufferJSON.stringifyandJSON.parseare expected to be handled outside of the scope of Bitcore methods. For example, callingJSON.stringifyon an Bitcore object will behave as expected and calltransaction.toJSON()and then stringify it:Likewise to instantiate a transaction from that string:
Errors
E1 - Use bitcore.Errors
We've designed a structure for Errors to follow and are slowly migrating to it.
Usage:
lib/errors/index.jsby invokinggulp errors.lib/errors/spec.jsfile.lib/errors/spec.js.lib/errors/spec.js, it should be clear how subclasses are generated from that file.E2 - Provide a
getValidationErrorStatic Method for ClassesInterface
I1 - Code that Fails Early
In order to deal with JavaScript's weak typing and confusing errors, we ask our code to fail as soon as possible when an unexpected input was provided.
There's a module called
util/preconditions, loosely based onpreconditions.js, based onguava, that we use for state and argument checking. It should be trivial to use. We recommend using it on all methods, in order to improve robustness and consistency.I2 - Permissive Constructors
Most classes have static methods named
fromBuffer,fromString,fromJSON. Whenever one of those methods is provided, the constructor for that class should also be able to detect the type of the arguments and call the appropriate method.I3 - Method Chaining
For classes that have a mutable state, most of the methods that can be chained SHOULD be chained, allowing for interfaces that read well, like:
I4 - Copy Constructors
Constructors, when provided an instance of the same class, should:
Examples:
I5 - No New Keyword for Constructors
Constructors should not require to be called with
new. This rule is not heavily enforced, but is a "nice to have".Testing
T1 - Tests Must be Written Elegantly
Style guidelines are not relaxed for tests. Tests are a good way to show how to use the library, and maintaining them is extremely necessary.
Don't write long tests, write helper functions to make them be as short and concise as possible (they should take just a few lines each), and use good variable names.
T2 - Tests Must not be Random
Inputs for tests should not be generated randomly. Also, the type and structure of outputs should be checked.
T3 - Require 'bitcore' and Look up Classes from There
This helps to make tests more useful as examples, and more independent of where they are placed. This also helps prevent forgetting to include all submodules in the bitcore object.
DO:
DON'T:
T4 - Data for Tests Included in a JSON File
If possible, data for tests should be included in a JSON file in the
test/datadirectory. This improves interoperability with other libraries and keeps tests cleaner.Documentation
D1 - Guide and API Reference
All modules should include a developer guide and API reference. The API reference documentation is generated using JSDOC. Each function that exposes a public API should include a description, @return and @param, as appropriate. The general documentation guide for the module should be located in the
docs/guidedirectory and is written in GitHub Flavored Markdown.D2 - Proofread
Please proofread documentation to avoid unintentional spelling and grammatical mistakes before submitting a pull request.
Pull Request Workflow
Our workflow is based on GitHub's pull requests. We use feature branches, prepended with:
test,feature,fix,refactor, orremoveaccording to the change the branch introduces. Some examples for such branches are:We expect pull requests to be rebased to the master branch before merging:
Note that we require rebasing your branch instead of merging it, for commit readability reasons.
After that, you can push the changes to your fork, by doing:
Finally go to github.com/bitpay/bitcore in your web browser and issue a new pull request.
Main contributors will review your code and possibly ask for changes before your code is pulled in to the main repository. We'll check that all tests pass, review the coding style, and check for general code correctness. If everything is OK, we'll merge your pull request and your code will be part of bitcore.
If you have any questions feel free to post them to
github.com/bitpay/bitcore/issues.
Thanks for your time and code!