mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-03-12 09:27:01 +00:00
modify bip47 utils
This commit is contained in:
parent
6a0673bec5
commit
a25c03cb5c
1 changed files with 20 additions and 10 deletions
|
@ -1,24 +1,34 @@
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
|
|
||||||
import 'package:bip47/src/util.dart';
|
import 'package:bip47/src/util.dart';
|
||||||
|
import 'package:stackwallet/models/isar/models/blockchain_data/output.dart';
|
||||||
import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart';
|
import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart';
|
||||||
|
|
||||||
abstract class Bip47Utils {
|
abstract class Bip47Utils {
|
||||||
/// looks at tx outputs and returns a blinded payment code if found
|
/// looks at tx outputs and returns a blinded payment code if found
|
||||||
static Uint8List? getBlindedPaymentCodeBytesFrom(Transaction transaction) {
|
static Uint8List? getBlindedPaymentCodeBytesFrom(Transaction transaction) {
|
||||||
|
for (int i = 0; i < transaction.outputs.length; i++) {
|
||||||
|
final bytes = getBlindedPaymentCodeBytesFromOutput(
|
||||||
|
transaction.outputs.elementAt(i));
|
||||||
|
if (bytes != null) {
|
||||||
|
return bytes;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Uint8List? getBlindedPaymentCodeBytesFromOutput(Output output) {
|
||||||
Uint8List? blindedCodeBytes;
|
Uint8List? blindedCodeBytes;
|
||||||
|
|
||||||
for (int i = 0; i < transaction.outputs.length; i++) {
|
List<String>? scriptChunks = output.scriptPubKeyAsm?.split(" ");
|
||||||
List<String>? scriptChunks =
|
if (scriptChunks?.length == 2 && scriptChunks?[0] == "OP_RETURN") {
|
||||||
transaction.outputs.elementAt(i).scriptPubKeyAsm?.split(" ");
|
final blindedPaymentCode = scriptChunks![1];
|
||||||
if (scriptChunks?.length == 2 && scriptChunks?[0] == "OP_RETURN") {
|
final bytes = blindedPaymentCode.fromHex;
|
||||||
final blindedPaymentCode = scriptChunks![1];
|
|
||||||
final bytes = blindedPaymentCode.fromHex;
|
|
||||||
|
|
||||||
// https://en.bitcoin.it/wiki/BIP_0047#Sending
|
// https://en.bitcoin.it/wiki/BIP_0047#Sending
|
||||||
if (bytes.length == 80 && bytes.first == 1) {
|
if (bytes.length == 80 && bytes.first == 1) {
|
||||||
blindedCodeBytes = bytes;
|
blindedCodeBytes = bytes;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue