call electrumx mn collat call

This commit is contained in:
julian 2024-06-25 11:59:55 -06:00
parent 68180d04bb
commit 0c3fbfef6c
2 changed files with 41 additions and 2 deletions

View file

@ -1142,6 +1142,38 @@ class ElectrumXClient {
}
// ===========================================================================
Future<bool> isMasterNodeCollateral({
String? requestID,
required String txid,
required int index,
}) async {
try {
final start = DateTime.now();
final response = await request(
requestID: requestID,
command: "blockchain.checkifmncollateral",
args: [
txid,
index.toString(),
],
);
Logging.instance.log(
"Finished ElectrumXClient.isMasterNodeCollateral, "
"response: $response, "
"Duration=${DateTime.now().difference(start)}",
level: LogLevel.Info,
);
return response as bool? ?? false;
} catch (e) {
Logging.instance.log(e, level: LogLevel.Error);
rethrow;
}
}
// ===========================================================================
/// Get the current fee rate.
///
/// Returns a map with the kay "rate" that corresponds to the free rate in satoshis

View file

@ -631,9 +631,16 @@ class FiroWallet<T extends ElectrumXCurrencyInterface> extends Bip39HDWallet<T>
BigInt.from(jsonUTXO["value"] as int);
if (blocked) {
blockedReason = "Possible masternode output. "
blocked = await electrumXClient.isMasterNodeCollateral(
txid: jsonTX!["txid"] as String,
index: jsonUTXO["tx_pos"] as int,
);
}
if (blocked) {
blockedReason = "Masternode collateral. "
"Unlock and spend at your own risk.";
label = "Possible masternode";
label = "Masternode collateral";
}
}