From c873cbbad3f165810d63f9737cdb98cd3bc625ec Mon Sep 17 00:00:00 2001 From: Stephan February Date: Thu, 17 Aug 2023 20:08:51 +0800 Subject: [PATCH] 2.0.0-rc1 release prep --- CHANGELOG.md | 12 +++++++++ README.md | 70 ++++++++++++++++++++++++++++++++++------------------ pubspec.yaml | 2 +- 3 files changed, 59 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3554778..6e72307 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,15 @@ +## 2.0.0-rc1 + +Version 2.x is a major refactor of the internals. +This includes several breaking changes from the 1.x branch of development. + +The new features : +- A new `TransactionBuilder` class for composing Transactions +- Removal of the old Builder interface which was directly attached to the `Transaction` class +- A complete re-implementation of the Script Interpreter to align with the Bitcoin4J API +- The `Sighash` class now exposes the SigHash Pre-Image; useful when creating `OP_PUSH_TX` spending scripts. +- A new `ScriptBuilder` class to make it easy to create custom locking/unlocking scripts. + ## 1.1.1 - downgraded test dependencies to for Flutter compatibility diff --git a/README.md b/README.md index 6c00b52..c9f2fdd 100644 --- a/README.md +++ b/README.md @@ -5,20 +5,29 @@ ## Overview TwoStack WalletSDK is a Bitcoin library for the Dart Language \( [dartlang.org](https://dartlang.org) \), loosely based on the [Moneybutton/BSV](https://github.com/moneybutton/bsv) Javascript library. This library has been built in line with the ideals espoused by BitcoinSV, i.e. massive on-chain scaling, protocol stability and original-bitcoin-protocol implementation. +It is intended for use in building multi-platform applications using the Flutter framework, or server-side +bitcoin applications using frameworks like [Serverpod](https://serverpod.dev/) +### A note about Version 2.x (August 2023) +Version 2.x of the library is a major refactor and breaks backwards compatibility +with several previous library APIs. -This library therefore lacks , and will not implement : -* Segregated Witness \(Segwit\) Transaction support -* Schnorr Signature support -* Check Datasig \(OP\_CHECKDATASIG\) +* A new `TransactionBuilder` class for composing Transactions +* Removal of the old Builder interface which was directly attached to the `Transaction` class +* A complete re-implementation of the Script Interpreter +* The `Sighash` class now exposes the SigHash Pre-Image; useful when creating `OP_PUSH_TX` spending scripts. +* A new `ScriptBuilder` class to make it easy to create custom locking/unlocking scripts. +* Merged contributed code to have better Flutter Web support. -Current Supported features are : -* P2PKH Transactions -* P2SH Transactions -* P2MS Transactions (naked multisig) -* P2PK Transactions +Generally Supported features are : * Custom-Script Builder Interface to support novel locking/spending conditions within Script -* Data-only Transactions +* Pre-built library code to support "standard" locking/unlocking scripts + * P2PKH Transactions + * P2SH Transactions + * P2MS Transactions (naked multisig) + * P2PK Transactions + * Data-only Transactions (locked with `OP_FALSE OP_RETURN`) + * Spendable data-carrier Transactions (locked with `PUSH_DATA [your_data] OP_DROP [P2PKH locking code]`) * HD Key Derivation \(BIP32\) * Original Bitcoin Address format * Bitcoin Signed Messages @@ -29,23 +38,33 @@ Current Supported features are : #### Sample of the Transaction API: ```dart - var unlockBuilder = P2PKHUnlockBuilder(privateKey.publicKey); - var transaction = new Transaction() - .spendFromOutput(utxo, Transaction.NLOCKTIME_MAX_VALUE, scriptBuilder: unlockBuilder) - .spendTo(recipientAddress, BigInt.from(50000000), scriptBuilder: P2PKHLockBuilder(recipientAddress)) - .sendChangeTo(changeAddress, scriptBuilder: P2PKHLockBuilder(changeAddress)) - .withFeePerKb(1000); - - //Sign the Transaction Input - transaction.signInput(0, privateKey, sighashType: SighashType.SIGHASH_ALL | SighashType.SIGHASH_FORKID); + var utxo = txWithUTXO.outputs[0]; + var outpoint = TransactionOutpoint(txWithUTXO.id, 0, utxo.satoshis, utxo.script); + var signer = TransactionSigner(SighashType.SIGHASH_FORKID.value | SighashType.SIGHASH_ALL.value, privateKey); + + var unlocker = P2PKHUnlockBuilder(privateKey.publicKey); + + var transaction = TransactionBuilder() + .spendFromOutpointWithSigner(signer, outpoint, TransactionInput.MAX_SEQ_NUMBER, unlocker) + .spendToPKH(recipientAddress, BigInt.from(50000000)) //spend half of a bitcoin + .sendChangeToPKH(changeAddress) // spend change to a different address + .withFeePerKb(50) //set a fee of 50 satoshis per kilobyte + .build(false); //build the transaction, disabling checks + + //at this point you have a fully signed transaction ready to be broadcast + + try { + transaction.verify(); //perform a pre-broadcast sanity check on the transaction + } on VerificationException catch (ex){ + print("Transaction failed verification - ${ex.cause}"); + } ``` ### Installation -**Note**: Version 1.0.0 is a major version update to support Dart Null-Safety. -This library was built using version _2.14.3_ of the Dart SDK( [https://dart.dev/tools/sdk](https://dart.dev/tools/sdk) ). -As of Version 1.0.0 this library supports Dart Null Safety, and will therefore require a minimum SDK Version of 2.12.2. +This library was built using version _3.0.7_ of the Dart SDK( [https://dart.dev/tools/sdk](https://dart.dev/tools/sdk) ). +As of Version 1.0.0 this library supports Dart Null Safety. Current minimum Dart SDK version required is version _2.18.0_. Navigate to the root folder of this project, and pull the required supported Dart libraries using the `pub` package manager. @@ -63,7 +82,10 @@ In the root folder of this project, run the command: ## Acknowledgement -A debt of gratitude is owed to the developers acknowledged in the LICENSE file. Without the hard work of individuals working on earlier library and node implementations like Bitcoin Core, Bitcoin Cash, MoneyButton/BSV, BitcoinJ and many more, this library would likely not have come to fruition. Thank you. +A debt of gratitude is owed to the developers acknowledged in the LICENSE file. +Without the hard work of individuals working on earlier library and node +implementations like Bitcoin Core, Bitcoin Cash, MoneyButton/BSV, BitcoinJ and many +more, this library would likely not have come to fruition. Thank you. ## Contact @@ -71,5 +93,5 @@ You can reach the author at : * @twostack_org on Twitter * beardpappa@handcash.io \(PayMail to buy me a beer\) -* stephan@twostack.org +* stephan@twostack.org (drop me an email. GPG supported. ) diff --git a/pubspec.yaml b/pubspec.yaml index 2702be2..a4aa38c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: dartsv description: Dart Library for interacting with the Bitcoin network. This library is especially well-suited for use in developing Flutter applications. -version: 2.0.0 +version: 2.0.0-rc1 homepage: https://github.com/twostack/dartsv environment: