Update README, add deprecation warning

This commit is contained in:
junderw 2019-07-19 15:10:58 +09:00
parent e19bc58b30
commit d05806fe69
No known key found for this signature in database
GPG key ID: B256185D3A971908
8 changed files with 28 additions and 0 deletions

View file

@ -85,6 +85,14 @@ The below examples are implemented as integration tests, they should be very eas
Otherwise, pull requests are appreciated. Otherwise, pull requests are appreciated.
Some examples interact (via HTTPS) with a 3rd Party Blockchain Provider (3PBP). Some examples interact (via HTTPS) with a 3rd Party Blockchain Provider (3PBP).
### Warning: Currently the tests use TransactionBuilder, which will be removed in the future (v6.x.x or higher)
We will move towards replacing all instances of TransactionBuilder in the tests with the new Psbt.
Currently we have a few examples on how to use the newer Psbt class at the following link:
- [Psbt examples](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/transactions-psbt.js)
The rest of the examples are below (using TransactionBuilder for Transaction creation)
- [Generate a random address](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/addresses.js) - [Generate a random address](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/addresses.js)
- [Import an address via WIF](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/addresses.js) - [Import an address via WIF](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/addresses.js)
- [Generate a 2-of-3 P2SH multisig address](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/addresses.js) - [Generate a 2-of-3 P2SH multisig address](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/addresses.js)

View file

@ -57,6 +57,13 @@ class TransactionBuilder {
this.__TX = new transaction_1.Transaction(); this.__TX = new transaction_1.Transaction();
this.__TX.version = 2; this.__TX.version = 2;
this.__USE_LOW_R = false; this.__USE_LOW_R = false;
console.warn(
'Deprecation Warning: TransactionBuilder will be removed in the future. ' +
'(v6.x.x or later) Please use the Psbt class instead. Examples of usage ' +
'are available in the transactions-psbt.js integration test file on our ' +
'Github. A high level explanation is available in the psbt.ts and psbt.js ' +
'files as well.',
);
} }
static fromTransaction(transaction, network) { static fromTransaction(transaction, network) {
const txb = new TransactionBuilder(network); const txb = new TransactionBuilder(network);

View file

@ -7,6 +7,7 @@ const bip65 = require('bip65')
const alice = bitcoin.ECPair.fromWIF('cScfkGjbzzoeewVWmU2hYPUHeVGJRDdFt7WhmrVVGkxpmPP8BHWe', regtest) const alice = bitcoin.ECPair.fromWIF('cScfkGjbzzoeewVWmU2hYPUHeVGJRDdFt7WhmrVVGkxpmPP8BHWe', regtest)
const bob = bitcoin.ECPair.fromWIF('cMkopUXKWsEzAjfa1zApksGRwjVpJRB3831qM9W4gKZsLwjHXA9x', regtest) const bob = bitcoin.ECPair.fromWIF('cMkopUXKWsEzAjfa1zApksGRwjVpJRB3831qM9W4gKZsLwjHXA9x', regtest)
console.warn = () => {} // Silence the Deprecation Warning
describe('bitcoinjs-lib (transactions w/ CLTV)', () => { describe('bitcoinjs-lib (transactions w/ CLTV)', () => {
// force update MTP // force update MTP

View file

@ -9,6 +9,7 @@ const alice = bitcoin.ECPair.fromWIF('cScfkGjbzzoeewVWmU2hYPUHeVGJRDdFt7WhmrVVGk
const bob = bitcoin.ECPair.fromWIF('cMkopUXKWsEzAjfa1zApksGRwjVpJRB3831qM9W4gKZsLwjHXA9x', regtest) const bob = bitcoin.ECPair.fromWIF('cMkopUXKWsEzAjfa1zApksGRwjVpJRB3831qM9W4gKZsLwjHXA9x', regtest)
const charles = bitcoin.ECPair.fromWIF('cMkopUXKWsEzAjfa1zApksGRwjVpJRB3831qM9W4gKZsMSb4Ubnf', regtest) const charles = bitcoin.ECPair.fromWIF('cMkopUXKWsEzAjfa1zApksGRwjVpJRB3831qM9W4gKZsMSb4Ubnf', regtest)
const dave = bitcoin.ECPair.fromWIF('cMkopUXKWsEzAjfa1zApksGRwjVpJRB3831qM9W4gKZsMwS4pqnx', regtest) const dave = bitcoin.ECPair.fromWIF('cMkopUXKWsEzAjfa1zApksGRwjVpJRB3831qM9W4gKZsMwS4pqnx', regtest)
console.warn = () => {} // Silence the Deprecation Warning
describe('bitcoinjs-lib (transactions w/ CSV)', () => { describe('bitcoinjs-lib (transactions w/ CSV)', () => {
// force update MTP // force update MTP

View file

@ -7,6 +7,7 @@ const keyPairs = [
bitcoin.ECPair.makeRandom({ network: NETWORK }), bitcoin.ECPair.makeRandom({ network: NETWORK }),
bitcoin.ECPair.makeRandom({ network: NETWORK }) bitcoin.ECPair.makeRandom({ network: NETWORK })
] ]
console.warn = () => {} // Silence the Deprecation Warning
async function buildAndSign (depends, prevOutput, redeemScript, witnessScript) { async function buildAndSign (depends, prevOutput, redeemScript, witnessScript) {
const unspent = await regtestUtils.faucetComplex(prevOutput, 5e4) const unspent = await regtestUtils.faucetComplex(prevOutput, 5e4)

View file

@ -3,6 +3,7 @@ const assert = require('assert')
const bitcoin = require('../../') const bitcoin = require('../../')
const regtestUtils = require('./_regtest') const regtestUtils = require('./_regtest')
const regtest = regtestUtils.network const regtest = regtestUtils.network
console.warn = () => {} // Silence the Deprecation Warning
function rng () { function rng () {
return Buffer.from('YT8dAtK4d16A3P1z+TpwB2jJ4aFH3g9M1EioIBkLEV4=', 'base64') return Buffer.from('YT8dAtK4d16A3P1z+TpwB2jJ4aFH3g9M1EioIBkLEV4=', 'base64')

View file

@ -9,6 +9,8 @@ const Transaction = require('..').Transaction
const TransactionBuilder = require('..').TransactionBuilder const TransactionBuilder = require('..').TransactionBuilder
const NETWORKS = require('../src/networks') const NETWORKS = require('../src/networks')
console.warn = () => {} // Silence the Deprecation Warning
const fixtures = require('./fixtures/transaction_builder') const fixtures = require('./fixtures/transaction_builder')
function constructSign (f, txb, useOldSignArgs) { function constructSign (f, txb, useOldSignArgs) {

View file

@ -146,6 +146,13 @@ export class TransactionBuilder {
this.__TX = new Transaction(); this.__TX = new Transaction();
this.__TX.version = 2; this.__TX.version = 2;
this.__USE_LOW_R = false; this.__USE_LOW_R = false;
console.warn(
'Deprecation Warning: TransactionBuilder will be removed in the future. ' +
'(v6.x.x or later) Please use the Psbt class instead. Examples of usage ' +
'are available in the transactions-psbt.js integration test file on our ' +
'Github. A high level explanation is available in the psbt.ts and psbt.js ' +
'files as well.',
);
} }
setLowR(setting?: boolean): boolean { setLowR(setting?: boolean): boolean {