@@ -54,8 +54,8 @@ class Address {
54
54
/// Returns information about the given Bitcoin Cash address.
55
55
///
56
56
/// See https://developer.bitcoin.com/bitbox/docs/util for details about returned format
57
- static Future <Map <String , dynamic >> validateAddress (String address) async =>
58
- await RestApi .sendGetRequest ("util/validateAddress" , address);
57
+ static Future <Map <String , dynamic >? > validateAddress (String address) async =>
58
+ await ( RestApi .sendGetRequest ("util/validateAddress" , address) as FutureOr < Map < String , dynamic >?> );
59
59
60
60
/// Returns details of the provided address or addresses
61
61
///
@@ -90,7 +90,7 @@ class Address {
90
90
return Utxo .convertMapListToUtxos (result["utxos" ]);
91
91
} else if (result is List <Map >) {
92
92
final returnList = < Map > [];
93
- final returnMap = < String , List > {};
93
+ final returnMap = < String ? , List > {};
94
94
95
95
result.forEach ((addressUtxoMap) {
96
96
if (returnAsMap) {
@@ -123,7 +123,7 @@ class Address {
123
123
return Utxo .convertMapListToUtxos (result["utxos" ]);
124
124
} else if (result is List ) {
125
125
final returnList = < Map > [];
126
- final returnMap = < String , List > {};
126
+ final returnMap = < String ? , List > {};
127
127
128
128
result.forEach ((addressUtxoMap) {
129
129
if (returnAsMap) {
@@ -147,7 +147,7 @@ class Address {
147
147
final decoded = _decode (address);
148
148
final testnet =
149
149
decoded['prefix' ] == "bchtest" || decoded['prefix' ] == "slptest" ;
150
- var version;
150
+ late var version;
151
151
if (testnet) {
152
152
switch (decoded['type' ]) {
153
153
case "P2PKH" :
@@ -171,7 +171,7 @@ class Address {
171
171
}
172
172
173
173
/// Converts legacy address to cash address
174
- static String toCashAddress (String address, [bool includePrefix = true ]) {
174
+ static String ? toCashAddress (String address, [bool includePrefix = true ]) {
175
175
final decoded = _decode (address);
176
176
switch (decoded["prefix" ]) {
177
177
case 'bitcoincash' :
@@ -195,7 +195,7 @@ class Address {
195
195
}
196
196
197
197
/// Converts legacy or cash address to SLP address
198
- static String toSLPAddress (String address, [bool includePrefix = true ]) {
198
+ static String ? toSLPAddress (String address, [bool includePrefix = true ]) {
199
199
final decoded = Address ._decode (address);
200
200
switch (decoded["prefix" ]) {
201
201
case 'bitcoincash' :
@@ -231,7 +231,7 @@ class Address {
231
231
}
232
232
233
233
/// Detects type of the address and returns [legacy] , [cashaddr] or [slpaddr]
234
- static String detectAddressFormat (String address) {
234
+ static String ? detectAddressFormat (String address) {
235
235
// decode the address to determine the format
236
236
final decoded = _decode (address);
237
237
// return the format
@@ -261,7 +261,7 @@ class Address {
261
261
/// [prefix] - Network prefix. E.g.: 'bitcoincash'.
262
262
/// [type] Type of address to generate. Either 'P2PKH' or 'P2SH'.
263
263
/// [hash] is the address hash, which can be decode either using [_decodeCashAddress()] or [_decodeLegacyAddress()]
264
- static _encode (String prefix, String type, Uint8List hash) {
264
+ static _encode (String prefix, String ? type, Uint8List hash) {
265
265
final prefixData = _prefixToUint5List (prefix) + Uint8List (1 );
266
266
final versionByte = _getTypeBits (type) + _getHashSizeBits (hash);
267
267
final payloadData =
@@ -278,7 +278,7 @@ class Address {
278
278
assert (addresses is String || addresses is List <String >);
279
279
280
280
if (addresses is String ) {
281
- return await RestApi .sendGetRequest ("address/$path " , addresses) as Map ;
281
+ return await RestApi .sendGetRequest ("address/$path " , addresses) as Map ? ;
282
282
} else if (addresses is List <String >) {
283
283
return await RestApi .sendPostRequest (
284
284
"address/$path " , "addresses" , addresses,
@@ -453,7 +453,7 @@ class Address {
453
453
throw FormatException ("Invalid Address Format: $address " );
454
454
}
455
455
456
- String exception;
456
+ late String exception;
457
457
// try to decode the address with either one or all three possible prefixes
458
458
for (int i = 0 ; i < prefixes.length; i++ ) {
459
459
final payload = _base32Decode (address);
@@ -514,7 +514,7 @@ class Address {
514
514
throw FormatException ("Invalid Address Format: $address " );
515
515
}
516
516
517
- String exception;
517
+ late String exception;
518
518
519
519
// try to decode the address with either one or all three possible prefixes
520
520
for (int i = 0 ; i < prefixes.length; i++ ) {
@@ -642,7 +642,7 @@ class Address {
642
642
final value = string[i];
643
643
if (! _CHARSET_INVERSE_INDEX .containsKey (value))
644
644
throw FormatException ("Invalid character '$value '" );
645
- data[i] = _CHARSET_INVERSE_INDEX [string[i]];
645
+ data[i] = _CHARSET_INVERSE_INDEX [string[i]]! ;
646
646
}
647
647
648
648
return data;
@@ -672,12 +672,12 @@ class Address {
672
672
673
673
/// Container for to make it easier to work with Utxos
674
674
class Utxo {
675
- final String txid;
676
- final int vout;
677
- final double amount;
678
- final int satoshis;
679
- final int height;
680
- final int confirmations;
675
+ final String ? txid;
676
+ final int ? vout;
677
+ final double ? amount;
678
+ final int ? satoshis;
679
+ final int ? height;
680
+ final int ? confirmations;
681
681
682
682
Utxo (this .txid, this .vout, this .amount, this .satoshis, this .height,
683
683
this .confirmations);
0 commit comments