Selaa lähdekoodia

TX默认指针,增加了GetInner(),可以获取实际fromtovalue等具体信息。

410 2 vuotta sitten
vanhempi
commit
9a31df6cce
1 muutettua tiedostoa jossa 23 lisäystä ja 0 poistoa
  1. 23 0
      core/types/transaction.go

+ 23 - 0
core/types/transaction.go

@@ -112,6 +112,7 @@ func (tx *Transaction) encodeTyped(w *bytes.Buffer) error {
 // For legacy transactions, it returns the RLP encoding. For EIP-2718 typed
 // transactions, it returns the type and payload.
 func (tx *Transaction) MarshalBinary() ([]byte, error) {
+
 	if tx.Type() == LegacyTxType {
 		return rlp.EncodeToBytes(tx.inner)
 	}
@@ -241,6 +242,28 @@ func (tx *Transaction) Protected() bool {
 	}
 }
 
+// 返回inner所有数据
+
+func (tx *Transaction) GetInner() TxData {
+	return tx.inner
+}
+
+func (tx *Transaction) Inner() (byte, TxData, *big.Int, AccessList, []byte, uint64, *big.Int, *big.Int, uint64, *common.Address, *big.Int, *big.Int, *big.Int) {
+	txType := tx.inner.txType()
+	copiedTxData := tx.inner.copy()
+	chainID := tx.inner.chainID()
+	accessList := tx.inner.accessList()
+	data := tx.inner.data()
+	gas := tx.inner.gas()
+	gasPrice := tx.inner.gasPrice()
+	value := tx.inner.value()
+	nonce := tx.inner.nonce()
+	to := tx.inner.to()
+	v, r, s := tx.inner.rawSignatureValues()
+
+	return txType, copiedTxData, chainID, accessList, data, gas, gasPrice, value, nonce, to, v, r, s
+}
+
 // Type returns the transaction type.
 func (tx *Transaction) Type() uint8 {
 	return tx.inner.txType()