2022-01-27 09:20:51 +00:00
|
|
|
import 'dart:typed_data';
|
|
|
|
import 'package:bitcoin_flutter/bitcoin_flutter.dart' as bitcoin;
|
|
|
|
import 'package:bitcoin_flutter/src/payments/index.dart' show PaymentData;
|
|
|
|
|
|
|
|
String addressFromOutput(Uint8List script, bitcoin.NetworkType networkType) {
|
|
|
|
try {
|
2023-11-30 10:01:58 +00:00
|
|
|
return bitcoin.P2PKH(data: PaymentData(output: script), network: networkType).data.address!;
|
2022-01-27 09:20:51 +00:00
|
|
|
} catch (_) {}
|
|
|
|
|
|
|
|
try {
|
2023-11-30 10:01:58 +00:00
|
|
|
return bitcoin.P2WPKH(data: PaymentData(output: script), network: networkType).data.address!;
|
|
|
|
} catch (_) {}
|
|
|
|
|
|
|
|
try {
|
|
|
|
return bitcoin.P2TR(data: PaymentData(output: script), network: networkType).data.address!;
|
|
|
|
} catch (_) {}
|
2022-01-27 09:20:51 +00:00
|
|
|
|
2022-10-12 17:09:57 +00:00
|
|
|
return '';
|
2023-11-30 10:01:58 +00:00
|
|
|
}
|