mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-12-24 20:39:21 +00:00
use getAddress with BTC, LTC, NMC, and PART
This commit is contained in:
parent
fb7c58f60a
commit
2dbd81fd4c
5 changed files with 33 additions and 38 deletions
|
@ -1297,7 +1297,8 @@ class BitcoinWallet extends CoinServiceAPI {
|
||||||
final priceData =
|
final priceData =
|
||||||
await _priceAPI.getPricesAnd24hChange(baseCurrency: _prefs.currency);
|
await _priceAPI.getPricesAnd24hChange(baseCurrency: _prefs.currency);
|
||||||
Decimal currentPrice = priceData[coin]?.item1 ?? Decimal.zero;
|
Decimal currentPrice = priceData[coin]?.item1 ?? Decimal.zero;
|
||||||
final locale = Platform.isWindows ? "en_US" : await Devicelocale.currentLocale;
|
final locale =
|
||||||
|
Platform.isWindows ? "en_US" : await Devicelocale.currentLocale;
|
||||||
final String worthNow = Format.localizedStringAsFixed(
|
final String worthNow = Format.localizedStringAsFixed(
|
||||||
value:
|
value:
|
||||||
((currentPrice * Decimal.fromInt(txData["recipientAmt"] as int)) /
|
((currentPrice * Decimal.fromInt(txData["recipientAmt"] as int)) /
|
||||||
|
@ -2502,7 +2503,7 @@ class BitcoinWallet extends CoinServiceAPI {
|
||||||
|
|
||||||
for (final out in tx["vout"] as List) {
|
for (final out in tx["vout"] as List) {
|
||||||
if (prevOut == out["n"]) {
|
if (prevOut == out["n"]) {
|
||||||
final address = out["scriptPubKey"]["address"] as String?;
|
final address = getAddress(out) as String?;
|
||||||
if (address != null) {
|
if (address != null) {
|
||||||
sendersArray.add(address);
|
sendersArray.add(address);
|
||||||
}
|
}
|
||||||
|
@ -2513,7 +2514,7 @@ class BitcoinWallet extends CoinServiceAPI {
|
||||||
Logging.instance.log("sendersArray: $sendersArray", level: LogLevel.Info);
|
Logging.instance.log("sendersArray: $sendersArray", level: LogLevel.Info);
|
||||||
|
|
||||||
for (final output in txObject["vout"] as List) {
|
for (final output in txObject["vout"] as List) {
|
||||||
final address = output["scriptPubKey"]["address"] as String?;
|
final address = getAddress(output);
|
||||||
if (address != null) {
|
if (address != null) {
|
||||||
recipientsArray.add(address);
|
recipientsArray.add(address);
|
||||||
}
|
}
|
||||||
|
@ -2553,7 +2554,7 @@ class BitcoinWallet extends CoinServiceAPI {
|
||||||
int totalOutput = 0;
|
int totalOutput = 0;
|
||||||
|
|
||||||
for (final output in txObject["vout"] as List) {
|
for (final output in txObject["vout"] as List) {
|
||||||
final String address = output["scriptPubKey"]!["address"] as String;
|
final String address = getAddress(output) as String;
|
||||||
final value = output["value"]!;
|
final value = output["value"]!;
|
||||||
final _value = (Decimal.parse(value.toString()) *
|
final _value = (Decimal.parse(value.toString()) *
|
||||||
Decimal.fromInt(Constants.satsPerCoin(coin)))
|
Decimal.fromInt(Constants.satsPerCoin(coin)))
|
||||||
|
@ -2578,7 +2579,7 @@ class BitcoinWallet extends CoinServiceAPI {
|
||||||
|
|
||||||
// add up received tx value
|
// add up received tx value
|
||||||
for (final output in txObject["vout"] as List) {
|
for (final output in txObject["vout"] as List) {
|
||||||
final address = output["scriptPubKey"]["address"];
|
final address = getAddress(output);
|
||||||
if (address != null) {
|
if (address != null) {
|
||||||
final value = (Decimal.parse(output["value"].toString()) *
|
final value = (Decimal.parse(output["value"].toString()) *
|
||||||
Decimal.fromInt(Constants.satsPerCoin(coin)))
|
Decimal.fromInt(Constants.satsPerCoin(coin)))
|
||||||
|
@ -3095,7 +3096,7 @@ class BitcoinWallet extends CoinServiceAPI {
|
||||||
for (final output in tx["vout"] as List) {
|
for (final output in tx["vout"] as List) {
|
||||||
final n = output["n"];
|
final n = output["n"];
|
||||||
if (n != null && n == utxosToUse[i].vout) {
|
if (n != null && n == utxosToUse[i].vout) {
|
||||||
final address = output["scriptPubKey"]["address"] as String;
|
final address = getAddress(output) as String;
|
||||||
if (!addressTxid.containsKey(address)) {
|
if (!addressTxid.containsKey(address)) {
|
||||||
addressTxid[address] = <String>[];
|
addressTxid[address] = <String>[];
|
||||||
}
|
}
|
||||||
|
|
|
@ -1064,7 +1064,8 @@ class DogecoinWallet extends CoinServiceAPI {
|
||||||
final priceData =
|
final priceData =
|
||||||
await _priceAPI.getPricesAnd24hChange(baseCurrency: _prefs.currency);
|
await _priceAPI.getPricesAnd24hChange(baseCurrency: _prefs.currency);
|
||||||
Decimal currentPrice = priceData[coin]?.item1 ?? Decimal.zero;
|
Decimal currentPrice = priceData[coin]?.item1 ?? Decimal.zero;
|
||||||
final locale = Platform.isWindows ? "en_US" : await Devicelocale.currentLocale;
|
final locale =
|
||||||
|
Platform.isWindows ? "en_US" : await Devicelocale.currentLocale;
|
||||||
final String worthNow = Format.localizedStringAsFixed(
|
final String worthNow = Format.localizedStringAsFixed(
|
||||||
value:
|
value:
|
||||||
((currentPrice * Decimal.fromInt(txData["recipientAmt"] as int)) /
|
((currentPrice * Decimal.fromInt(txData["recipientAmt"] as int)) /
|
||||||
|
@ -2113,7 +2114,7 @@ class DogecoinWallet extends CoinServiceAPI {
|
||||||
|
|
||||||
for (final out in tx["vout"] as List) {
|
for (final out in tx["vout"] as List) {
|
||||||
if (prevOut == out["n"]) {
|
if (prevOut == out["n"]) {
|
||||||
final address = out["scriptPubKey"]["addresses"][0] as String?;
|
final address = getAddress(out);
|
||||||
if (address != null) {
|
if (address != null) {
|
||||||
sendersArray.add(address);
|
sendersArray.add(address);
|
||||||
}
|
}
|
||||||
|
@ -2124,7 +2125,7 @@ class DogecoinWallet extends CoinServiceAPI {
|
||||||
Logging.instance.log("sendersArray: $sendersArray", level: LogLevel.Info);
|
Logging.instance.log("sendersArray: $sendersArray", level: LogLevel.Info);
|
||||||
|
|
||||||
for (final output in txObject["vout"] as List) {
|
for (final output in txObject["vout"] as List) {
|
||||||
final address = output["scriptPubKey"]["addresses"][0] as String?;
|
final address = getAddress(output);
|
||||||
if (address != null) {
|
if (address != null) {
|
||||||
recipientsArray.add(address);
|
recipientsArray.add(address);
|
||||||
}
|
}
|
||||||
|
@ -2164,7 +2165,7 @@ class DogecoinWallet extends CoinServiceAPI {
|
||||||
int totalOutput = 0;
|
int totalOutput = 0;
|
||||||
|
|
||||||
for (final output in txObject["vout"] as List) {
|
for (final output in txObject["vout"] as List) {
|
||||||
final address = output["scriptPubKey"]["addresses"][0];
|
final address = getAddress(output);
|
||||||
final value = output["value"];
|
final value = output["value"];
|
||||||
final _value = (Decimal.parse(value.toString()) *
|
final _value = (Decimal.parse(value.toString()) *
|
||||||
Decimal.fromInt(Constants.satsPerCoin(coin)))
|
Decimal.fromInt(Constants.satsPerCoin(coin)))
|
||||||
|
@ -2189,7 +2190,7 @@ class DogecoinWallet extends CoinServiceAPI {
|
||||||
|
|
||||||
// add up received tx value
|
// add up received tx value
|
||||||
for (final output in txObject["vout"] as List) {
|
for (final output in txObject["vout"] as List) {
|
||||||
final address = output["scriptPubKey"]["addresses"][0];
|
final address = getAddress(output);
|
||||||
if (address != null) {
|
if (address != null) {
|
||||||
final value = (Decimal.parse(output["value"].toString()) *
|
final value = (Decimal.parse(output["value"].toString()) *
|
||||||
Decimal.fromInt(Constants.satsPerCoin(coin)))
|
Decimal.fromInt(Constants.satsPerCoin(coin)))
|
||||||
|
@ -2712,7 +2713,7 @@ class DogecoinWallet extends CoinServiceAPI {
|
||||||
for (final output in tx["vout"] as List) {
|
for (final output in tx["vout"] as List) {
|
||||||
final n = output["n"];
|
final n = output["n"];
|
||||||
if (n != null && n == utxosToUse[i].vout) {
|
if (n != null && n == utxosToUse[i].vout) {
|
||||||
final address = output["scriptPubKey"]["addresses"][0] as String;
|
final address = getAddress(output) as String;
|
||||||
if (!addressTxid.containsKey(address)) {
|
if (!addressTxid.containsKey(address)) {
|
||||||
addressTxid[address] = <String>[];
|
addressTxid[address] = <String>[];
|
||||||
}
|
}
|
||||||
|
|
|
@ -1299,7 +1299,8 @@ class LitecoinWallet extends CoinServiceAPI {
|
||||||
final priceData =
|
final priceData =
|
||||||
await _priceAPI.getPricesAnd24hChange(baseCurrency: _prefs.currency);
|
await _priceAPI.getPricesAnd24hChange(baseCurrency: _prefs.currency);
|
||||||
Decimal currentPrice = priceData[coin]?.item1 ?? Decimal.zero;
|
Decimal currentPrice = priceData[coin]?.item1 ?? Decimal.zero;
|
||||||
final locale = Platform.isWindows ? "en_US" : await Devicelocale.currentLocale;
|
final locale =
|
||||||
|
Platform.isWindows ? "en_US" : await Devicelocale.currentLocale;
|
||||||
final String worthNow = Format.localizedStringAsFixed(
|
final String worthNow = Format.localizedStringAsFixed(
|
||||||
value:
|
value:
|
||||||
((currentPrice * Decimal.fromInt(txData["recipientAmt"] as int)) /
|
((currentPrice * Decimal.fromInt(txData["recipientAmt"] as int)) /
|
||||||
|
@ -2513,7 +2514,7 @@ class LitecoinWallet extends CoinServiceAPI {
|
||||||
|
|
||||||
for (final out in tx["vout"] as List) {
|
for (final out in tx["vout"] as List) {
|
||||||
if (prevOut == out["n"]) {
|
if (prevOut == out["n"]) {
|
||||||
final address = out["scriptPubKey"]["addresses"][0] as String?;
|
final address = getAddress(out) as String?;
|
||||||
if (address != null) {
|
if (address != null) {
|
||||||
sendersArray.add(address);
|
sendersArray.add(address);
|
||||||
}
|
}
|
||||||
|
@ -2524,7 +2525,7 @@ class LitecoinWallet extends CoinServiceAPI {
|
||||||
Logging.instance.log("sendersArray: $sendersArray", level: LogLevel.Info);
|
Logging.instance.log("sendersArray: $sendersArray", level: LogLevel.Info);
|
||||||
|
|
||||||
for (final output in txObject["vout"] as List) {
|
for (final output in txObject["vout"] as List) {
|
||||||
final address = output["scriptPubKey"]["addresses"][0] as String?;
|
final address = getAddress(output);
|
||||||
if (address != null) {
|
if (address != null) {
|
||||||
recipientsArray.add(address);
|
recipientsArray.add(address);
|
||||||
}
|
}
|
||||||
|
@ -2564,7 +2565,7 @@ class LitecoinWallet extends CoinServiceAPI {
|
||||||
int totalOutput = 0;
|
int totalOutput = 0;
|
||||||
|
|
||||||
for (final output in txObject["vout"] as List) {
|
for (final output in txObject["vout"] as List) {
|
||||||
final String address =
|
final String address = getAddress(output) as String;
|
||||||
final value = output["value"] ?? 0;
|
final value = output["value"] ?? 0;
|
||||||
final _value = (Decimal.parse(value.toString()) *
|
final _value = (Decimal.parse(value.toString()) *
|
||||||
Decimal.fromInt(Constants.satsPerCoin(coin)))
|
Decimal.fromInt(Constants.satsPerCoin(coin)))
|
||||||
|
@ -2589,7 +2590,7 @@ class LitecoinWallet extends CoinServiceAPI {
|
||||||
|
|
||||||
// add up received tx value
|
// add up received tx value
|
||||||
for (final output in txObject["vout"] as List) {
|
for (final output in txObject["vout"] as List) {
|
||||||
final address = output["scriptPubKey"]["addresses"][0];
|
final address = getAddress(output);
|
||||||
if (address != null) {
|
if (address != null) {
|
||||||
final value = (Decimal.parse((output["value"] ?? 0).toString()) *
|
final value = (Decimal.parse((output["value"] ?? 0).toString()) *
|
||||||
Decimal.fromInt(Constants.satsPerCoin(coin)))
|
Decimal.fromInt(Constants.satsPerCoin(coin)))
|
||||||
|
@ -3106,7 +3107,7 @@ class LitecoinWallet extends CoinServiceAPI {
|
||||||
for (final output in tx["vout"] as List) {
|
for (final output in tx["vout"] as List) {
|
||||||
final n = output["n"];
|
final n = output["n"];
|
||||||
if (n != null && n == utxosToUse[i].vout) {
|
if (n != null && n == utxosToUse[i].vout) {
|
||||||
final address = output["scriptPubKey"]["addresses"][0] as String;
|
final address = getAddress(output) as String;
|
||||||
if (!addressTxid.containsKey(address)) {
|
if (!addressTxid.containsKey(address)) {
|
||||||
addressTxid[address] = <String>[];
|
addressTxid[address] = <String>[];
|
||||||
}
|
}
|
||||||
|
|
|
@ -1287,7 +1287,8 @@ class NamecoinWallet extends CoinServiceAPI {
|
||||||
final priceData =
|
final priceData =
|
||||||
await _priceAPI.getPricesAnd24hChange(baseCurrency: _prefs.currency);
|
await _priceAPI.getPricesAnd24hChange(baseCurrency: _prefs.currency);
|
||||||
Decimal currentPrice = priceData[coin]?.item1 ?? Decimal.zero;
|
Decimal currentPrice = priceData[coin]?.item1 ?? Decimal.zero;
|
||||||
final locale = Platform.isWindows ? "en_US" : await Devicelocale.currentLocale;
|
final locale =
|
||||||
|
Platform.isWindows ? "en_US" : await Devicelocale.currentLocale;
|
||||||
final String worthNow = Format.localizedStringAsFixed(
|
final String worthNow = Format.localizedStringAsFixed(
|
||||||
value:
|
value:
|
||||||
((currentPrice * Decimal.fromInt(txData["recipientAmt"] as int)) /
|
((currentPrice * Decimal.fromInt(txData["recipientAmt"] as int)) /
|
||||||
|
@ -2494,11 +2495,7 @@ class NamecoinWallet extends CoinServiceAPI {
|
||||||
|
|
||||||
for (final out in tx["vout"] as List) {
|
for (final out in tx["vout"] as List) {
|
||||||
if (prevOut == out["n"]) {
|
if (prevOut == out["n"]) {
|
||||||
String? address = out["scriptPubKey"]["address"] as String?;
|
String? address = getAddress(out);
|
||||||
if (address == null && out["scriptPubKey"]["address"] != null) {
|
|
||||||
address = out["scriptPubKey"]["address"] as String?;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (address != null) {
|
if (address != null) {
|
||||||
sendersArray.add(address);
|
sendersArray.add(address);
|
||||||
}
|
}
|
||||||
|
@ -2509,10 +2506,7 @@ class NamecoinWallet extends CoinServiceAPI {
|
||||||
Logging.instance.log("sendersArray: $sendersArray", level: LogLevel.Info);
|
Logging.instance.log("sendersArray: $sendersArray", level: LogLevel.Info);
|
||||||
|
|
||||||
for (final output in txObject["vout"] as List) {
|
for (final output in txObject["vout"] as List) {
|
||||||
String? address = output["scriptPubKey"]["address"] as String?;
|
String? address = getAddress(output);
|
||||||
if (address == null && output["scriptPubKey"]["address"] != null) {
|
|
||||||
address = output["scriptPubKey"]["address"] as String?;
|
|
||||||
}
|
|
||||||
if (address != null) {
|
if (address != null) {
|
||||||
recipientsArray.add(address);
|
recipientsArray.add(address);
|
||||||
}
|
}
|
||||||
|
@ -2553,7 +2547,7 @@ class NamecoinWallet extends CoinServiceAPI {
|
||||||
|
|
||||||
for (final output in txObject["vout"] as List) {
|
for (final output in txObject["vout"] as List) {
|
||||||
Logging.instance.log(output, level: LogLevel.Info);
|
Logging.instance.log(output, level: LogLevel.Info);
|
||||||
final address = output["scriptPubKey"]["address"];
|
final address = getAddress(output);
|
||||||
final value = output["value"] ?? 0;
|
final value = output["value"] ?? 0;
|
||||||
final _value = (Decimal.parse(value.toString()) *
|
final _value = (Decimal.parse(value.toString()) *
|
||||||
Decimal.fromInt(Constants.satsPerCoin(coin)))
|
Decimal.fromInt(Constants.satsPerCoin(coin)))
|
||||||
|
@ -2578,10 +2572,7 @@ class NamecoinWallet extends CoinServiceAPI {
|
||||||
|
|
||||||
// add up received tx value
|
// add up received tx value
|
||||||
for (final output in txObject["vout"] as List) {
|
for (final output in txObject["vout"] as List) {
|
||||||
String? address = output["scriptPubKey"]["address"] as String?;
|
String? address = getAddress(output);
|
||||||
if (address == null && output["scriptPubKey"]["address"] != null) {
|
|
||||||
address = output["scriptPubKey"]["address"] as String?;
|
|
||||||
}
|
|
||||||
if (address != null) {
|
if (address != null) {
|
||||||
final value = (Decimal.parse((output["value"] ?? 0).toString()) *
|
final value = (Decimal.parse((output["value"] ?? 0).toString()) *
|
||||||
Decimal.fromInt(Constants.satsPerCoin(coin)))
|
Decimal.fromInt(Constants.satsPerCoin(coin)))
|
||||||
|
@ -3101,7 +3092,7 @@ class NamecoinWallet extends CoinServiceAPI {
|
||||||
for (final output in tx["vout"] as List) {
|
for (final output in tx["vout"] as List) {
|
||||||
final n = output["n"];
|
final n = output["n"];
|
||||||
if (n != null && n == utxosToUse[i].vout) {
|
if (n != null && n == utxosToUse[i].vout) {
|
||||||
final address = output["scriptPubKey"]["address"] as String;
|
final address = getAddress(output) as String;
|
||||||
if (!addressTxid.containsKey(address)) {
|
if (!addressTxid.containsKey(address)) {
|
||||||
addressTxid[address] = <String>[];
|
addressTxid[address] = <String>[];
|
||||||
}
|
}
|
||||||
|
|
|
@ -1200,7 +1200,8 @@ class ParticlWallet extends CoinServiceAPI {
|
||||||
final priceData =
|
final priceData =
|
||||||
await _priceAPI.getPricesAnd24hChange(baseCurrency: _prefs.currency);
|
await _priceAPI.getPricesAnd24hChange(baseCurrency: _prefs.currency);
|
||||||
Decimal currentPrice = priceData[coin]?.item1 ?? Decimal.zero;
|
Decimal currentPrice = priceData[coin]?.item1 ?? Decimal.zero;
|
||||||
final locale = Platform.isWindows ? "en_US" : await Devicelocale.currentLocale;
|
final locale =
|
||||||
|
Platform.isWindows ? "en_US" : await Devicelocale.currentLocale;
|
||||||
final String worthNow = Format.localizedStringAsFixed(
|
final String worthNow = Format.localizedStringAsFixed(
|
||||||
value:
|
value:
|
||||||
((currentPrice * Decimal.fromInt(txData["recipientAmt"] as int)) /
|
((currentPrice * Decimal.fromInt(txData["recipientAmt"] as int)) /
|
||||||
|
@ -2288,7 +2289,7 @@ class ParticlWallet extends CoinServiceAPI {
|
||||||
|
|
||||||
for (final out in tx["vout"] as List) {
|
for (final out in tx["vout"] as List) {
|
||||||
if (prevOut == out["n"]) {
|
if (prevOut == out["n"]) {
|
||||||
final address = out["scriptPubKey"]["addresses"][0] as String?;
|
final address = getAddress(out);
|
||||||
if (address != null) {
|
if (address != null) {
|
||||||
sendersArray.add(address);
|
sendersArray.add(address);
|
||||||
}
|
}
|
||||||
|
@ -2302,7 +2303,7 @@ class ParticlWallet extends CoinServiceAPI {
|
||||||
// Particl has different tx types that need to be detected and handled here
|
// Particl has different tx types that need to be detected and handled here
|
||||||
if (output.containsKey('scriptPubKey') as bool) {
|
if (output.containsKey('scriptPubKey') as bool) {
|
||||||
// Logging.instance.log("output is transparent", level: LogLevel.Info);
|
// Logging.instance.log("output is transparent", level: LogLevel.Info);
|
||||||
final address = output["scriptPubKey"]["addresses"][0] as String?;
|
final address = getAddress(output);
|
||||||
if (address != null) {
|
if (address != null) {
|
||||||
recipientsArray.add(address);
|
recipientsArray.add(address);
|
||||||
}
|
}
|
||||||
|
@ -2417,7 +2418,7 @@ class ParticlWallet extends CoinServiceAPI {
|
||||||
// add up received tx value
|
// add up received tx value
|
||||||
for (final output in txObject["vout"] as List) {
|
for (final output in txObject["vout"] as List) {
|
||||||
try {
|
try {
|
||||||
final address = output["scriptPubKey"]["addresses"][0];
|
final address = getAddress(output);
|
||||||
if (address != null) {
|
if (address != null) {
|
||||||
final value = (Decimal.parse((output["value"] ?? 0).toString()) *
|
final value = (Decimal.parse((output["value"] ?? 0).toString()) *
|
||||||
Decimal.fromInt(Constants.satsPerCoin(coin)))
|
Decimal.fromInt(Constants.satsPerCoin(coin)))
|
||||||
|
|
Loading…
Reference in a new issue