Skip to content

Commit d83e8fb

Browse files
committed
V4.7.0
Update dependencies
1 parent 560d845 commit d83e8fb

File tree

7 files changed

+68
-41
lines changed

7 files changed

+68
-41
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 4.7.0
2+
3+
* Update dependencies
4+
15
## 4.6.0
26

37
* add asyncTransactionBuilder method to support building transactions asynchronously.

example/pubspec.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ packages:
1515
path: ".."
1616
relative: true
1717
source: path
18-
version: "4.4.0"
18+
version: "4.7.0"
1919
blockchain_utils:
2020
dependency: "direct main"
2121
description:
2222
path: "../../blockchain_utils"
2323
relative: true
2424
source: path
25-
version: "3.1.0"
25+
version: "3.3.0"
2626
boolean_selector:
2727
dependency: transitive
2828
description:

example/pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ dependencies:
3939
path: ../
4040
blockchain_utils:
4141
path: ../../blockchain_utils
42-
# blockchain_utils: ^3.0.0
42+
# blockchain_utils: ^3.3.0
4343
http: ^1.2.0
4444

4545
dev_dependencies:

lib/src/models/network.dart

+8-9
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import 'package:bitcoin_base/bitcoin_base.dart';
22
import 'package:bitcoin_base/src/exception/exception.dart';
33
import 'package:bitcoin_base/src/utils/enumerate.dart';
44
import 'package:blockchain_utils/bip/bip/bip.dart';
5-
import 'package:blockchain_utils/bip/bip/conf/bip_coins.dart';
65
import 'package:blockchain_utils/bip/coin_conf/coin_conf.dart';
76
import 'package:blockchain_utils/bip/coin_conf/coins_conf.dart';
87

@@ -56,7 +55,7 @@ abstract class BasedUtxoNetwork implements Enumerate {
5655
return values.firstWhere((element) => element.value == name);
5756
}
5857

59-
List<CryptoCoins> get coins;
58+
List<BipCoins> get coins;
6059

