Skip to content

Commit 1ea9e60

Browse files
committed
Clarify Open CryptoPay commit capabilities
1 parent f7fdf0f commit 1ea9e60

3 files changed

Lines changed: 12 additions & 5 deletions

File tree

lib/services/open_crypto_pay/method_support.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ class OpenCryptoPayMethodSupport {
1818
case 'Ethereum':
1919
case 'Bitcoin':
2020
case 'Firo':
21+
// Firo starts here for transparent/provider-broadcast payments; Spark
22+
// or oversized raw transactions fall back to txid at confirmation.
2123
return OpenCryptoPaySubmissionFlow.rawHexToProvider;
2224
case 'Lightning':
2325
case 'BinancePay':

lib/services/open_crypto_pay/models.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,4 +274,11 @@ class OpenCryptoPayCommit {
274274
});
275275

276276
bool get isExpired => expiresAt.isBefore(DateTime.now());
277+
278+
bool get canCommitRawHex =>
279+
submissionFlow == OpenCryptoPaySubmissionFlow.rawHexToProvider;
280+
281+
bool get canCommitTxId =>
282+
submissionFlow == OpenCryptoPaySubmissionFlow.txIdAfterLocalBroadcast ||
283+
method == 'Firo';
277284
}

lib/services/open_crypto_pay/open_crypto_pay_api.dart

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class OpenCryptoPayApi {
4444
}) async {
4545
final lnurl = LnurlUtils.extractLnurl(qrUrl);
4646
if (lnurl == null) {
47-
throw Exception('No lightning parameter found in URL');
47+
throw Exception('No LNURL payload found');
4848
}
4949

5050
final apiUrl = Uri.parse(LnurlUtils.decodeLnurl(lnurl));
@@ -132,9 +132,7 @@ class OpenCryptoPayApi {
132132
required OpenCryptoPayCommit commit,
133133
required String txId,
134134
}) async {
135-
if (commit.submissionFlow !=
136-
OpenCryptoPaySubmissionFlow.txIdAfterLocalBroadcast &&
137-
commit.method != 'Firo') {
135+
if (!commit.canCommitTxId) {
138136
throw UnsupportedError(
139137
'OpenCryptoPay method ${commit.method} cannot be committed with txid',
140138
);
@@ -149,7 +147,7 @@ class OpenCryptoPayApi {
149147
required OpenCryptoPayCommit commit,
150148
required String hex,
151149
}) async {
152-
if (commit.submissionFlow != OpenCryptoPaySubmissionFlow.rawHexToProvider) {
150+
if (!commit.canCommitRawHex) {
153151
throw UnsupportedError(
154152
'OpenCryptoPay method ${commit.method} cannot be committed with hex',
155153
);

0 commit comments

Comments
 (0)