mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-12-23 03:49:22 +00:00
WIP Isar transaction object skeletons
This commit is contained in:
parent
2da1e23251
commit
c4cc5b1a02
7 changed files with 164 additions and 6 deletions
30
lib/models/isar/models/blockchain_data/input.dart
Normal file
30
lib/models/isar/models/blockchain_data/input.dart
Normal file
|
@ -0,0 +1,30 @@
|
|||
import 'package:isar/isar.dart';
|
||||
import 'package:stackwallet/models/isar/models/blockchain_data/output.dart';
|
||||
import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart';
|
||||
|
||||
@Collection()
|
||||
class Input {
|
||||
Id id = Isar.autoIncrement;
|
||||
|
||||
late String txid;
|
||||
|
||||
late int vout;
|
||||
|
||||
late String? scriptSig;
|
||||
|
||||
late String? scriptSigAsm;
|
||||
|
||||
// TODO: find witness type // is it even used?
|
||||
// late List<dynamic>? witness;
|
||||
|
||||
late bool? isCoinbase;
|
||||
|
||||
late int? sequence;
|
||||
|
||||
late String? innerRedeemScriptAsm;
|
||||
|
||||
final prevOut = IsarLink<Output>();
|
||||
|
||||
@Backlink(to: 'inputs')
|
||||
final transaction = IsarLink<Transaction>();
|
||||
}
|
20
lib/models/isar/models/blockchain_data/output.dart
Normal file
20
lib/models/isar/models/blockchain_data/output.dart
Normal file
|
@ -0,0 +1,20 @@
|
|||
import 'package:isar/isar.dart';
|
||||
import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart';
|
||||
|
||||
@Collection()
|
||||
class Output {
|
||||
Id id = Isar.autoIncrement;
|
||||
|
||||
late String? scriptPubKey;
|
||||
|
||||
late String? scriptPubKeyAsm;
|
||||
|
||||
late String? scriptPubKeyType;
|
||||
|
||||
late String scriptPubKeyAddress;
|
||||
|
||||
late int value;
|
||||
|
||||
@Backlink(to: 'outputs')
|
||||
final transaction = IsarLink<Transaction>();
|
||||
}
|
59
lib/models/isar/models/blockchain_data/transaction.dart
Normal file
59
lib/models/isar/models/blockchain_data/transaction.dart
Normal file
|
@ -0,0 +1,59 @@
|
|||
import 'package:isar/isar.dart';
|
||||
import 'package:stackwallet/models/isar/models/blockchain_data/input.dart';
|
||||
import 'package:stackwallet/models/isar/models/blockchain_data/output.dart';
|
||||
import 'package:stackwallet/models/isar/models/transaction_note.dart';
|
||||
|
||||
@Collection()
|
||||
class Transaction {
|
||||
Id id = Isar.autoIncrement;
|
||||
|
||||
late String txid;
|
||||
|
||||
late bool confirmed;
|
||||
|
||||
late int confirmations;
|
||||
|
||||
late int timestamp;
|
||||
|
||||
late TransactionType txType;
|
||||
|
||||
late String subType;
|
||||
|
||||
late int amount;
|
||||
|
||||
// TODO: do we need this?
|
||||
// late List<dynamic> aliens;
|
||||
|
||||
late String worthAtBlockTimestamp;
|
||||
|
||||
late int fee;
|
||||
|
||||
late String address;
|
||||
|
||||
late int height;
|
||||
|
||||
late bool cancelled;
|
||||
|
||||
late String? slateId;
|
||||
|
||||
late String? otherData;
|
||||
|
||||
final inputs = IsarLinks<Input>();
|
||||
|
||||
final outputs = IsarLinks<Output>();
|
||||
|
||||
final note = IsarLink<TransactionNote>();
|
||||
}
|
||||
|
||||
// Used in Isar db and stored there as int indexes so adding/removing values
|
||||
// in this definition should be done extremely carefully in production
|
||||
enum TransactionType with IsarEnum<int> {
|
||||
// TODO: add more types before prod release?
|
||||
outgoing,
|
||||
incoming,
|
||||
sendToSelf, // should we keep this?
|
||||
anonymize; // firo specific
|
||||
|
||||
@override
|
||||
int get value => index;
|
||||
}
|
37
lib/models/isar/models/blockchain_data/utxo.dart
Normal file
37
lib/models/isar/models/blockchain_data/utxo.dart
Normal file
|
@ -0,0 +1,37 @@
|
|||
import 'package:isar/isar.dart';
|
||||
|
||||
@Collection()
|
||||
class UTXO {
|
||||
Id id = Isar.autoIncrement;
|
||||
|
||||
late String txid;
|
||||
|
||||
late int vout;
|
||||
|
||||
late Status status;
|
||||
|
||||
late int value;
|
||||
|
||||
late String fiatWorth;
|
||||
|
||||
late String txName;
|
||||
|
||||
late bool blocked;
|
||||
|
||||
late bool isCoinbase;
|
||||
}
|
||||
|
||||
@Embedded()
|
||||
class Status {
|
||||
Id id = Isar.autoIncrement;
|
||||
|
||||
late bool confirmed;
|
||||
|
||||
late int confirmations;
|
||||
|
||||
late String blockHash;
|
||||
|
||||
late int blockHeight;
|
||||
|
||||
late int blockTime;
|
||||
}
|
12
lib/models/isar/models/transaction_note.dart
Normal file
12
lib/models/isar/models/transaction_note.dart
Normal file
|
@ -0,0 +1,12 @@
|
|||
import 'package:isar/isar.dart';
|
||||
import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart';
|
||||
|
||||
@Collection()
|
||||
class TransactionNote {
|
||||
Id id = Isar.autoIncrement;
|
||||
|
||||
late String value;
|
||||
|
||||
@Backlink(to: 'note')
|
||||
final transaction = IsarLink<Transaction>();
|
||||
}
|
|
@ -803,21 +803,21 @@ packages:
|
|||
name: isar
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "3.0.0-dev.10"
|
||||
version: "3.0.5"
|
||||
isar_flutter_libs:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: isar_flutter_libs
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "3.0.0-dev.10"
|
||||
version: "3.0.5"
|
||||
isar_generator:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
name: isar_generator
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "3.0.0-dev.10"
|
||||
version: "3.0.5"
|
||||
js:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
|
@ -135,8 +135,8 @@ dependencies:
|
|||
file_picker: ^5.0.1
|
||||
connectivity_plus: 2.3.6+1
|
||||
# document_file_save_plus: ^1.0.5
|
||||
isar: 3.0.0-dev.10
|
||||
isar_flutter_libs: 3.0.0-dev.10 # contains the binaries
|
||||
isar: 3.0.5
|
||||
isar_flutter_libs: 3.0.5 # contains the binaries
|
||||
dropdown_button2: 1.7.2
|
||||
string_validator: ^0.3.0
|
||||
|
||||
|
@ -156,7 +156,7 @@ dev_dependencies:
|
|||
analyzer: ^4.6.0
|
||||
import_sorter: ^4.6.0
|
||||
flutter_lints: ^2.0.1
|
||||
isar_generator: 3.0.0-dev.10
|
||||
isar_generator: 3.0.5
|
||||
|
||||
flutter_icons:
|
||||
android: true
|
||||
|
|
Loading…
Reference in a new issue