mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-09-29 18:01:06 +00:00
run createSparkSend in isolate
This commit is contained in:
parent
94e69f193b
commit
c640d3e4cc
1 changed files with 87 additions and 26 deletions
|
@ -304,32 +304,36 @@ mixin SparkInterface on Bip39HDWallet, ElectrumXInterface {
|
||||||
);
|
);
|
||||||
extractedTx.setPayload(Uint8List(0));
|
extractedTx.setPayload(Uint8List(0));
|
||||||
|
|
||||||
final spend = LibSpark.createSparkSendTransaction(
|
final spend = await compute(
|
||||||
privateKeyHex: privateKey.toHex,
|
_createSparkSend,
|
||||||
index: kDefaultSparkIndex,
|
(
|
||||||
recipients: txData.recipients
|
privateKeyHex: privateKey.toHex,
|
||||||
?.map((e) => (
|
index: kDefaultSparkIndex,
|
||||||
address: e.address,
|
recipients: txData.recipients
|
||||||
amount: e.amount.raw.toInt(),
|
?.map((e) => (
|
||||||
subtractFeeFromAmount: isSendAll,
|
address: e.address,
|
||||||
))
|
amount: e.amount.raw.toInt(),
|
||||||
.toList() ??
|
subtractFeeFromAmount: isSendAll,
|
||||||
[],
|
))
|
||||||
privateRecipients: txData.sparkRecipients
|
.toList() ??
|
||||||
?.map((e) => (
|
[],
|
||||||
sparkAddress: e.address,
|
privateRecipients: txData.sparkRecipients
|
||||||
amount: e.amount.raw.toInt(),
|
?.map((e) => (
|
||||||
subtractFeeFromAmount: isSendAll,
|
sparkAddress: e.address,
|
||||||
memo: e.memo,
|
amount: e.amount.raw.toInt(),
|
||||||
))
|
subtractFeeFromAmount: isSendAll,
|
||||||
.toList() ??
|
memo: e.memo,
|
||||||
[],
|
))
|
||||||
serializedCoins: serializedCoins,
|
.toList() ??
|
||||||
allAnonymitySets: allAnonymitySets,
|
[],
|
||||||
idAndBlockHashes: idAndBlockHashes
|
serializedCoins: serializedCoins,
|
||||||
.map((e) => (setId: e.groupId, blockHash: base64Decode(e.blockHash)))
|
allAnonymitySets: allAnonymitySets,
|
||||||
.toList(),
|
idAndBlockHashes: idAndBlockHashes
|
||||||
txHash: extractedTx.getHash(),
|
.map(
|
||||||
|
(e) => (setId: e.groupId, blockHash: base64Decode(e.blockHash)))
|
||||||
|
.toList(),
|
||||||
|
txHash: extractedTx.getHash(),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
for (final outputScript in spend.outputScripts) {
|
for (final outputScript in spend.outputScripts) {
|
||||||
|
@ -853,6 +857,63 @@ String base64ToReverseHex(String source) =>
|
||||||
.map((e) => e.toRadixString(16).padLeft(2, '0'))
|
.map((e) => e.toRadixString(16).padLeft(2, '0'))
|
||||||
.join();
|
.join();
|
||||||
|
|
||||||
|
/// Top level function which should be called wrapped in [compute]
|
||||||
|
Future<
|
||||||
|
({
|
||||||
|
Uint8List serializedSpendPayload,
|
||||||
|
List<Uint8List> outputScripts,
|
||||||
|
int fee,
|
||||||
|
})> _createSparkSend(
|
||||||
|
({
|
||||||
|
String privateKeyHex,
|
||||||
|
int index,
|
||||||
|
List<
|
||||||
|
({
|
||||||
|
String address,
|
||||||
|
int amount,
|
||||||
|
bool subtractFeeFromAmount
|
||||||
|
})> recipients,
|
||||||
|
List<
|
||||||
|
({
|
||||||
|
String sparkAddress,
|
||||||
|
int amount,
|
||||||
|
bool subtractFeeFromAmount,
|
||||||
|
String memo
|
||||||
|
})> privateRecipients,
|
||||||
|
List<
|
||||||
|
({
|
||||||
|
String serializedCoin,
|
||||||
|
String serializedCoinContext,
|
||||||
|
int groupId,
|
||||||
|
int height,
|
||||||
|
})> serializedCoins,
|
||||||
|
List<
|
||||||
|
({
|
||||||
|
int setId,
|
||||||
|
String setHash,
|
||||||
|
List<({String serializedCoin, String txHash})> set
|
||||||
|
})> allAnonymitySets,
|
||||||
|
List<
|
||||||
|
({
|
||||||
|
int setId,
|
||||||
|
Uint8List blockHash,
|
||||||
|
})> idAndBlockHashes,
|
||||||
|
Uint8List txHash,
|
||||||
|
}) args) async {
|
||||||
|
final spend = LibSpark.createSparkSendTransaction(
|
||||||
|
privateKeyHex: args.privateKeyHex,
|
||||||
|
index: args.index,
|
||||||
|
recipients: args.recipients,
|
||||||
|
privateRecipients: args.privateRecipients,
|
||||||
|
serializedCoins: args.serializedCoins,
|
||||||
|
allAnonymitySets: args.allAnonymitySets,
|
||||||
|
idAndBlockHashes: args.idAndBlockHashes,
|
||||||
|
txHash: args.txHash,
|
||||||
|
);
|
||||||
|
|
||||||
|
return spend;
|
||||||
|
}
|
||||||
|
|
||||||
/// Top level function which should be called wrapped in [compute]
|
/// Top level function which should be called wrapped in [compute]
|
||||||
Future<List<SparkCoin>> _identifyCoins(
|
Future<List<SparkCoin>> _identifyCoins(
|
||||||
({
|
({
|
||||||
|
|
Loading…
Reference in a new issue