mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-18 02:07:43 +00:00
translate usedCoins to usedUTXOs
This commit is contained in:
parent
5d9dc02eb1
commit
01881aae4f
1 changed files with 33 additions and 8 deletions
|
@ -499,6 +499,35 @@ mixin SparkInterface on Bip39HDWallet, ElectrumXInterface {
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Find out which coins were used and translate them into UTXOs.
|
||||||
|
final usedUTXOs = coins.where((coin) {
|
||||||
|
return spend.usedCoins.any((usedCoin) {
|
||||||
|
return usedCoin.serializedCoin == coin.serializedCoinB64 &&
|
||||||
|
usedCoin.serializedCoinContext == coin.contextB64;
|
||||||
|
});
|
||||||
|
}).map((coin) {
|
||||||
|
return UTXO(
|
||||||
|
walletId: walletId,
|
||||||
|
txid: extractedTx.getId(),
|
||||||
|
vout: coin.groupId,
|
||||||
|
value: coin.value.toInt(),
|
||||||
|
name: '',
|
||||||
|
isBlocked: false, // true?
|
||||||
|
blockedReason: null, // "Used in Spark spend."?
|
||||||
|
isCoinbase: false,
|
||||||
|
blockHash: null,
|
||||||
|
blockHeight: coin.height,
|
||||||
|
blockTime: null,
|
||||||
|
address: null,
|
||||||
|
used: true,
|
||||||
|
otherData: jsonEncode((
|
||||||
|
groupId: coin.groupId,
|
||||||
|
serializedCoin: coin.serializedCoinB64,
|
||||||
|
serializedCoinContext: coin.contextB64,
|
||||||
|
)),
|
||||||
|
);
|
||||||
|
}).toList();
|
||||||
|
|
||||||
return txData.copyWith(
|
return txData.copyWith(
|
||||||
raw: rawTxHex,
|
raw: rawTxHex,
|
||||||
vSize: extractedTx.virtualSize(),
|
vSize: extractedTx.virtualSize(),
|
||||||
|
@ -523,7 +552,7 @@ mixin SparkInterface on Bip39HDWallet, ElectrumXInterface {
|
||||||
height: null,
|
height: null,
|
||||||
version: 3,
|
version: 3,
|
||||||
),
|
),
|
||||||
// TODO used coins
|
usedUTXOs: usedUTXOs,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -540,17 +569,13 @@ mixin SparkInterface on Bip39HDWallet, ElectrumXInterface {
|
||||||
Logging.instance.log("Sent txHash: $txHash", level: LogLevel.Info);
|
Logging.instance.log("Sent txHash: $txHash", level: LogLevel.Info);
|
||||||
|
|
||||||
txData = txData.copyWith(
|
txData = txData.copyWith(
|
||||||
// TODO mark spark coins as spent locally and update balance before waiting to check via electrumx?
|
usedUTXOs: txData.usedUTXOs,
|
||||||
|
|
||||||
// usedUTXOs:
|
|
||||||
// txData.usedUTXOs!.map((e) => e.copyWith(used: true)).toList(),
|
|
||||||
|
|
||||||
// TODO revisit setting these both
|
// TODO revisit setting these both
|
||||||
txHash: txHash,
|
txHash: txHash,
|
||||||
txid: txHash,
|
txid: txHash,
|
||||||
);
|
);
|
||||||
// // mark utxos as used
|
// mark utxos as used
|
||||||
// await mainDB.putUTXOs(txData.usedUTXOs!);
|
await mainDB.putUTXOs(txData.usedUTXOs!);
|
||||||
|
|
||||||
return await updateSentCachedTxData(txData: txData);
|
return await updateSentCachedTxData(txData: txData);
|
||||||
} catch (e, s) {
|
} catch (e, s) {
|
||||||
|
|
Loading…
Reference in a new issue