cake_wallet/cw_bitcoin/lib/address_to_output_script.dart
Omar Hatem 5a7a0e01a7
Litcoin bitcoin cash fix (#1339)
* 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>
2024-03-21 04:51:57 +02:00

14 lines
474 B
Dart

import 'dart:typed_data';
import 'package:bitcoin_base/bitcoin_base.dart' as bitcoin;
List<int> addressToOutputScript(String address, bitcoin.BasedUtxoNetwork network) {
try {
if (network == bitcoin.BitcoinCashNetwork.mainnet) {
return bitcoin.BitcoinCashAddress(address).baseAddress.toScriptPubKey().toBytes();
}
return bitcoin.addressToOutputScript(address: address, network: network);
} catch (err) {
print(err);
return Uint8List(0);
}
}