mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-28 06:28:41 +01:00
Upstream reformatted its whole tree in 16ddc0837. Matching it removes
formatting from the conflict surface of this and every later sync.
67 lines
1.2 KiB
Dart
67 lines
1.2 KiB
Dart
import 'package:cw_core/hive_type_ids.dart';
|
|
import 'package:hive/hive.dart';
|
|
|
|
part 'payjoin_session.part.dart';
|
|
|
|
// @HiveType(typeId: PAYJOIN_SESSION_TYPE_ID)
|
|
class PayjoinSession extends HiveObject {
|
|
PayjoinSession({
|
|
required this.walletId,
|
|
this.receiver,
|
|
this.sender,
|
|
this.pjUri,
|
|
this.status = "created",
|
|
this.inProgressSince,
|
|
this.rawAmount,
|
|
}) {
|
|
if (receiver == null) {
|
|
assert(sender != null);
|
|
assert(pjUri != null);
|
|
} else {
|
|
assert(receiver != null);
|
|
}
|
|
}
|
|
|
|
static const typeId = PAYJOIN_SESSION_TYPE_ID;
|
|
static const boxName = 'PayjoinSessions';
|
|
|
|
// @HiveField(0)
|
|
final String walletId;
|
|
|
|
// @HiveField(1)
|
|
final String? sender;
|
|
|
|
// @HiveField(2)
|
|
final String? receiver;
|
|
|
|
// @HiveField(3)
|
|
final String? pjUri;
|
|
|
|
// @HiveField(4)
|
|
String status;
|
|
|
|
// @HiveField(5)
|
|
DateTime? inProgressSince;
|
|
|
|
// @HiveField(6)
|
|
String? txId;
|
|
|
|
// @HiveField(7)
|
|
String? rawAmount;
|
|
|
|
// @HiveField(8)
|
|
String? error;
|
|
|
|
bool get isSenderSession => sender != null;
|
|
|
|
BigInt get amount => BigInt.parse(rawAmount ?? "0");
|
|
set amount(BigInt amount) => rawAmount = amount.toString();
|
|
}
|
|
|
|
enum PayjoinSessionStatus {
|
|
created,
|
|
inProgress,
|
|
success,
|
|
unrecoverable,
|
|
}
|