MCPcopy Create free account
hub / github.com/DEROFDN/Engram / addTransfer

Function addTransfer

functions.go:1094–1215  ·  view source on GitHub ↗

Add a DERO transfer to the batch

()

Source from the content-addressed store, hash-verified

1092
1093// Add a DERO transfer to the batch
1094func addTransfer() error {
1095 var arguments = rpc.Arguments{}
1096 var err error
1097
1098 logger.Printf("[Send] Starting tx...\n")
1099 if tx.Address.IsIntegratedAddress() {
1100 if tx.Address.Arguments.Validate_Arguments() != nil {
1101 logger.Errorf("[Service] Integrated Address arguments could not be validated\n")
1102 err = errors.New("integrated address arguments could not be validated")
1103 return err
1104 }
1105
1106 logger.Printf("[Send] Not Integrated..\n")
1107 if !tx.Address.Arguments.Has(rpc.RPC_DESTINATION_PORT, rpc.DataUint64) {
1108 logger.Errorf("[Service] Integrated Address does not contain destination port\n")
1109 err = errors.New("integrated address does not contain destination port")
1110 return err
1111 }
1112
1113 arguments = append(arguments, rpc.Argument{Name: rpc.RPC_DESTINATION_PORT, DataType: rpc.DataUint64, Value: tx.Address.Arguments.Value(rpc.RPC_DESTINATION_PORT, rpc.DataUint64).(uint64)})
1114 logger.Printf("[Send] Added arguments..\n")
1115
1116 if tx.Address.Arguments.Has(rpc.RPC_EXPIRY, rpc.DataTime) {
1117
1118 if tx.Address.Arguments.Value(rpc.RPC_EXPIRY, rpc.DataTime).(time.Time).Before(time.Now().UTC()) {
1119 logger.Errorf("[Service] This address has expired: %s\n", tx.Address.Arguments.Value(rpc.RPC_EXPIRY, rpc.DataTime))
1120 err = errors.New("this address has expired")
1121 return err
1122 } else {
1123 logger.Warnf("[Service] This address will expire: %s\n", tx.Address.Arguments.Value(rpc.RPC_EXPIRY, rpc.DataTime))
1124 }
1125 }
1126
1127 logger.Printf("[Service] Destination port is integrated in address: %d\n", tx.Address.Arguments.Value(rpc.RPC_DESTINATION_PORT, rpc.DataUint64).(uint64))
1128
1129 if tx.Address.Arguments.Has(rpc.RPC_COMMENT, rpc.DataString) {
1130 logger.Printf("[Service] Integrated Message: %s\n", tx.Address.Arguments.Value(rpc.RPC_COMMENT, rpc.DataString))
1131 arguments = append(arguments, rpc.Argument{Name: rpc.RPC_COMMENT, DataType: rpc.DataString, Value: tx.Address.Arguments.Value(rpc.RPC_COMMENT, rpc.DataString)})
1132 }
1133 }
1134
1135 logger.Printf("[Send] Checking arguments..\n")
1136
1137 for _, arg := range tx.Address.Arguments {
1138 if !(arg.Name == rpc.RPC_COMMENT || arg.Name == rpc.RPC_EXPIRY || arg.Name == rpc.RPC_DESTINATION_PORT || arg.Name == rpc.RPC_SOURCE_PORT || arg.Name == rpc.RPC_VALUE_TRANSFER || arg.Name == rpc.RPC_NEEDS_REPLYBACK_ADDRESS) {
1139 switch arg.DataType {
1140 case rpc.DataString:
1141 arguments = append(arguments, rpc.Argument{Name: arg.Name, DataType: arg.DataType, Value: arg.Value.(string)})
1142 case rpc.DataInt64:
1143 arguments = append(arguments, rpc.Argument{Name: arg.Name, DataType: arg.DataType, Value: arg.Value.(string)})
1144 case rpc.DataUint64:
1145 arguments = append(arguments, rpc.Argument{Name: arg.Name, DataType: arg.DataType, Value: arg.Value.(string)})
1146 case rpc.DataFloat64:
1147 arguments = append(arguments, rpc.Argument{Name: arg.Name, DataType: arg.DataType, Value: arg.Value.(string)})
1148 case rpc.DataTime:
1149 logger.Warnf("[Service] Time currently not supported.\n")
1150 }
1151 }

Callers 1

layoutSendFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected