mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-17 17:57:40 +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,7 +304,9 @@ mixin SparkInterface on Bip39HDWallet, ElectrumXInterface {
|
|||
);
|
||||
extractedTx.setPayload(Uint8List(0));
|
||||
|
||||
final spend = LibSpark.createSparkSendTransaction(
|
||||
final spend = await compute(
|
||||
_createSparkSend,
|
||||
(
|
||||
privateKeyHex: privateKey.toHex,
|
||||
index: kDefaultSparkIndex,
|
||||
recipients: txData.recipients
|
||||
|
@ -327,9 +329,11 @@ mixin SparkInterface on Bip39HDWallet, ElectrumXInterface {
|
|||
serializedCoins: serializedCoins,
|
||||
allAnonymitySets: allAnonymitySets,
|
||||
idAndBlockHashes: idAndBlockHashes
|
||||
.map((e) => (setId: e.groupId, blockHash: base64Decode(e.blockHash)))
|
||||
.map(
|
||||
(e) => (setId: e.groupId, blockHash: base64Decode(e.blockHash)))
|
||||
.toList(),
|
||||
txHash: extractedTx.getHash(),
|
||||
),
|
||||
);
|
||||
|
||||
for (final outputScript in spend.outputScripts) {
|
||||
|
@ -853,6 +857,63 @@ String base64ToReverseHex(String source) =>
|
|||
.map((e) => e.toRadixString(16).padLeft(2, '0'))
|
||||
.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]
|
||||
Future<List<SparkCoin>> _identifyCoins(
|
||||
({
|
||||
|
|
Loading…
Reference in a new issue