MCPcopy Create free account
hub / github.com/CPChain/chain / WithSignature

Method WithSignature

types/transaction.go:233–241  ·  view source on GitHub ↗

WithSignature returns a new transaction with the given signature. This signature needs to be formatted as described in the yellow paper (v+27).

(signer Signer, sig []byte)

Source from the content-addressed store, hash-verified

231// WithSignature returns a new transaction with the given signature.
232// This signature needs to be formatted as described in the yellow paper (v+27).
233func (tx *Transaction) WithSignature(signer Signer, sig []byte) (*Transaction, error) {
234 r, s, v, err := signer.SignatureValues(tx, sig)
235 if err != nil {
236 return nil, err
237 }
238 cpy := &Transaction{data: tx.data}
239 cpy.data.R, cpy.data.S, cpy.data.V = r, s, v
240 return cpy, nil
241}
242
243// Cost returns amount + gasprice * gaslimit.
244func (tx *Transaction) Cost() *big.Int {

Callers 8

TestBlockEncodingFunction · 0.95
Test_sigHashFunction · 0.95
Test_ecrecoverFunction · 0.95
SignTxFunction · 0.80
NewKeyedTransactorFunction · 0.80

Calls 1

SignatureValuesMethod · 0.65

Tested by 5

TestBlockEncodingFunction · 0.76
Test_sigHashFunction · 0.76
Test_ecrecoverFunction · 0.76