@@ -60,9 +60,10 @@ type ChaincodeStub struct {
60
60
chaincodeEvent * pb.ChaincodeEvent
61
61
args [][]byte
62
62
handler * Handler
63
+ signedProposal * pb.SignedProposal
63
64
proposal * pb.Proposal
64
65
65
- // Additional fields extracted from the proposal
66
+ // Additional fields extracted from the signedProposal
66
67
creator []byte
67
68
transient map [string ][]byte
68
69
binding []byte
@@ -286,28 +287,32 @@ func chatWithPeer(chaincodename string, stream PeerChaincodeStream, cc Chaincode
286
287
// -- init stub ---
287
288
// ChaincodeInvocation functionality
288
289
289
- func (stub * ChaincodeStub ) init (handler * Handler , txid string , input * pb.ChaincodeInput , proposal * pb.Proposal ) error {
290
+ func (stub * ChaincodeStub ) init (handler * Handler , txid string , input * pb.ChaincodeInput , signedProposal * pb.SignedProposal ) error {
290
291
stub .TxID = txid
291
292
stub .args = input .Args
292
293
stub .handler = handler
293
- stub .proposal = proposal
294
+ stub .signedProposal = signedProposal
294
295
295
296
// TODO: sanity check: verify that every call to init with a nil
296
- // proposal is a legitimate one, meaning it is an internal call
297
+ // signedProposal is a legitimate one, meaning it is an internal call
297
298
// to system chaincodes.
298
- if proposal != nil {
299
- // Extract creator, transient, binding...
299
+ if signedProposal != nil {
300
300
var err error
301
- stub .creator , stub .transient , err = utils .GetChaincodeProposalContext (proposal )
301
+
302
+ stub .proposal , err = utils .GetProposal (signedProposal .ProposalBytes )
303
+ if err != nil {
304
+ return fmt .Errorf ("Failed extracting signedProposal from signed signedProposal. [%s]" , err )
305
+ }
306
+
307
+ // Extract creator, transient, binding...
308
+ stub .creator , stub .transient , err = utils .GetChaincodeProposalContext (stub .proposal )
302
309
if err != nil {
303
- return fmt .Errorf ("Failed extracting proposal fields. [%s]" , err )
310
+ return fmt .Errorf ("Failed extracting signedProposal fields. [%s]" , err )
304
311
}
305
312
306
- // TODO: txid must uniquely identity the transaction.
307
- // Remove this comment once replay attack protection will be in place
308
- stub .binding , err = utils .ComputeProposalBinding (proposal )
313
+ stub .binding , err = utils .ComputeProposalBinding (stub .proposal )
309
314
if err != nil {
310
- return fmt .Errorf ("Failed computing binding from proposal . [%s]" , err )
315
+ return fmt .Errorf ("Failed computing binding from signedProposal . [%s]" , err )
311
316
}
312
317
}
313
318
@@ -590,7 +595,7 @@ func (stub *ChaincodeStub) GetFunctionAndParameters() (function string, params [
590
595
return
591
596
}
592
597
593
- // GetCreator returns SignatureHeader.Creator of the proposal
598
+ // GetCreator returns SignatureHeader.Creator of the signedProposal
594
599
// this Stub refers to.
595
600
func (stub * ChaincodeStub ) GetCreator () ([]byte , error ) {
596
601
return stub .creator , nil
@@ -610,6 +615,11 @@ func (stub *ChaincodeStub) GetBinding() ([]byte, error) {
610
615
return stub .binding , nil
611
616
}
612
617
618
+ // GetSignedProposal return the signed signedProposal this stub refers to.
619
+ func (stub * ChaincodeStub ) GetSignedProposal () (* pb.SignedProposal , error ) {
620
+ return stub .signedProposal , nil
621
+ }
622
+
613
623
// GetArgsSlice returns the arguments to the stub call as a byte array
614
624
func (stub * ChaincodeStub ) GetArgsSlice () ([]byte , error ) {
615
625
args := stub .GetArgs ()
0 commit comments