mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-03-26 00:58:50 +00:00
check all outputs for payment codes
This commit is contained in:
parent
6df782647e
commit
95d1f3c17e
1 changed files with 21 additions and 3 deletions
|
@ -696,8 +696,26 @@ mixin PaynymWalletInterface {
|
|||
}
|
||||
|
||||
try {
|
||||
final blindedCode =
|
||||
transaction.outputs.elementAt(1).scriptPubKeyAsm!.split(" ")[1];
|
||||
Uint8List? blindedCodeBytes;
|
||||
|
||||
for (int i = 0; i < transaction.outputs.length; i++) {
|
||||
List<String>? scriptChunks =
|
||||
transaction.outputs.elementAt(1).scriptPubKeyAsm?.split(" ");
|
||||
if (scriptChunks?.length == 2 && scriptChunks?[0] == "OP_RETURN") {
|
||||
final blindedPaymentCode = scriptChunks![1];
|
||||
final bytes = blindedPaymentCode.fromHex;
|
||||
|
||||
// https://en.bitcoin.it/wiki/BIP_0047#Sending
|
||||
if (bytes.length == 80 && bytes.first == 1) {
|
||||
blindedCodeBytes = bytes;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// transaction does not contain a payment code
|
||||
if (blindedCodeBytes == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final designatedInput = transaction.inputs.first;
|
||||
|
||||
|
@ -718,7 +736,7 @@ mixin PaynymWalletInterface {
|
|||
|
||||
final mask = PaymentCode.getMask(S.ecdhSecret(), rev);
|
||||
|
||||
final unBlindedPayload = PaymentCode.blind(blindedCode.fromHex, mask);
|
||||
final unBlindedPayload = PaymentCode.blind(blindedCodeBytes, mask);
|
||||
|
||||
final unBlindedPaymentCode =
|
||||
PaymentCode.initFromPayload(unBlindedPayload);
|
||||
|
|
Loading…
Reference in a new issue