6160
/// Checks if the current network is the mainnet.
6261
bool get isMainnet => this == BitcoinNetwork.mainnet;
@@ -108,7 +107,7 @@ class BitcoinSVNetwork implements BasedUtxoNetwork {
108107
[P2pkhAddressType.p2pkh, PubKeyAddressType.p2pk];
109108

110109
@override
111-
List<CryptoCoins> get coins {
110+
List<BipCoins> get coins {
112111
if (isMainnet) return [Bip44Coins.bitcoinSv];
113112
return [Bip44Coins.bitcoinSvTestnet];
114113
}
@@ -169,7 +168,7 @@ class BitcoinNetwork implements BasedUtxoNetwork {
169168
];
170169

171170
@override
172-
List<CryptoCoins> get coins {
171+
List<BipCoins> get coins {
173172
if (isMainnet) {
174173
return [
175174
Bip44Coins.bitcoin,
@@ -240,7 +239,7 @@ class LitecoinNetwork implements BasedUtxoNetwork {
240239
];
241240

242241
@override
243-
List<CryptoCoins> get coins {
242+
List<BipCoins> get coins {
244243
if (isMainnet) {
245244
return [Bip44Coins.litecoin, Bip49Coins.litecoin, Bip84Coins.litecoin];
246245
}
@@ -302,7 +301,7 @@ class DashNetwork implements BasedUtxoNetwork {
302301
final String value;
303302

304303
@override
305-
List<CryptoCoins> get coins {
304+
List<BipCoins> get coins {
306305
if (isMainnet) return [Bip44Coins.dash, Bip49Coins.dash];
307306
return [Bip44Coins.dashTestnet, Bip49Coins.dashTestnet];
308307
}
@@ -358,7 +357,7 @@ class DogecoinNetwork implements BasedUtxoNetwork {
358357
];
359358

360359
@override
361-
List<CryptoCoins> get coins {
360+
List<BipCoins> get coins {
362361
if (isMainnet) return [Bip44Coins.dogecoin, Bip49Coins.dogecoin];
363362
return [Bip44Coins.dogecoinTestnet, Bip49Coins.dogecoinTestnet];
364363
}
@@ -435,7 +434,7 @@ class BitcoinCashNetwork implements BasedUtxoNetwork {
435434
];
436435

437436
@override
438-
List<CryptoCoins> get coins {
437+
List<BipCoins> get coins {
439438
if (isMainnet) return [Bip44Coins.bitcoinCash, Bip49Coins.bitcoinCash];
440439
return [Bip44Coins.bitcoinCashTestnet, Bip49Coins.bitcoinCashTestnet];
441440
}
@@ -487,7 +486,7 @@ class PepeNetwork implements BasedUtxoNetwork {
487486
];
488487

489488
@override
490-
List<CryptoCoins> get coins {
489+
List<BipCoins> get coins {
491490
if (isMainnet) {
492491
return [Bip44Coins.pepecoin, Bip49Coins.pepecoin];
493492
}

lib/src/provider/api_provider/api_provider.dart

+17
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import 'dart:convert';
22
import 'package:bitcoin_base/src/provider/models/models.dart';
33
import 'package:bitcoin_base/src/provider/service/http/http_service.dart';
44
import 'package:bitcoin_base/src/models/network.dart';
5+
import 'package:blockchain_utils/utils/string/string.dart';
56

67
class ApiProvider {
78
ApiProvider(
@@ -138,4 +139,20 @@ class ApiProvider {
138139
return transactions;
139140
}
140141
}
142+
143+
Future<String> getBlockHeight(int height) async {
144+
final url = api.getBlockHeight(height);
145+
final response = await _getRequest<String>(url);
146+
switch (api.apiType) {
147+
case APIType.mempool:
148+
return response;
149+
default:
150+
final toJson = StringUtils.toJson<Map<String, dynamic>>(response);
151+
return toJson["hash"];
152+
}
153+
}
154+
155+
Future<String> genesis() async {
156+
return getBlockHeight(0);
157+
}
141158
}

lib/src/provider/models/config.dart

+32-25
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class APIConfig {
1010
final String transaction;
1111
final String transactions;
1212
final String sendTransaction;
13+
final String blockHeight;
1314
final APIType apiType;
1415
final BasedUtxoNetwork network;
1516

@@ -41,6 +42,11 @@ class APIConfig {
4142
return baseUrl.replaceAll("###", address);
4243
}
4344

45+
String getBlockHeight(int blockHaight) {
46+
String baseUrl = blockHeight;
47+
return baseUrl.replaceAll("###", "$blockHaight");
48+
}
49+
4450
factory APIConfig.fromBlockCypher(BasedUtxoNetwork network) {
4551
String baseUrl;
4652
switch (network) {
@@ -65,14 +71,15 @@ class APIConfig {
6571
}
6672

6773
return APIConfig(
68-
url: "$baseUrl/addrs/###/?unspentOnly=true&includeScript=true&limit=2000",
69-
feeRate: baseUrl,
70-
transaction: "$baseUrl/txs/###",
71-
sendTransaction: "$baseUrl/txs/push",
72-
apiType: APIType.blockCypher,
73-
transactions: "$baseUrl/addrs/###/full?limit=200",
74-
network: network,
75-
);
74+
url:
75+
"$baseUrl/addrs/###/?unspentOnly=true&includeScript=true&limit=2000",
76+
feeRate: baseUrl,
77+
transaction: "$baseUrl/txs/###",
78+
sendTransaction: "$baseUrl/txs/push",
79+
apiType: APIType.blockCypher,
80+
transactions: "$baseUrl/addrs/###/full?limit=200",
81+
network: network,
82+
blockHeight: "$baseUrl/blocks/###");
7683
}
7784

7885
factory APIConfig.mempool(BasedUtxoNetwork network) {
@@ -90,23 +97,23 @@ class APIConfig {
9097
}
9198

9299
return APIConfig(
93-
url: "$baseUrl/address/###/utxo",
94-
feeRate: "$baseUrl/v1/fees/recommended",
95-
transaction: "$baseUrl/tx/###",
96-
sendTransaction: "$baseUrl/tx",
97-
apiType: APIType.mempool,
98-
transactions: "$baseUrl/address/###/txs",
99-
network: network,
100-
);
100+
url: "$baseUrl/address/###/utxo",
101+
feeRate: "$baseUrl/v1/fees/recommended",
102+
transaction: "$baseUrl/tx/###",
103+
sendTransaction: "$baseUrl/tx",
104+
apiType: APIType.mempool,
105+
transactions: "$baseUrl/address/###/txs",
106+
network: network,
107+
blockHeight: "$baseUrl/block-height/###");
101108
}
102109

103-
APIConfig({
104-
required this.url,
105-
required this.feeRate,
106-
required this.transaction,
107-
required this.transactions,
108-
required this.sendTransaction,
109-
required this.apiType,
110-
required this.network,
111-
});
110+
APIConfig(
111+
{required this.url,
112+
required this.feeRate,
113+
required this.transaction,
114+
required this.transactions,
115+
required this.sendTransaction,
116+
required this.apiType,
117+
required this.network,
118+
required this.blockHeight});
112119
}

pubspec.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: bitcoin_base
22
description: A versatile library for Bitcoin, Dogecoin, Litecoin, Dash, BSV, and BCH. Supports P2PKH, P2SH, P2WPKH, P2WSH, P2TR, with advanced creation, signing, and spending capabilities.
3-
version: 4.6.0
3+
version: 4.7.0
44
homepage: "https://github.com/mrtnetwork/bitcoin_base"
55
repository: "https://github.com/mrtnetwork/bitcoin_base"
66
@@ -16,10 +16,10 @@ environment:
1616

1717

1818
dependencies:
19-
blockchain_utils: ^3.2.0
19+
# blockchain_utils: ^3.3.0
2020

21-
# blockchain_utils:
22-
# path: ../blockchain_utils
21+
blockchain_utils:
22+
path: ../blockchain_utils
2323

2424

2525
dev_dependencies:

0 commit comments

Comments
 (0)