Gathering detailed insights and metrics for bech32-buffer
Gathering detailed insights and metrics for bech32-buffer
Gathering detailed insights and metrics for bech32-buffer
Gathering detailed insights and metrics for bech32-buffer
npm install bech32-buffer
95.8
Supply Chain
99.1
Quality
75.7
Maintenance
100
Vulnerability
100
License
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
21 Stars
283 Commits
10 Forks
3 Watching
3 Branches
3 Contributors
Updated on 10 Nov 2024
Minified
Minified + Gzipped
JavaScript (91.95%)
TypeScript (5.6%)
Shell (2.45%)
Cumulative downloads
Total Downloads
Last day
-27.9%
3,609
Compared to previous day
Last week
40%
33,139
Compared to previous week
Last month
230.1%
104,615
Compared to previous month
Last year
280.3%
381,204
Compared to previous year
30
Bech32 is a Bitcoin address format specified in BIP 173 and BIP 350. Among its advantages are: better adaptability to QR codes and in voice conversations, and improved error detection. This library generalizes Bech32 and its modified version (Bech32m) to encode any reasonably short byte buffers.
1declare function encode( 2 prefix: string, 3 data: Uint8Array, 4 encoding: 'bech32' | 'bech32m' = 'bech32' 5): string;
Encodes binary data
with the specified human-readable prefix
into a Bech32(m) string.
The case is preserved: if the prefix is uppercase, then the output will be uppercase
as well; otherwise, the output will be lowercase (including the case when the prefix does
not contain any letters).
bech32
or bech32m
String containing:
prefix
'1'
separator chardata
encoded with the variant of base32 encoding used by Bech32, andprefix
and data
1const bech32 = require('bech32-buffer'); 2const data = new Uint8Array(20); 3bech32.encode('test', data); 4// 'test1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqql6aptf'
1declare function decode(message: string): { 2 prefix: string, 3 encoding: 'bech32' | 'bech32m', 4 data: Uint8Array 5};
Extracts human-readable prefix and binary data from the Bech32-encoded string.
An object with the following fields:
bech32
or bech32m
Decoding may fail for a variety of reasons (e.g., invalid checksum, or invalid
chars in the input). In this case, decode()
throws an exception
with a descriptive message.
1const bech32 = require('bech32-buffer'); 2const data = 'lost1qsyq7yqh9gk0szs5'; 3bech32.decode(data); 4// { 5// prefix: 'lost', 6// encoding: 'bech32', 7// data: Uint8Array([ 4, 8, 15, 16, 23, 42 ]) 8// }
1declare class BitcoinAddress { 2 prefix: 'bc' | 'tb'; 3 scriptVersion: number; 4 data: Uint8Array; 5 6 static decode(message: string): BitcoinAddress; 7 constructor(prefix: 'bc' | 'tb', scriptVersion: number, data: Uint8Array); 8 encode(): string; 9 type(): void | 'p2wsh' | 'p2wpkh'; 10}
Provides basic functionality to work with Bech32 encoding of Bitcoin addresses.
Addresses can be decode
d from strings and encode
d into strings.
It is also possible to check the type
of an address. P2WSH and P2WPKH address
types are defined per BIP 141. Encoding constraints are defined per BIP 173
and BIP 350.
1const { BitcoinAddress } = require('bech32-buffer'); 2const address = BitcoinAddress.decode('BC1QW508D6QEJXTDG4Y5R3ZARVARY0C5XW7KV8F3T4'); 3// address.prefix === 'bc' 4// address.scriptVersion === 0 5// address.data.length === 20 6// address.type() === 'p2wpkh'
Use dist/bech32-buffer.min.js
from the package distribution
or your favorite browserifier. In the first case,
the library will be available as a bech32
global variable:
1<script src="bech32-buffer.min.js"></script> 2<!-- later --> 3<script> 4bech32.encode('test', new Uint8Array(20)); 5</script>
Check out the web demo to see how
bech32-buffer works in browser. It is also available in the examples
directory of the package.
BIP 173 is authored by Pieter Wuille and Greg Maxwell and is licensed under the 2-clause BSD license. BIP 350 is authored by Pieter Wuille and is licensed under the 2-clause BSD license.
There are at least 2 existing implementations of Bech32 for JavaScript:
bech32
packageBoth implementations are Bitcoin-specific, and the reference implementation is also not in the Npm / yarn package manager.
bech32-buffer is available under Apache-2.0 license.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
3 existing vulnerabilities detected
Details
Reason
5 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 4
Reason
dependency not pinned by hash detected -- score normalized to 4
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More