當前位置: 首頁>>代碼示例>>Golang>>正文


Golang ITransaction.GetOutputs方法代碼示例

本文整理匯總了Golang中github.com/FactomProject/factoid.ITransaction.GetOutputs方法的典型用法代碼示例。如果您正苦於以下問題:Golang ITransaction.GetOutputs方法的具體用法?Golang ITransaction.GetOutputs怎麽用?Golang ITransaction.GetOutputs使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/FactomProject/factoid.ITransaction的用法示例。


在下文中一共展示了ITransaction.GetOutputs方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: FactoidAddOutput

func FactoidAddOutput(trans fct.ITransaction, key string, address fct.IAddress, amount uint64) error {
	ok := Utility.IsValidKey(key)
	if !ok {
		return fmt.Errorf("Invalid name for transaction")
	}

	// First look if this is really an update
	for _, output := range trans.GetOutputs() {
		if output.GetAddress().IsSameAs(address) {
			output.SetAmount(amount)
			return nil
		}
	}
	// Add our new Output
	err := factoidState.GetWallet().AddOutput(trans, address, uint64(amount))
	if err != nil {
		return fmt.Errorf("Failed to add output")
	}

	// Update our map with our new transaction to the same key.  Otherwise, all
	// of our work will go away!
	factoidState.GetDB().PutRaw([]byte(fct.DB_BUILD_TRANS), []byte(key), trans)

	return nil
}
開發者ID:johncap46,項目名稱:fctwallet,代碼行數:25,代碼來源:transaction.go

示例2: UpdateTransaction

// Assumes validation has already been done.
func (fs *FactoidState) UpdateTransaction(trans fct.ITransaction) error {
	for _, input := range trans.GetInputs() {
		err := fs.UpdateBalance(input.GetAddress(), -int64(input.GetAmount()))
		if err != nil {
			return err
		}
	}
	for _, output := range trans.GetOutputs() {
		err := fs.UpdateBalance(output.GetAddress(), int64(output.GetAmount()))
		if err != nil {
			return err
		}
	}
	for _, ecoutput := range trans.GetECOutputs() {
		err := fs.UpdateECBalance(ecoutput.GetAddress(), int64(ecoutput.GetAmount()))
		if err != nil {
			return err
		}
	}

	fs.numTransactions++
	cp.CP.AddUpdate(
		"transprocessed", // tag
		"status",         // Category
		fmt.Sprintf("Factoid Transactions Processed: %d", fs.numTransactions), // Title
		"", // Message
		0)  // When to expire the message; 0 is never

	return nil
}
開發者ID:conseweb,項目名稱:factoid,代碼行數:31,代碼來源:factoidstate.go

示例3: filtertransaction

func filtertransaction(trans fct.ITransaction, addresses [][]byte) bool {
	if addresses == nil || len(addresses) == 0 {
		return true
	}
	if len(trans.GetInputs()) == 0 &&
		len(trans.GetOutputs()) == 0 {
		return false
	}

	if len(addresses) == 1 && bytes.Equal(addresses[0], trans.GetSigHash().Bytes()) {
		return true
	}

Search:
	for _, adr := range addresses {

		for _, in := range trans.GetInputs() {
			if bytes.Equal(adr, in.GetAddress().Bytes()) {
				continue Search
			}
		}
		for _, out := range trans.GetOutputs() {
			if bytes.Equal(adr, out.GetAddress().Bytes()) {
				continue Search
			}
		}
		for _, ec := range trans.GetECOutputs() {
			if bytes.Equal(adr, ec.GetAddress().Bytes()) {
				continue Search
			}
		}
		return false
	}
	return true
}
開發者ID:johncap46,項目名稱:fctwallet,代碼行數:35,代碼來源:transactionlist.go

示例4: PrtTrans

func PrtTrans(t fct.ITransaction) {
	fmt.Println("Transaction")
	for _, input := range t.GetInputs() {
		fmt.Println("in ", input.GetAddress(), input.GetAmount(), fs.GetBalance(input.GetAddress()))
	}
	for _, output := range t.GetOutputs() {
		fmt.Println("out", output.GetAddress(), output.GetAmount(), fs.GetBalance(output.GetAddress()))
	}
	for _, ecoutput := range t.GetECOutputs() {
		fmt.Println("ec ", ecoutput.GetAddress(), ecoutput.GetAmount(), fs.GetECBalance(ecoutput.GetAddress()))
	}
}
開發者ID:FactomProject,項目名稱:Testing,代碼行數:12,代碼來源:block_test.go

示例5: FactoidSubFee

func FactoidSubFee(trans fct.ITransaction, key string, address fct.IAddress, name string) (uint64, error) {
	{
		ins, err := trans.TotalInputs()
		if err != nil {
			return 0, err
		}
		outs, err := trans.TotalOutputs()
		if err != nil {
			return 0, err
		}
		ecs, err := trans.TotalECs()
		if err != nil {
			return 0, err
		}

		if ins != outs+ecs {
			return 0, fmt.Errorf("Inputs and outputs don't add up")
		}
	}

	ok := Utility.IsValidKey(key)
	if !ok {
		return 0, fmt.Errorf("Invalid name for transaction")
	}

	fee, err := GetFee()
	if err != nil {
		return 0, err
	}

	transfee, err := trans.CalculateFee(uint64(fee))
	if err != nil {
		return 0, err
	}

	adr, err := factoidState.GetWallet().GetAddressHash(address)
	if err != nil {
		return 0, err
	}

	for _, output := range trans.GetOutputs() {
		if output.GetAddress().IsSameAs(adr) {
			output.SetAmount(output.GetAmount() - transfee)
			return transfee, nil
		}
	}
	return 0, fmt.Errorf("%s is not an output to the transaction.", name)
}
開發者ID:FactomProject,項目名稱:fctwallet,代碼行數:48,代碼來源:transaction.go


注:本文中的github.com/FactomProject/factoid.ITransaction.GetOutputs方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。