paynym bugfix

This commit is contained in:
julian 2023-02-15 18:39:36 -06:00
parent 7e2276394c
commit 774f2071b6
2 changed files with 30 additions and 1 deletions

View file

@ -1,3 +1,5 @@
import 'dart:convert';
import 'package:bip47/src/util.dart';
import 'package:decimal/decimal.dart';
import 'package:stackwallet/models/isar/models/isar_models.dart';
@ -156,6 +158,14 @@ mixin ElectrumXParsing {
for (final json in txData["vin"] as List) {
bool isCoinBase = json['coinbase'] != null;
String? witness;
if (json['witness'] != null && json['witness'] is String) {
witness = json['witness'] as String;
} else if (json['txinwitness'] != null) {
if (json['txinwitness'] is List) {
witness = jsonEncode(json['txinwitness']);
}
}
final input = Input(
txid: json['txid'] as String,
vout: json['vout'] as int? ?? -1,
@ -164,6 +174,7 @@ mixin ElectrumXParsing {
isCoinbase: isCoinBase ? isCoinBase : json['is_coinbase'] as bool?,
sequence: json['sequence'] as int?,
innerRedeemScriptAsm: json['innerRedeemscriptAsm'] as String?,
witness: witness,
);
ins.add(input);
}

View file

@ -732,6 +732,24 @@ mixin PaynymWalletInterface {
return false;
}
Uint8List? _pubKeyFromInput(Input input) {
final scriptSigComponents = input.scriptSigAsm?.split(" ") ?? [];
if (scriptSigComponents.length > 1) {
return scriptSigComponents[1].fromHex;
}
if (input.witness != null) {
try {
final witnessComponents = jsonDecode(input.witness!) as List;
if (witnessComponents.length == 2) {
return (witnessComponents[1] as String).fromHex;
}
} catch (_) {
//
}
}
return null;
}
Future<PaymentCode?> unBlindedPaymentCodeFromTransaction({
required Transaction transaction,
required Address myNotificationAddress,
@ -760,7 +778,7 @@ mixin PaynymWalletInterface {
final buffer = rev.buffer.asByteData();
buffer.setUint32(txPoint.length, txPointIndex, Endian.little);
final pubKey = designatedInput.scriptSigAsm!.split(" ")[1].fromHex;
final pubKey = _pubKeyFromInput(designatedInput)!;
final myPrivateKey = (await deriveNotificationBip32Node(
mnemonic: (await _getMnemonicString())!,