mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-17 17:57:40 +00:00
WIP: add particl
This commit is contained in:
parent
b0cee75b76
commit
401d4b568c
2 changed files with 17 additions and 7 deletions
|
@ -46,7 +46,7 @@ const int MINIMUM_CONFIRMATIONS = 1;
|
||||||
const int DUST_LIMIT = 294;
|
const int DUST_LIMIT = 294;
|
||||||
|
|
||||||
const String GENESIS_HASH_MAINNET =
|
const String GENESIS_HASH_MAINNET =
|
||||||
"000000000062b72c5e2ceb45fbc8587e807c155b0da735e6483dfba2f0a9c770";
|
"0000ee0784c195317ac95623e22fddb8c7b8825dc3998e0bb924d66866eccf4c";
|
||||||
const String GENESIS_HASH_TESTNET =
|
const String GENESIS_HASH_TESTNET =
|
||||||
"0000594ada5310b367443ee0afd4fa3d0bbd5850ea4e33cdc7d6a904a7ec7c90";
|
"0000594ada5310b367443ee0afd4fa3d0bbd5850ea4e33cdc7d6a904a7ec7c90";
|
||||||
|
|
||||||
|
@ -883,6 +883,8 @@ class ParticlWallet extends CoinServiceAPI {
|
||||||
|
|
||||||
if (currentHeight != storedHeight) {
|
if (currentHeight != storedHeight) {
|
||||||
if (currentHeight != -1) {
|
if (currentHeight != -1) {
|
||||||
|
Logging.instance
|
||||||
|
.log("Can update chain: $currentHeight", level: LogLevel.Info);
|
||||||
// -1 failed to fetch current height
|
// -1 failed to fetch current height
|
||||||
unawaited(updateStoredChainHeight(newHeight: currentHeight));
|
unawaited(updateStoredChainHeight(newHeight: currentHeight));
|
||||||
}
|
}
|
||||||
|
@ -2221,6 +2223,9 @@ class ParticlWallet extends CoinServiceAPI {
|
||||||
Logging.instance.log("allTransactions length: ${allTransactions.length}",
|
Logging.instance.log("allTransactions length: ${allTransactions.length}",
|
||||||
level: LogLevel.Info);
|
level: LogLevel.Info);
|
||||||
|
|
||||||
|
Logging.instance
|
||||||
|
.log("allTransactions is: $allTransactions", level: LogLevel.Info);
|
||||||
|
|
||||||
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;
|
||||||
|
@ -2246,9 +2251,12 @@ class ParticlWallet extends CoinServiceAPI {
|
||||||
final tx = await _cachedElectrumXClient.getTransaction(
|
final tx = await _cachedElectrumXClient.getTransaction(
|
||||||
txHash: prevTxid, coin: coin);
|
txHash: prevTxid, coin: coin);
|
||||||
|
|
||||||
|
Logging.instance
|
||||||
|
.log("RECEIVED TX IS : ${tx["vout"]}", level: LogLevel.Info);
|
||||||
|
|
||||||
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 = out["scriptPubKey"]["address"] as String?;
|
||||||
if (address != null) {
|
if (address != null) {
|
||||||
sendersArray.add(address);
|
sendersArray.add(address);
|
||||||
}
|
}
|
||||||
|
@ -2259,7 +2267,7 @@ class ParticlWallet 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 = output["scriptPubKey"]["address"] as String?;
|
||||||
if (address != null) {
|
if (address != null) {
|
||||||
recipientsArray.add(address);
|
recipientsArray.add(address);
|
||||||
}
|
}
|
||||||
|
@ -2300,8 +2308,9 @@ class ParticlWallet 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 = output["scriptPubKey"]["address"];
|
||||||
final value = output["value"];
|
final value = output["value"];
|
||||||
|
|
||||||
final _value = (Decimal.parse(value.toString()) *
|
final _value = (Decimal.parse(value.toString()) *
|
||||||
Decimal.fromInt(Constants.satsPerCoin))
|
Decimal.fromInt(Constants.satsPerCoin))
|
||||||
.toBigInt()
|
.toBigInt()
|
||||||
|
@ -2325,7 +2334,8 @@ 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) {
|
||||||
final address = output["scriptPubKey"]["addresses"][0];
|
final address = output["scriptPubKey"]["address"];
|
||||||
|
|
||||||
if (address != null) {
|
if (address != null) {
|
||||||
final value = (Decimal.parse(output["value"].toString()) *
|
final value = (Decimal.parse(output["value"].toString()) *
|
||||||
Decimal.fromInt(Constants.satsPerCoin))
|
Decimal.fromInt(Constants.satsPerCoin))
|
||||||
|
@ -3006,7 +3016,7 @@ class ParticlWallet extends CoinServiceAPI {
|
||||||
.log("Starting buildTransaction ----------", level: LogLevel.Info);
|
.log("Starting buildTransaction ----------", level: LogLevel.Info);
|
||||||
|
|
||||||
final txb = TransactionBuilder(network: _network);
|
final txb = TransactionBuilder(network: _network);
|
||||||
txb.setVersion(1);
|
txb.setVersion(160);
|
||||||
|
|
||||||
// Add transaction inputs
|
// Add transaction inputs
|
||||||
for (var i = 0; i < utxosToUse.length; i++) {
|
for (var i = 0; i < utxosToUse.length; i++) {
|
||||||
|
|
|
@ -87,7 +87,7 @@ class PriceAPI {
|
||||||
Map<Coin, Tuple2<Decimal, double>> result = {};
|
Map<Coin, Tuple2<Decimal, double>> result = {};
|
||||||
try {
|
try {
|
||||||
final uri = Uri.parse(
|
final uri = Uri.parse(
|
||||||
"https://api.coingecko.com/api/v3/coins/markets?vs_currency=${baseCurrency.toLowerCase()}&ids=monero,bitcoin,epic-cash,zcoin,dogecoin,bitcoin-cash,namecoin,wownero&order=market_cap_desc&per_page=10&page=1&sparkline=false");
|
"https://api.coingecko.com/api/v3/coins/markets?vs_currency=${baseCurrency.toLowerCase()}&ids=monero,bitcoin,epic-cash,zcoin,dogecoin,bitcoin-cash,namecoin,wownero,particl&order=market_cap_desc&per_page=10&page=1&sparkline=false");
|
||||||
// final uri = Uri.parse(
|
// final uri = Uri.parse(
|
||||||
// "https://api.coingecko.com/api/v3/coins/markets?vs_currency=${baseCurrency.toLowerCase()}&ids=monero%2Cbitcoin%2Cepic-cash%2Czcoin%2Cdogecoin&order=market_cap_desc&per_page=10&page=1&sparkline=false");
|
// "https://api.coingecko.com/api/v3/coins/markets?vs_currency=${baseCurrency.toLowerCase()}&ids=monero%2Cbitcoin%2Cepic-cash%2Czcoin%2Cdogecoin&order=market_cap_desc&per_page=10&page=1&sparkline=false");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue