Skip to content
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

Remove deprecated "new Buffer" in favor of "Buffer.from" #6

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions accounts/api-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ class ApiHelper {
*/
parseEntities(str) {
const ret = new WalletEntities()

if (typeof str !== 'string')
return ret

for (let item of str.split('|')) {
try {

Expand All @@ -47,7 +47,7 @@ class ApiHelper {

} else if (addrHelper.isSupportedPubKey(item) && !ret.hasPubKey(item)) {
// Derive pubkey as 3 addresses (P1PKH, P2WPKH/P2SH, BECH32)
const bufItem = new Buffer(item, 'hex')
const bufItem = Buffer.from(item, 'hex')

const funcs = [
addrHelper.p2pkhAddress,
Expand Down
12 changes: 6 additions & 6 deletions test/lib/bitcoin/addresses-helper-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,21 +80,21 @@ const VECTOR_5 = [


describe('AddressesHelper', function() {

describe('p2pkhAddress()', function() {
it('should successfully derive P2PKH addresses from pubkeys', function() {
for (const v of VECTOR_1) {
const pkb = new Buffer(v[0], 'hex')
const pkb = Buffer.from(v[0], 'hex')
const addr = addrHelper.p2pkhAddress(pkb)
assert(addr == v[1])
}
})
})

describe('p2wpkhP2shAddress()', function() {
it('should successfully derive P2WPKH-P2SH addresses from pubkeys', function() {
for (const v of VECTOR_1) {
const pkb = new Buffer(v[0], 'hex')
const pkb = Buffer.from(v[0], 'hex')
const addr = addrHelper.p2wpkhP2shAddress(pkb)
assert(addr == v[2])
}
Expand All @@ -104,7 +104,7 @@ describe('AddressesHelper', function() {
describe('p2wpkhAddress()', function() {
it('should successfully derive bech32 addresses from pubkeys', function() {
for (const v of VECTOR_1) {
const pkb = new Buffer(v[0], 'hex')
const pkb = Buffer.from(v[0], 'hex')
const addr = addrHelper.p2wpkhAddress(pkb)
assert(addr == v[3])
}
Expand Down Expand Up @@ -150,7 +150,7 @@ describe('AddressesHelper', function() {
const expectedResult = stc[2]

const sig = btcMessage.sign(msg, prefix, privKey, true)

// Check that library returns valid result
assert((sig.compare(targetSig) == 0) == expectedResult)

Expand Down