Skip to content

Commit 49d4497

Browse files
committed
Signed-off-by: SuyashAlphaC <suyashagrawal862@gmail.com>
1 parent 3f3f610 commit 49d4497

2 files changed

Lines changed: 16 additions & 6 deletions

File tree

token/services/ttx/boolpolicy/spend.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,16 +239,21 @@ func (a *EndorseSpendView) Call(context view.Context) (interface{}, error) {
239239

240240
// verifySpendTxMatchesRequest fails if the received transaction does not consume
241241
// exactly the token referenced by the SpendRequest.
242+
//
243+
// We use Request.Inputs (not AuditRecord) on purpose: the co-owner is not the
244+
// auditor and so does not have audit-level visibility into the spent tokens.
245+
// Inputs returns the token IDs without trying to enrich them via ListAuditTokens,
246+
// which is exactly what we need for the equality check.
242247
func verifySpendTxMatchesRequest(ctx context.Context, tx *ttx.Transaction, request *SpendRequest) error {
243248
if request == nil || request.Token == nil {
244249
return errors.New("spend request is missing the token to authorize")
245250
}
246-
record, err := tx.Request().AuditRecord(ctx)
251+
inputs, err := tx.Request().Inputs(ctx)
247252
if err != nil {
248-
return errors.Wrap(err, "failed to extract audit record from transaction")
253+
return errors.Wrap(err, "failed to extract inputs from transaction")
249254
}
250255

251-
return verifyInputIDsMatchExpected(record.Inputs.IDs(), request.Token.Id)
256+
return verifyInputIDsMatchExpected(inputs.IDs(), request.Token.Id)
252257
}
253258

254259
// verifyInputIDsMatchExpected returns nil when every entry in inputIDs equals expected.

token/services/ttx/multisig/spend.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,16 +276,21 @@ func (a *EndorseSpendView) Call(context view.Context) (interface{}, error) {
276276

277277
// verifySpendTxMatchesRequest fails if the received transaction does not consume
278278
// exactly the token referenced by the SpendRequest.
279+
//
280+
// We use Request.Inputs (not AuditRecord) on purpose: the co-owner is not the
281+
// auditor and so does not have audit-level visibility into the spent tokens.
282+
// Inputs returns the token IDs without trying to enrich them via ListAuditTokens,
283+
// which is exactly what we need for the equality check.
279284
func verifySpendTxMatchesRequest(ctx context.Context, tx *ttx.Transaction, request *SpendRequest) error {
280285
if request == nil || request.Token == nil {
281286
return errors.New("spend request is missing the token to authorize")
282287
}
283-
record, err := tx.Request().AuditRecord(ctx)
288+
inputs, err := tx.Request().Inputs(ctx)
284289
if err != nil {
285-
return errors.Wrap(err, "failed to extract audit record from transaction")
290+
return errors.Wrap(err, "failed to extract inputs from transaction")
286291
}
287292

288-
return verifyInputIDsMatchExpected(record.Inputs.IDs(), request.Token.Id)
293+
return verifyInputIDsMatchExpected(inputs.IDs(), request.Token.Id)
289294
}
290295

291296
// verifyInputIDsMatchExpected returns nil when every entry in inputIDs equals expected.

0 commit comments

Comments
 (0)