Skip to content

Commit 761fc3d

Browse files
authored
add validation rules for rejection and expiration, use global secp (#468)
1 parent d5e39cf commit 761fc3d

File tree

26 files changed

+1204
-50
lines changed

26 files changed

+1204
-50
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* Add in-depth tests for bill validation
44
* Add recourse reason to `Recourse` block data
55
* (breaks existing persisted bills, if they had a recourse block)
6+
* Added `has_requested_funds` flag to `BillStatusWeb`, indicating the caller has requested funds (req to pay, req to recourse, offer to sell) at some point
7+
* Added `past_payments` endpoint to `Api.bill()`, which returns data about past payments and payment requests where the caller was the beneficiary
68

79
# 0.3.3
810

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,4 @@ getrandom = { version = "0.3.1", features = ["wasm_js"] }
3939
reqwest = { version = "0.12", default-features = false, features = ["json"] }
4040
async-broadcast = "0.7.2"
4141
rstest = "0.25.0"
42+
secp256k1 = { version = "0.29" }

crates/bcr-ebill-api/src/service/bill_service/data_fetching.rs

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,9 @@ impl BillService {
175175
redeemed_funds_available = true;
176176
}
177177

178+
let has_requested_funds =
179+
chain.is_beneficiary_from_a_request_funds_block(bill_keys, current_identity_node_id);
180+
178181
let mut offered_to_sell = false;
179182
let mut rejected_offer_to_sell = false;
180183
let mut offer_to_sell_timed_out = false;
@@ -260,18 +263,15 @@ impl BillService {
260263
time_of_request_to_accept = Some(req_to_accept_block.timestamp);
261264
rejected_to_accept = chain.block_with_operation_code_exists(BillOpCode::RejectToAccept);
262265

263-
if !accepted && !rejected_to_accept {
264-
if let Some(req_block) =
265-
chain.get_last_version_block_with_op_code(BillOpCode::RequestToAccept)
266-
{
267-
if util::date::check_if_deadline_has_passed(
268-
req_block.timestamp,
269-
current_timestamp,
270-
ACCEPT_DEADLINE_SECONDS,
271-
) {
272-
request_to_accept_timed_out = true;
273-
}
274-
}
266+
if !accepted
267+
&& !rejected_to_accept
268+
&& util::date::check_if_deadline_has_passed(
269+
req_to_accept_block.timestamp,
270+
current_timestamp,
271+
ACCEPT_DEADLINE_SECONDS,
272+
)
273+
{
274+
request_to_accept_timed_out = true;
275275
}
276276
}
277277

@@ -297,9 +297,7 @@ impl BillService {
297297
)
298298
.await;
299299

300-
let address_to_pay = self
301-
.bitcoin_client
302-
.get_address_to_pay(&bill_keys.public_key, &payment_info.seller.node_id)?;
300+
let address_to_pay = payment_info.payment_address;
303301

304302
let link_to_pay = self.bitcoin_client.generate_link_to_pay(
305303
&address_to_pay,
@@ -452,6 +450,7 @@ impl BillService {
452450
rejected_request_to_recourse,
453451
},
454452
redeemed_funds_available,
453+
has_requested_funds,
455454
};
456455

457456
let participants = BillParticipants {

0 commit comments

Comments
 (0)