Skip to content

Commit

Permalink
Set "https://mempool.space/" as default mempool url
Browse files Browse the repository at this point in the history
  • Loading branch information
erdemyerebasmaz committed Mar 27, 2024
1 parent e7eef16 commit ed689f3
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 13 deletions.
2 changes: 1 addition & 1 deletion lib/bloc/network/network_settings_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class NetworkSettingsBloc extends Cubit<NetworkSettingsState> with HydratedMixin
));
}

Future<String> get mempoolInstance async {
Future<String?> get mempoolInstance async {
String? mempoolInstance = await ServiceInjector().preferences.getMempoolSpaceUrl();
if (mempoolInstance == null) {
final config = await Config.instance();
Expand Down
8 changes: 4 additions & 4 deletions lib/config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ class Config {

final sdk.Config sdkConfig;
final sdk.NodeConfig nodeConfig;
final String defaultMempoolUrl;
final String? defaultMempoolUrl;

Config._({
required this.sdkConfig,
required this.nodeConfig,
required this.defaultMempoolUrl,
this.defaultMempoolUrl,
});

static Future<Config> instance({
Expand All @@ -33,7 +33,7 @@ class Config {
final breezSDK = injector.breezSDK;
final breezConfig = await _getBundledConfig();
final defaultConf = await _getDefaultConf(breezSDK, breezConfig.apiKey, breezConfig.nodeConfig);
final defaultMempoolUrl = defaultConf.mempoolspaceUrl;
final defaultMempoolUrl = defaultConf.mempoolspaceUrl ?? "https://mempool.space/";
final sdkConfig = await getSDKConfig(injector, defaultConf, breezConfig);

_instance = Config._(
Expand Down Expand Up @@ -99,7 +99,7 @@ class Config {
return configuredExemptFee;
}

static Future<String> _mempoolSpaceUrl(
static Future<String?> _mempoolSpaceUrl(
ServiceInjector serviceInjector,
sdk.Config defaultConf,
) async {
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/get-refund/widgets/refund_item_action.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class _RefundItemActionState extends State<RefundItemAction> {

return FutureBuilder(
future: networkSettingsBloc.mempoolInstance,
builder: (BuildContext context, AsyncSnapshot<String> snapshot) {
builder: (BuildContext context, AsyncSnapshot<String?> snapshot) {
if (snapshot.connectionState != ConnectionState.done) {
return const Loader();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ class ClosedChannelPaymentDetailsWidget extends StatelessWidget {
final texts = context.texts();
final networkSettingsBloc = context.read<NetworkSettingsBloc>();

return FutureBuilder<String>(
return FutureBuilder<String?>(
future: networkSettingsBloc.mempoolInstance,
builder: (BuildContext context, AsyncSnapshot<String> snapshot) {
builder: (BuildContext context, AsyncSnapshot<String?> snapshot) {
if (snapshot.connectionState != ConnectionState.done) {
return const Loader();
}
Expand All @@ -44,7 +44,9 @@ class ClosedChannelPaymentDetailsWidget extends StatelessWidget {
paymentMinutiae.closingTxid != null) ...[
TxWidget(
txURL: BlockChainExplorerUtils().formatTransactionUrl(
txid: paymentMinutiae.closingTxid!, mempoolInstance: mempoolInstance),
txid: paymentMinutiae.closingTxid!,
mempoolInstance: mempoolInstance,
),
txID: paymentMinutiae.closingTxid!,
),
],
Expand All @@ -67,14 +69,18 @@ class ClosedChannelPaymentDetailsWidget extends StatelessWidget {
if (paymentMinutiae.fundingTxid != null) ...[
TxWidget(
txURL: BlockChainExplorerUtils().formatTransactionUrl(
txid: paymentMinutiae.fundingTxid!, mempoolInstance: mempoolInstance),
txid: paymentMinutiae.fundingTxid!,
mempoolInstance: mempoolInstance,
),
txID: paymentMinutiae.fundingTxid!,
),
],
if (paymentMinutiae.closingTxid != null) ...[
TxWidget(
txURL: BlockChainExplorerUtils().formatTransactionUrl(
txid: paymentMinutiae.closingTxid!, mempoolInstance: mempoolInstance),
txid: paymentMinutiae.closingTxid!,
mempoolInstance: mempoolInstance,
),
txID: paymentMinutiae.closingTxid!,
),
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,10 @@ class _TxLink extends StatelessWidget {
return const Loader();
}

final transactionUrl =
BlockChainExplorerUtils().formatTransactionUrl(mempoolInstance: snapshot.data!, txid: txid);
final transactionUrl = BlockChainExplorerUtils().formatTransactionUrl(
mempoolInstance: snapshot.data!,
txid: lockupTxid,
);

return LinkLauncher(
linkName: txid,
Expand Down

0 comments on commit ed689f3

Please sign in to comment.