Exemple #1
0
func (self *Value) EncodeRLP(w io.Writer) error {
	if self == nil {
		w.Write(rlp.EmptyList)
		return nil
	} else {
		return rlp.Encode(w, self.Val)
	}
}
Exemple #2
0
func Broadcast(tx *Transaction) (interface{}, error) {
	w := new(bytes.Buffer)
	if err := rlp.Encode(w, tx); err != nil {
		return nil, err
	}
	txHex := fmt.Sprintf("%X", w.Bytes())
	logger.Debugln("Broadcasting transaction bytes", txHex)
	r, err := EthClient.RequestResponse("eth", "sendRawTransaction", txHex)
	if err != nil {
		return nil, err
	}
	return r, nil
}
Exemple #3
0
// rlp encode and hash (for tx sign bytes)
func rlpHash(x interface{}) (h common.Hash) {
	hw := sha3.NewKeccak256()
	rlp.Encode(hw, x)
	hw.Sum(h[:0])
	return h
}
Exemple #4
0
func rlpEncode(x interface{}) []byte {
	w := new(bytes.Buffer)
	rlp.Encode(w, x)
	return w.Bytes()
}