Sign() executes a digital signature on the transaction
(pk crypto.PrivateKeyI)
| 164 | |
| 165 | // Sign() executes a digital signature on the transaction |
| 166 | func (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 |
| 184 | type jsonTx struct { |