mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-27 14:09:50 +00:00
5a7a0e01a7
* Make address to output script a single entry point Fix network type for bitcoin cash * Add MoonPay to sell polygon * Normalize currency for moonpay widget * Minor fix * fix: litecoin & bch address types * fix: remove print * fix: network decode location * fix: missing place additional network type * fix: wrong initial address page type * fix: initial address generation * fix: btc exchange sending all, bch without change addresses * Minor fixes * Update app versions [skip ci] --------- Co-authored-by: Rafael Saes <git@rafael.saes.dev>
19 lines
560 B
Dart
19 lines
560 B
Dart
import 'package:crypto/crypto.dart';
|
|
import 'package:cw_bitcoin/address_to_output_script.dart';
|
|
import 'package:bitcoin_base/bitcoin_base.dart' as bitcoin;
|
|
|
|
String scriptHash(String address, {required bitcoin.BasedUtxoNetwork network}) {
|
|
final outputScript = addressToOutputScript(address, network);
|
|
final parts = sha256.convert(outputScript).toString().split('');
|
|
var res = '';
|
|
|
|
for (var i = parts.length - 1; i >= 0; i--) {
|
|
final char = parts[i];
|
|
i--;
|
|
final nextChar = parts[i];
|
|
res += nextChar;
|
|
res += char;
|
|
}
|
|
|
|
return res;
|
|
}
|