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

Cake update v15 #2

Open
wants to merge 23 commits into
base: cake-update-v9
Choose a base branch
from
Open
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
30 changes: 30 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@
## 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 uncompressed 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)

## 4.9.1

* Resolved issue with transaction deserialization (Issue #9)

## 4.9.0

* Correct Bitcoin address network configuration.
* Resolve issue with Electrum fee estimation results.


## 4.8.0

* Update dependencies

## 4.7.0

* Update dependencies
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
52 changes: 52 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,55 @@
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:
# - 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