mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-10-31 17:37:41 +00:00
23 lines
568 B
Dart
23 lines
568 B
Dart
|
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 {
|
||
|
return bitcoin.P2PKH(
|
||
|
data: PaymentData(output: script),
|
||
|
network: networkType)
|
||
|
.data
|
||
|
.address;
|
||
|
} catch (_) {}
|
||
|
|
||
|
try {
|
||
|
return bitcoin.P2WPKH(
|
||
|
data: PaymentData(output: script),
|
||
|
network: networkType)
|
||
|
.data
|
||
|
.address;
|
||
|
} catch(_) {}
|
||
|
|
||
|
return null;
|
||
|
}
|