From 8e636b91d51b27e75584b06e5bc92e09d854f651 Mon Sep 17 00:00:00 2001 From: Rigidity Date: Sat, 9 Nov 2024 12:46:02 -0500 Subject: [PATCH] Allow custom nonce in requested payments --- crates/chia-sdk-offers/src/offer_builder.rs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/crates/chia-sdk-offers/src/offer_builder.rs b/crates/chia-sdk-offers/src/offer_builder.rs index 460aa8c2..21c2620b 100644 --- a/crates/chia-sdk-offers/src/offer_builder.rs +++ b/crates/chia-sdk-offers/src/offer_builder.rs @@ -44,9 +44,24 @@ impl OfferBuilder { /// Adds a list of requested payments for a given puzzle. /// It will use the nonce to create a new [`NotarizedPayment`] and add it to the requested payments. pub fn request

( + self, + ctx: &mut SpendContext, + puzzle: &P, + payments: Vec, + ) -> Result + where + P: ToClvm, + { + let nonce = self.data.nonce; + self.request_with_nonce(ctx, puzzle, nonce, payments) + } + + /// Adds a list of payments in a [`NotarizedPayment`] for a given puzzle and nonce. + pub fn request_with_nonce

( mut self, ctx: &mut SpendContext, puzzle: &P, + nonce: Bytes32, payments: Vec, ) -> Result where @@ -56,10 +71,7 @@ impl OfferBuilder { let puzzle_hash = ctx.tree_hash(puzzle_ptr).into(); let puzzle = Puzzle::parse(&ctx.allocator, puzzle_ptr); - let notarized_payment = NotarizedPayment { - nonce: self.data.nonce, - payments, - }; + let notarized_payment = NotarizedPayment { nonce, payments }; let notarized_payment_ptr = ctx.alloc(¬arized_payment)?; let notarized_payment_hash = ctx.tree_hash(notarized_payment_ptr);