getUnconfirmed method
Returns list of unconfirmed transactions
- If
addresses
isString
, it will returnMap
with unconfirmed transaction details. - If
addresses
isList
of Strings andreturnAsMap
is true, it will returnMap
with cashAddress used as keys andMap
objects with address details in values. - If
addresses
isList
of Strings andreturnAsMap
is false, it will returnList
with details sorted in the same order as the input list of addresses. - Otherwise it will throw
FormatException
See https://developer.bitcoin.com/bitbox/docs/address#unconfirmed for details about the returned format. However note, that processing from array to map is done on the library side
Implementation
static Future<dynamic> getUnconfirmed(addresses,
[returnAsMap = false]) async {
final result = await _sendRequest("unconfirmed", addresses);
if (result is Map) {
return Utxo.convertMapListToUtxos(result["utxos"]);
} else if (result is List<Map>) {
final returnList = <Map>[];
final returnMap = <String, List>{};
result.forEach((addressUtxoMap) {
if (returnAsMap) {
returnMap[addressUtxoMap["cashAddr"]] =
Utxo.convertMapListToUtxos(addressUtxoMap["utxos"]);
} else {
addressUtxoMap["utxos"] =
Utxo.convertMapListToUtxos(addressUtxoMap["utxos"]);
returnList.add(addressUtxoMap);
}
});
return returnAsMap ? returnMap : returnList;
}
}