Skip to content

Commit 5769000

Browse files
committed
photon: add outpoint formatter for withdrawal bundle UTXOs
1 parent ebaa618 commit 5769000

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

photon/lib/pages/tabs/withdrawals_page.dart

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,20 +127,21 @@ class WithdrawalsPage extends StatelessWidget {
127127
child: ListenableBuilder(
128128
listenable: formatter,
129129
builder: (context, child) => SailTable(
130-
getRowId: (index) => model.bundle!.spendUtxos[index].outpoint,
130+
getRowId: (index) => _formatOutPoint(model.bundle!.spendUtxos[index].outPoint),
131131
headerBuilder: (context) => [
132132
SailTableHeaderCell(name: 'Outpoint'),
133133
SailTableHeaderCell(name: 'Value'),
134134
],
135135
rowBuilder: (context, row, selected) {
136136
final utxo = model.bundle!.spendUtxos[row];
137+
final outpointStr = _formatOutPoint(utxo.outPoint);
137138
final value = utxo.output.content.type == OutputContentType.value
138139
? formatter.formatSats(utxo.output.content.value!)
139140
: '-';
140141
return [
141142
SailTableCell(
142-
value: _truncateOutpoint(utxo.outpoint),
143-
copyValue: utxo.outpoint,
143+
value: _truncateOutpoint(outpointStr),
144+
copyValue: outpointStr,
144145
monospace: true,
145146
),
146147
SailTableCell(value: value, monospace: true),
@@ -166,6 +167,20 @@ class WithdrawalsPage extends StatelessWidget {
166167
);
167168
}
168169

170+
String _formatOutPoint(PWBOutPoint outPoint) {
171+
switch (outPoint.type) {
172+
case OutPointType.regular:
173+
final regular = outPoint.regular!;
174+
return '${regular.txid}:${regular.vout}';
175+
case OutPointType.coinbase:
176+
final coinbase = outPoint.coinbase!;
177+
return 'coinbase:${coinbase.merkleRoot}:${coinbase.vout}';
178+
case OutPointType.deposit:
179+
final deposit = outPoint.deposit!;
180+
return 'deposit:${deposit.txid}:${deposit.vout}';
181+
}
182+
}
183+
169184
String _truncateOutpoint(String outpoint) {
170185
if (outpoint.length <= 16) return outpoint;
171186
final parts = outpoint.split(':');

0 commit comments

Comments
 (0)