MCPcopy Create free account
hub / github.com/DNAProject/DNA / SignTransaction

Function SignTransaction

cmd/utils/gas.go:292–321  ·  view source on GitHub ↗
(signer *account.Account, tx *types.MutableTransaction)

Source from the content-addressed store, hash-verified

290}
291
292func SignTransaction(signer *account.Account, tx *types.MutableTransaction) error {
293 if tx.Payer == common.ADDRESS_EMPTY {
294 tx.Payer = signer.Address
295 }
296 txHash := tx.Hash()
297 sigData, err := Sign(txHash.ToArray(), signer)
298 if err != nil {
299 return fmt.Errorf("sign error:%s", err)
300 }
301 hasSig := false
302 for i, sig := range tx.Sigs {
303 if len(sig.PubKeys) == 1 && pubKeysEqual(sig.PubKeys, []keypair.PublicKey{signer.PublicKey}) {
304 if hasAlreadySig(txHash.ToArray(), signer.PublicKey, sig.SigData) {
305 //has already signed
306 return nil
307 }
308 hasSig = true
309 //replace
310 tx.Sigs[i].SigData = [][]byte{sigData}
311 }
312 }
313 if !hasSig {
314 tx.Sigs = append(tx.Sigs, types.Sig{
315 PubKeys: []keypair.PublicKey{signer.PublicKey},
316 M: 1,
317 SigData: [][]byte{sigData},
318 })
319 }
320 return nil
321}
322
323func MultiSigTransaction(mutTx *types.MutableTransaction, m uint16, pubKeys []keypair.PublicKey, signer *account.Account) error {
324 pkSize := len(pubKeys)

Callers 8

invokeCodeContractFunction · 0.92
sigToTxFunction · 0.92
TransferFunction · 0.85
TransferFromFunction · 0.85
ApproveFunction · 0.85
DeployContractFunction · 0.85
InvokeSmartContractFunction · 0.85

Calls 6

pubKeysEqualFunction · 0.85
hasAlreadySigFunction · 0.85
ErrorfMethod · 0.80
SignFunction · 0.70
HashMethod · 0.65
ToArrayMethod · 0.65

Tested by 1