Skip to content

Commit

Permalink
V5.0.0
Browse files Browse the repository at this point in the history
* Update dependencies
* Minimum required Dart SDK version updated to 3.3.
  • Loading branch information
mrtnetwork committed Jan 2, 2025
1 parent 7fbb468 commit 78719a8
Show file tree
Hide file tree
Showing 119 changed files with 2,159 additions and 2,128 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
## 5.0.0
* Update dependencies
* Minimum required Dart SDK version updated to 3.3.

## 4.9.4

* Improved serialization process for large transaction scripts.
* Added support for the Electra network.
* Create and spent from uncomprossed public key format.
* Important Notice: This is the final version supporting Dart v2. The next release will require Dart v3.3 or higher.


## 4.9.2

* Update dependencies
* Resolved issue with transaction deserialization (unsigned tx)

Expand Down
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ In the [example](https://github.com/mrtnetwork/bitcoin_base/tree/main/example/li
await ElectrumWebSocketService.connect("184....");
/// create provider with service
final provider = ElectrumApiProvider(service);
final provider = ElectrumProvider(service);
/// spender details
final privateKey = ECPrivate.fromHex(
Expand Down Expand Up @@ -310,7 +310,7 @@ In the [example](https://github.com/mrtnetwork/bitcoin_base/tree/main/example/li
for (final i in spenders) {
/// Reads all UTXOs (Unspent Transaction Outputs) associated with the account
final elctrumUtxos = await provider
.request(ElectrumScriptHashListUnspent(scriptHash: i.pubKeyHash()));
.request(ElectrumRequestScriptHashListUnspent(scriptHash: i.pubKeyHash()));
/// Converts all UTXOs to a list of UtxoWithAddress, containing UTXO information along with address details.
/// read spender utxos
Expand Down Expand Up @@ -427,7 +427,7 @@ In the [example](https://github.com/mrtnetwork/bitcoin_base/tree/main/example/li
final raw = transaction.serialize();
/// send to network
await provider.request(ElectrumBroadCastTransaction(transactionRaw: raw));
await provider.request(ElectrumRequestBroadCastTransaction(transactionRaw: raw));
/// Once completed, we verify the status by checking the mempool or using another explorer to review the transaction details.
/// https://mempool.space/testnet/tx/70cf664bba4b5ac9edc6133e9c6891ffaf8a55eaea9d2ac99aceead1c3db8899
Expand All @@ -446,7 +446,7 @@ In the [example](https://github.com/mrtnetwork/bitcoin_base/tree/main/example/li
"wss://chipnet.imaginary.cash:50004");
/// create provider with service
final provider = ElectrumApiProvider(service);
final provider = ElectrumProvider(service);
/// initialize private key
final privateKey = ECPrivate.fromBytes(BytesUtils.fromHexString(
Expand All @@ -470,7 +470,7 @@ In the [example](https://github.com/mrtnetwork/bitcoin_base/tree/main/example/li
/// Reads all UTXOs (Unspent Transaction Outputs) associated with the account.
/// We does not need tokens utxo and we set to false.
final elctrumUtxos = await provider.request(ElectrumScriptHashListUnspent(
final elctrumUtxos = await provider.request(ElectrumRequestScriptHashListUnspent(
scriptHash: p2pkhAddress.baseAddress.pubKeyHash(),
includeTokens: true,
));
Expand Down Expand Up @@ -566,7 +566,7 @@ In the [example](https://github.com/mrtnetwork/bitcoin_base/tree/main/example/li
/// send transaction to network
await provider
.request(ElectrumBroadCastTransaction(transactionRaw: transactionRaw));
.request(ElectrumRequestBroadCastTransaction(transactionRaw: transactionRaw));
/// done! check the transaction in block explorer
/// https://chipnet.imaginary.cash/tx/97030c1236a024de7cad7ceadf8571833029c508e016bcc8173146317e367ae6
Expand Down Expand Up @@ -704,7 +704,7 @@ I haven't implemented any specific HTTP service or socket service within this pl
await ElectrumSSLService.connect("testnet.aranguren.org:51002");
/// create provider with service
final provider = ElectrumApiProvider(service);
final provider = ElectrumProvider(service);
final address = P2trAddress.fromAddress(address: ".....", network: network);
Expand All @@ -714,15 +714,15 @@ I haven't implemented any specific HTTP service or socket service within this pl
/// Return an ordered list of UTXOs sent to a script hash.
final accountUnspend = await provider
.request(ElectrumScriptHashListUnspent(scriptHash: address.pubKeyHash()));
.request(ElectrumRequestScriptHashListUnspent(scriptHash: address.pubKeyHash()));
/// Return the confirmed and unconfirmed history of a script hash.
final accountHistory = await provider
.request(ElectrumScriptHashGetHistory(scriptHash: address.pubKeyHash()));
/// Broadcast a transaction to the network.
final broadcastTransaction = await provider
.request(ElectrumBroadCastTransaction(transactionRaw: "txDigest"));
.request(ElectrumRequestBroadCastTransaction(transactionRaw: "txDigest"));
/// ....
```
Expand Down
55 changes: 51 additions & 4 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,56 @@
# include: package:lints/recommended.yaml
include: package:flutter_lints/flutter.yaml
# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
# Uncomment the following section to specify additional rules.
linter:
rules:
prefer_final_locals: true # Warns when a local variable could be final
prefer_final_in_for_each: true # Warns when a forEach variable could be final
prefer_const_constructors: true # Warns when a constructor could be const
prefer_const_declarations: true # Warns when a declaration could be const
- always_declare_return_types
- annotate_overrides
- avoid_init_to_null
- avoid_null_checks_in_equality_operators
- avoid_relative_lib_imports
- avoid_return_types_on_setters
- avoid_shadowing_type_parameters
- avoid_single_cascade_in_expression_statements
- avoid_types_as_parameter_names
- await_only_futures
- camel_case_extensions
- curly_braces_in_flow_control_structures
- empty_catches
- empty_constructor_bodies
- library_names
- library_prefixes
- no_duplicate_case_values
- null_closures
- omit_local_variable_types
- prefer_adjacent_string_concatenation
- prefer_collection_literals
- prefer_conditional_assignment
- prefer_contains
- prefer_equal_for_default_values
- prefer_final_fields
- prefer_for_elements_to_map_fromIterable
- prefer_generic_function_type_aliases
- prefer_if_null_operators
- prefer_inlined_adds
- prefer_is_empty
- prefer_is_not_empty
- prefer_iterable_whereType
- prefer_single_quotes
- prefer_spread_collections
- recursive_getters
- slash_for_doc_comments
- sort_child_properties_last
- type_init_formals
- unawaited_futures
- unnecessary_brace_in_string_interps
- unnecessary_const
- unnecessary_getters_setters
- unnecessary_new
- unnecessary_null_in_if_null_operators
- unnecessary_this
- unrelated_type_equality_checks
- use_function_type_syntax_for_parameters
- use_rethrow_when_possible
- valid_regexps
9 changes: 5 additions & 4 deletions example/lib/bitcoin_cash/burn_token_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ void main() async {
"wss://chipnet.imaginary.cash:50004");

/// create provider with service
final provider = ElectrumApiProvider(service);
final provider = ElectrumProvider(service);

/// initialize private key
final privateKey = ECPrivate.fromBytes(BytesUtils.fromHexString(
Expand All @@ -34,7 +34,8 @@ void main() async {

/// Reads all UTXOs (Unspent Transaction Outputs) associated with the account.
/// We does not need tokens utxo and we set to false.
final elctrumUtxos = await provider.request(ElectrumScriptHashListUnspent(
final elctrumUtxos =
await provider.request(ElectrumRequestScriptHashListUnspent(
scriptHash: p2pkhAddress.baseAddress.pubKeyHash(),
includeTokens: true,
));
Expand Down Expand Up @@ -141,8 +142,8 @@ void main() async {
final transactionRaw = transaaction.toHex();

/// send transaction to network
await provider
.request(ElectrumBroadCastTransaction(transactionRaw: transactionRaw));
await provider.request(
ElectrumRequestBroadCastTransaction(transactionRaw: transactionRaw));

/// done! check the transaction in block explorer
/// https://chipnet.imaginary.cash/tx/d85da44ba0c12ab8b0f4c636ca5451ae2c3a90b0f6d9e47fe381d0f5c6966ff3
Expand Down
9 changes: 5 additions & 4 deletions example/lib/bitcoin_cash/create_cash_token_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ void main() async {
"wss://chipnet.imaginary.cash:50004");

/// create provider with service
final provider = ElectrumApiProvider(service);
final provider = ElectrumProvider(service);

/// initialize private key
final privateKey = ECPrivate.fromBytes(BytesUtils.fromHexString(
Expand All @@ -29,7 +29,8 @@ void main() async {

/// Reads all UTXOs (Unspent Transaction Outputs) associated with the account.
/// We does not need tokens utxo and we set to false.
final elctrumUtxos = await provider.request(ElectrumScriptHashListUnspent(
final elctrumUtxos =
await provider.request(ElectrumRequestScriptHashListUnspent(
scriptHash: p2pkhAddress.pubKeyHash(),
includeTokens: false,
));
Expand Down Expand Up @@ -135,8 +136,8 @@ void main() async {
final transactionRaw = transaaction.toHex();

/// send transaction to network
await provider
.request(ElectrumBroadCastTransaction(transactionRaw: transactionRaw));
await provider.request(
ElectrumRequestBroadCastTransaction(transactionRaw: transactionRaw));

/// done! check the transaction in block explorer
/// https://chipnet.imaginary.cash/tx/fe0f9f84bd8782b8037160c09a515d39a9cc5bbeda6dcca6fb8a89e952bc9dea
Expand Down
9 changes: 5 additions & 4 deletions example/lib/bitcoin_cash/create_nft_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ void main() async {
"wss://chipnet.imaginary.cash:50004");

/// create provider with service
final provider = ElectrumApiProvider(service);
final provider = ElectrumProvider(service);

/// initialize private key
final privateKey = ECPrivate.fromBytes(BytesUtils.fromHexString(
Expand All @@ -30,7 +30,8 @@ void main() async {

/// Reads all UTXOs (Unspent Transaction Outputs) associated with the account.
/// We does not need tokens utxo and we set to false.
final elctrumUtxos = await provider.request(ElectrumScriptHashListUnspent(
final elctrumUtxos =
await provider.request(ElectrumRequestScriptHashListUnspent(
scriptHash: p2pkhAddress.baseAddress.pubKeyHash(),
includeTokens: false,
));
Expand Down Expand Up @@ -121,8 +122,8 @@ void main() async {
final transactionRaw = transaaction.toHex();

/// send transaction to network
await provider
.request(ElectrumBroadCastTransaction(transactionRaw: transactionRaw));
await provider.request(
ElectrumRequestBroadCastTransaction(transactionRaw: transactionRaw));

/// done! check the transaction in block explorer
/// https://chipnet.imaginary.cash/tx/4e153029c75963f39920184233756f8f55d5a8f86e01cbdaf0340320c814e25e
Expand Down
9 changes: 5 additions & 4 deletions example/lib/bitcoin_cash/make_vout0_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ void main() async {
await ElectrumSSLService.connect("chipnet.imaginary.cash:50002");

/// create provider with service
final provider = ElectrumApiProvider(service);
final provider = ElectrumProvider(service);

/// initialize private key
final privateKey = ECPrivate.fromBytes(BytesUtils.fromHexString(
Expand All @@ -30,7 +30,8 @@ void main() async {

/// Reads all UTXOs (Unspent Transaction Outputs) associated with the account.
/// We does not need tokens utxo and we set to false.
final elctrumUtxos = await provider.request(ElectrumScriptHashListUnspent(
final elctrumUtxos =
await provider.request(ElectrumRequestScriptHashListUnspent(
scriptHash: p2pkhAddress.pubKeyHash(),
includeTokens: false,
));
Expand Down Expand Up @@ -77,8 +78,8 @@ void main() async {
final transactionRaw = transaaction.toHex();

/// send transaction to network
await provider
.request(ElectrumBroadCastTransaction(transactionRaw: transactionRaw));
await provider.request(
ElectrumRequestBroadCastTransaction(transactionRaw: transactionRaw));

/// done! check the transaction in block explorer
/// https://chipnet.imaginary.cash/tx/b20d4c13fe67adc2f73aee0161eb51c7e813643ddc8eb655c6bd9ae72b7562cb
Expand Down
9 changes: 5 additions & 4 deletions example/lib/bitcoin_cash/minting_nft_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ void main() async {
await ElectrumWebSocketService.connect("wss://tbch4.loping.net:62004");

/// create provider with service
final provider = ElectrumApiProvider(service);
final provider = ElectrumProvider(service);

/// initialize private key
final privateKey = ECPrivate.fromBytes(BytesUtils.fromHexString(
Expand All @@ -30,7 +30,8 @@ void main() async {

/// Reads all UTXOs (Unspent Transaction Outputs) associated with the account.
/// We does not need tokens utxo and we set to false.
final elctrumUtxos = await provider.request(ElectrumScriptHashListUnspent(
final elctrumUtxos =
await provider.request(ElectrumRequestScriptHashListUnspent(
scriptHash: p2pkhAddress.baseAddress.pubKeyHash(),
includeTokens: true,
));
Expand Down Expand Up @@ -177,8 +178,8 @@ void main() async {
final transactionRaw = transaaction.toHex();

/// send transaction to network
await provider
.request(ElectrumBroadCastTransaction(transactionRaw: transactionRaw));
await provider.request(
ElectrumRequestBroadCastTransaction(transactionRaw: transactionRaw));

/// done! check the transaction in block explorer
/// https://tbch4.loping.net/tx/caa91b0fea2843a99c3cd7375ac4d3102b6b74a25e52cd866ad7ecc486204f0d
Expand Down
10 changes: 5 additions & 5 deletions example/lib/bitcoin_cash/p2sh32_spend_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ void main() async {
"wss://chipnet.imaginary.cash:50004");

/// create provider with service
final provider = ElectrumApiProvider(service);
final provider = ElectrumProvider(service);

/// initialize private key
final privateKey = ECPrivate.fromBytes(BytesUtils.fromHexString(
Expand Down Expand Up @@ -45,12 +45,12 @@ void main() async {
/// Reads all UTXOs (Unspent Transaction Outputs) associated with the account.
/// We does not need tokens utxo and we set to false.
final example1ElectrumUtxos =
await provider.request(ElectrumScriptHashListUnspent(
await provider.request(ElectrumRequestScriptHashListUnspent(
scriptHash: p2sh32Example1.baseAddress.pubKeyHash(),
includeTokens: false,
));
final example2ElectrumUtxos =
await provider.request(ElectrumScriptHashListUnspent(
await provider.request(ElectrumRequestScriptHashListUnspent(
scriptHash: p2sh32Example2.baseAddress.pubKeyHash(),
includeTokens: false,
));
Expand Down Expand Up @@ -111,8 +111,8 @@ void main() async {
final transactionRaw = transaaction.toHex();

/// send transaction to network
await provider
.request(ElectrumBroadCastTransaction(transactionRaw: transactionRaw));
await provider.request(
ElectrumRequestBroadCastTransaction(transactionRaw: transactionRaw));

/// done! check the transaction in block explorer
/// https://chipnet.imaginary.cash/tx/b76b851ce0374504591db414d7469aadb68649079defb26e44c62e970afda729
Expand Down
9 changes: 5 additions & 4 deletions example/lib/bitcoin_cash/send_ft_token_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ void main() async {
"wss://chipnet.imaginary.cash:50004");

/// create provider with service
final provider = ElectrumApiProvider(service);
final provider = ElectrumProvider(service);

/// initialize private key
final privateKey = ECPrivate.fromBytes(BytesUtils.fromHexString(
Expand All @@ -35,7 +35,8 @@ void main() async {

/// Reads all UTXOs (Unspent Transaction Outputs) associated with the account.
/// We does not need tokens utxo and we set to false.
final elctrumUtxos = await provider.request(ElectrumScriptHashListUnspent(
final elctrumUtxos =
await provider.request(ElectrumRequestScriptHashListUnspent(
scriptHash: p2pkhAddress.baseAddress.pubKeyHash(),
includeTokens: true,
));
Expand Down Expand Up @@ -136,8 +137,8 @@ void main() async {
final transactionRaw = transaaction.toHex();

/// send transaction to network
await provider
.request(ElectrumBroadCastTransaction(transactionRaw: transactionRaw));
await provider.request(
ElectrumRequestBroadCastTransaction(transactionRaw: transactionRaw));

/// done! check the transaction in block explorer
/// https://chipnet.imaginary.cash/tx/97030c1236a024de7cad7ceadf8571833029c508e016bcc8173146317e367ae6
Expand Down
Loading

0 comments on commit 78719a8

Please sign in to comment.