signTransaction method

Future<Transaction> signTransaction(
  1. Transaction? txnObj, {
  2. String? passphrase,
  3. Map<String, dynamic>? options,
})

sign transasction

Implementation

Future<Transaction> signTransaction(Transaction? txnObj,
    {String? passphrase, Map<String, dynamic>? options}) async {
  if (this.isEncrypted) {
    await this.decryptAccount(passphrase);
    await this.updateBalance();
    Map<String, dynamic> newTxMap = Map.from(txnObj!.txParams);
    newTxMap.update('nonce', (found) => this.nonce! + 1,
        ifAbsent: () => this.nonce! + 1);
    // var signed = crypto.SchnorrSign(this.privateKey, txnObj.txParams);
    var signed = await asyncSchnorrSign(this.privateKey, newTxMap);
    await this.encryptAccount(passphrase, options ?? {'level': 1024});
    return txnObj.map((Map obj) {
      obj.addAll(signed);
      return obj;
    });
  } else {
    await this.updateBalance();

    Map<String, dynamic> newTxMap = Map.from(txnObj!.txParams);

    newTxMap.update('nonce', (found) => this.nonce! + 1,
        ifAbsent: () => this.nonce! + 1);
    // var signed = crypto.SchnorrSign(this.privateKey, newTxMap);
    var signed = await asyncSchnorrSign(this.privateKey, newTxMap);
    return txnObj.map((Map obj) {
      obj.addAll(signed);
      return obj;
    });
  }
}