MCPcopy
hub / github.com/canopy-network/canopy / Sign

Method Sign

lib/tx.go:166–181  ·  view source on GitHub ↗

Sign() executes a digital signature on the transaction

(pk crypto.PrivateKeyI)

Source from the content-addressed store, hash-verified

164
165// Sign() executes a digital signature on the transaction
166func (x *Transaction) Sign(pk crypto.PrivateKeyI) (err ErrorI) {
167 // get the sign bytes for the transaction
168 signBytes, err := x.GetSignBytes()
169 // if an error occurred during the conversion
170 if err != nil {
171 // exit with error
172 return
173 }
174 // populate the signature field
175 x.Signature = &Signature{
176 PublicKey: pk.PublicKey().Bytes(),
177 Signature: pk.Sign(signBytes),
178 }
179 // exit
180 return
181}
182
183// jsonTx implements the json.Marshaller and json.Unmarshaler interface for the Transaction type
184type jsonTx struct {

Callers 3

TestSignFunction · 0.95
TestCheckSignatureFunction · 0.95
NewTransactionFunction · 0.95

Calls 4

GetSignBytesMethod · 0.95
BytesMethod · 0.65
PublicKeyMethod · 0.65
SignMethod · 0.65

Tested by 2

TestSignFunction · 0.76
TestCheckSignatureFunction · 0.76